SELECT ServiceName, SpanName, ResourceAttributes['host.name'] AS host, ResourceAttributes['k8s.pod.name'] AS pod, ResourceAttributes['deployment.environment'] AS envFROM otel_tracesLIMIT 10;
按 Map 值过滤 — 查找特定服务名称的所有 spans:
SELECT Timestamp, SpanName, Duration / 1e6 AS duration_msFROM otel_tracesWHERE ResourceAttributes['service.name'] = 'cartservice'ORDER BY TimestampLIMIT 10;
SELECT ServiceName, mapFilter((k, v) -> k LIKE 'k8s.%', ResourceAttributes) AS k8s_attrsFROM otel_tracesWHERE mapContains(ResourceAttributes, 'k8s.pod.name')LIMIT 10;
查找错误 span 及其资源上下文 — 将常规列过滤条件与 Map 访问结合使用:
SELECT Timestamp, ServiceName, SpanName, ResourceAttributes['host.name'] AS host, ResourceAttributes['k8s.pod.name'] AS pod, SpanAttributes['error.type'] AS error_type, SpanAttributes['error.message'] AS error_messageFROM otel_tracesWHERE StatusCode = 'STATUS_CODE_ERROR';