全部產品
Search
文件中心

Cloud Monitor:Phase 2 Object模式 - 方法列表

更新時間:Sep 27, 2025

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__()進行“動態能力發現”。

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'
    )