链路追踪的数据存储在SLS里面,如果您需要自定义检索数据,可以根据数据格式写SQL进行数据检索。

链路追踪数据在SLS里面的Project名称格式为:
proj-xtrade-***-{regionId}
例如:
proj-xtrace-6dcbb77ef4ba6ef5466b5debf9e2f951-cn-beijing

链路详情(Span的格式)

对应的LogStore名称格式为:
logstore-xtrace-{userId}-{regionId}
例如:
logstore-xtrace-123456789-cn-beijing
字段名 字段说明
traceId 调用链ID,链路请求的唯一标识。例如:fec891bb8f81e7fb。
timestamp Span的产生时间,单位为微秒。例如:1607410144095000。
rpc Span名称或者是Operator名称。例如:/health。
serviceName Span所在的微服务名称,又称为应用名称。例如:order。
serverIp Span所在的机器IP地址。例如:127.0.0.1。
elapsed 耗时,单位是微秒。例如:1000表示1毫秒。
spanId Span ID,链路中的唯一标识。例如:fec891bb8f81e7fc。
parentSpanId 父亲spanId,用来记录当前Span的父亲spanId。 例如:fec891bb8f81e7fb。
anno 记录Span的tag信息。例如:lb=prod&。

实际场景使用举例:

  • 查找耗时大于1秒的请求。
    elapsed > 1000 | select distinct traceId
  • 查找耗时大于1秒的请求,而且经过172.16.0.0这台机器。
    * and serverIp = "172.16.0.0" and elapsed > 1000 | select distinct traceId

链路统计(Metric的格式)

对应的LogStore名称格式为:
logstore-xtrace-{userId}-stat-{regionId}
例如:
logstore-xtrace-123456789-stat-cn-beijing
字段名 字段说明
serviceName Span所在的微服务名称,又称为应用名称。例如:order。
rpc Span名称或者是Operator名称。例如:/health。
elapsed 统计时间内的总耗时,单位为毫秒。例如:值为10, 表示10毫秒。
avg_elapsed 统计时间内的平均耗时,单位为毫秒。例如:值为10, 表示10毫秒。
count 统计时间内的数据。例如:10。
timestamp 统计时间,单位为毫秒。例如:1607410144000。

实际场景使用举例:

  • 查找Span名称为/api1的平均请求数。
    rpc: "/api1" |select sum(count) qps timestamp GROUP by timestamp
  • 查找Span名称为/api1的平均耗时。
    rpc: "/api1" |select sum(elapsed) /sum(count) rt, timestamp GROUP by timestamp