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__()
返回字段:
name
、display_name
、description
、params
(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_id
、domain
、name
、filterable_fields
、fields
、entity_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_id
、type
、domain
、name
、fields_mapping
、filterable_fields
、fields
、data_link_detail
、data_set_detail
。
1.4 list_related_entity_set(列出相关实体)
功能:列出与当前
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_id
、relation
、direction
、domain
、name
、fields_mapping
、fields
、relation_data_sets
、entity_link_detail
、entity_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' )