Phase 2 Object模式 - 方法列表

Object 模式通过在EntitySet上下文中调用方法(entity-call),提供统一、抽象且可扩展的对象语义查询能力。本节按方法类别汇总说明语法、参数与示例,便于上层快速集成与自适应调用。

通用调用语法:

.entity_set with(domain='域名', name='实体名称', [ids|query|其他参数])
| entity-call 方法名(参数...)

通用参数:

参数名

类型

必填

说明

示例值

domain

string

EntitySet 所属域

‘apm’

name

string

EntitySet 名称

‘apm.service’

ids

array

实体ID列表

[‘id1’,‘id2’]

query

string

过滤条件,请参考 SPL 表达式语法

‘service_id = “xxx”’

提示:方法的可用性、参数与返回值,会随实体实际关联的DataSet/Link变化。建议先使用__list_method__()进行“动态能力发现”。

应用案例

当前应用案例相关素材,请参考:umodel.zip

1. 实体内置方法

1.1 list_method(方法清单)

  • 功能:枚举当前EntitySet支持的所有方法、参数Schema与返回Schema。

  • 示例:

    .entity_set with(domain='apm', name='apm.service')
    | entity-call __list_method__()
    
  • 返回字段:namedisplay_namedescriptionparams(JSON Array)、returns(JSON Array)。

1.2 get_entity_set(获取当前实体定义)

  • 功能:返回当前EntitySet的定义信息(不接入任何外部数据集)。

  • 参数:

    参数名

    类型

    必填

    说明

    示例值

    detail

    boolean

    是否返回完整定义JSON

    false

  • 示例:

    .entity_set with(domain='apm', name='apm.service')
    | entity-call get_entity_set()
    
  • 返回字段:entity_set_iddomainnamefilterable_fieldsfieldsentity_set_detail

1.3 list_data_set(列出关联数据集)

  • 功能:列出当前实体关联的DataSet(MetricSet、LogSet、TraceSet、EventSet、ProfileSet)。

  • 参数:

    参数名

    类型

    必填

    说明

    示例值

    data_set_types

    array

    过滤数据集类型

    [‘metric_set’]

    detail

    boolean

    是否返回详细信息

    true

  • 示例:

    .entity_set with(domain='apm', name='apm.service')
    | entity-call list_data_set(['metric_set'], true)
    
  • 返回字段:data_set_idtypedomainnamefields_mappingfilterable_fieldsfieldsdata_link_detaildata_set_detail

  • 功能:列出与当前EntitySet相关的其他实体集合。

  • 参数:

    参数名

    类型

    必填

    说明

    示例值

    relations

    array

    关系类型过滤

    [‘contains’]

    direction

    string

    方向:‘in’/‘out’/‘both’

    ‘out’

    detail

    boolean

    是否返回详细信息

    true

  • 示例:

    .entity_set with(domain='apm', name='apm.service')
    | entity-call list_related_entity_set(['contains'], 'out')
    
  • 返回字段:entity_set_idrelationdirectiondomainnamefields_mappingfieldsrelation_data_setsentity_link_detailentity_set_detail

1.5 inspect(配置检查)

  • 功能:验证UModel配置的完整性与合理性,输出结构化检查报告(错误/警告/提示)。

  • 参数:无

2. 实体列表访问方法

2.1 get_entities(实体列表)

  • 功能:获取当前EntitySet中的实体列表;过滤条件与ID列表通过通用上下文参数传入。

  • 获取所有实体:

.entity_set with(domain='apm', name='apm.service')
| entity-call get_entities()

返回的SPL:

.entity with(domain='apm', type='apm.service')
  • 根据ID获取:

.entity_set with(domain='apm', name='apm.service', ids=['4503c9','35353'])
| entity-call get_entities()

返回的SPL:

.entity with(domain='apm', type='apm.service', entityIds='4503c9,35353')
  • 根据条件获取:

.entity_set with(domain='apm', name='apm.service', query='service = "order"')
| entity-call get_entities()

返回的SPL:

.entity with(domain='apm', type='apm.service') | where service = 'order'

2.2 get_neighbor_entities(相邻实体)

  • 功能:获取与当前实体相邻的其他实体,支持关系类型与方向过滤。

  • 参数:

    参数名

    类型

    必填

    说明

    dest_entity_set_domain

    string

    目标实体域名,空表示全部

    dest_entity_set_name

    string

    目标实体名称,空表示全部

    dest_entity_ids

    array

    目标实体ID列表,空数组表示全部

    dest_entity_filter

    string

    目标实体过滤条件,空表示全部

    relation_type

    string

    关系类型,空表示全部

    direction

    string

    ‘in’/‘out’/‘both’,空表示全部

  • 示例:

    .entity_set with(domain='apm', name='apm.service', ids=['aa158','xxx'])
    | entity-call get_neighbor_entities('apm','apm.external.rpc_client',['abc123'],
        'region_id = "cn-hongkong" and call_type = "grpc_client" and instance_addr = "cart"',
        'contains','out')
    
  • 返回:一个properties列表,每项为目标实体的properties JSON。

3. 数据集访问方法

3.1 get_golden_metrics(黄金指标集合)

  • 功能:获取实体关联MetricSet中标记为“黄金指标”的时间序列,最多返回10个黄金指标。

  • 参数:

    参数名

    类型

    必填

    说明

    默认

    query_type

    string

    ‘range’ 或 ‘instant’

    ‘range’

    step

    string

    步长,仅range有效

    自动

    aggregate

    boolean

    是否聚合

    true

  • 示例:

    .entity_set with(domain='apm', name='apm.service', query='service_id = "order-service"')
    | entity-call get_golden_metrics('range', '1m')
    
  • 返回:metric__labels____ts____value__

3.2 get_metric(获取指标数据)

  • 功能:从关联MetricSet获取指标数据,自动应用字段映射与过滤条件。

  • 参数:

    参数名

    类型

    必填

    说明

    domain

    string

    MetricSet 域名

    name

    string

    MetricSet 名称

    metric

    string

    指标名称

    query_type

    string

    ‘range’ 或 ‘instant’

    step

    string

    步长

    aggregate

    boolean

    是否聚合

  • 示例:

    .entity_set with(domain='apm', name='apm.service', query='service_id = "order-service"')
    | entity-call get_metric('apm', 'apm.metric.apm.service', 'request_count', 'range', '1m')
    

3.3 get_label_values(获取标签值)

  • 参数:

    参数名

    类型

    必填

    说明

    domain

    string

    MetricSet 域名

    name

    string

    MetricSet 名称

    label

    string

    标签名称

  • 示例:

    .entity_set with(domain='apm', name='apm.service', query='service_id = "order-service"')
    | entity-call get_label_values('apm', 'apm.metric.apm.service', 'region')
    

3.4 get_log/get_trace/get_event/get_profile(获取日志/追踪/事件/性能剖析数据)

  • 参数:

    参数名

    类型

    必填

    说明

    domain

    string

    LogSet 域名

    name

    string

    LogSet 名称

  • 示例:

    .entity_set with(domain='apm', name='apm.service', query='service_id = "order-service"')
    | entity-call get_log('apm', 'apm.log.app')
    

4. 关系数据访问方法

4.1 get_relation_golden_metrics(关系黄金指标)

  • 功能:在实体关系上获取黄金指标,自动结合源/目标实体数据构建过滤条件并应用字段映射。

  • 参数:

    参数名

    类型

    必填

    说明

    dest_entity_set_domain

    string

    目标实体域名

    dest_entity_set_name

    string

    目标实体名称

    entity_ids

    array

    目标实体ID列表,可为空数组

    dest_entity_filter

    string

    目标实体过滤条件,可为空字符串

    entity_link_type

    string

    关系类型(如 ‘calls’,‘contains’)

    direction

    string

    方向(‘in’/‘out’)

    query_type

    string

    ‘range’ 或 ‘instant’

    step

    string

    步长,仅range有效

    aggregate

    boolean

    是否聚合

  • 示例:

    .entity_set with(domain='apm', name='apm.service', query='service = "service-a"')
    | entity-call get_relation_golden_metrics(
        'apm', 'apm.service', [], 'service = "service-b"',
        'calls', 'out',
        'range', '5m', false
    )
    
  • 返回:metric__labels____ts____value__

4.2 get_relation_metric(关系指标)

  • 功能:在实体关系上获取指定MetricSet的指标数据。

  • 参数:

参数名

类型

必填

说明

dest_entity_set_domain

string

目标实体域名

dest_entity_set_name

string

目标实体名称

dest_entity_ids

array

目标实体ID列表,可为空数组

dest_entity_filter

string

目标实体过滤条件,可为空字符串

entity_link_type

string

关系类型(如 ‘calls’,‘contains’)

direction

string

方向(‘in’/‘out’)

metric_set_domain

string

MetricSet 域名

metric_set_name

string

MetricSet 名称

metric

string

指标名称

query_type

string

‘range’ 或 ‘instant’

step

string

步长

aggregate

boolean

是否聚合

  • 示例:

.entity_set with(domain='apm', name='apm.service', query='service = "service-a"')
| entity-call get_relation_metric(
    'apm', 'apm.service', [], 'service = "service-b"',
    'calls', 'out',
    'apm', 'apm.metric.service_calls_service',
    'request_count', 'range', '5m'
)

4.3 get_relation_label_values(关系标签值)

  • 功能:在实体关系上获取关联MetricSet的标签值。

  • 参数:

参数名

类型

必填

说明

dest_entity_set_domain

string

目标实体域名

dest_entity_set_name

string

目标实体名称

dest_entity_ids

array

目标实体ID列表

dest_entity_filter

string

目标实体过滤条件

entity_link_type

string

关系类型

direction

string

方向(‘in’/‘out’)

metric_set_domain

string

MetricSet 域名

metric_set_name

string

MetricSet 名称

label

string

标签名称,空或不填表示全部

  • 示例:

.entity_set with(domain='apm', name='apm.service', query='service_id = "service-a"')
| entity-call get_relation_label_values(
    'apm', 'apm.operation', [], 'service = "service-a"',
    'contains', 'out',
    'apm', 'apm.metric.apm.operation',
    'rpc'
)

4.4 get_relation_log/get_relation_trace/get_relation_event/get_relation_profile(关系日志/追踪/事件/性能剖析)

  • 功能:在实体关系上获取关联LogSet的日志数据。

  • 参数:

参数名

类型

必填

说明

dest_entity_set_domain

string

目标实体域名

dest_entity_set_name

string

目标实体名称

dest_entity_ids

array

目标实体ID列表

dest_entity_filter

string

目标实体过滤条件

entity_link_type

string

关系类型

direction

string

方向(‘in’/‘out’)

log_set_domain

string

LogSet 域名

log_set_name

string

LogSet 名称

  • 示例:

    .entity_set with(domain='apm', name='apm.service', ids=['dc5abde8cd8cbc1fd142927f006f694d'])
    | entity-call get_relation_log(
        'apm', 'apm.operation', ['dc5abde8cd8cbc1fd142927f006f694a'], '',
        'contains', 'out',
        'apm', 'apm.log.relation'
    )