基础介绍

SkyWalking的接口并没有使用常见的RESTful架构,它使用了GraphQL协议。

什么是GraphQL?

官方解释
GraphQL 旨在让 API 变得快速、灵活并且为开发人员提供便利。作为 REST 的替代方案,GraphQL 允许开发人员构建相应的请求,从而通过单个 API 调用从多个数据源中提取数据。
总结
简单的说,GraphQL通过请求参数中的方法名来区分不同接口,并且可以根据接口的需要,自定义设置需要返回的结果值。

参数解释

官方参数

ID
The ID scalar type represents a unique identifier, often used to refetch an object or as key for a cache.
The ID type appears in a JSON response as a String; however, it is not intended to be human-readable.
When expected as an input type, any string (such as "4") or integer (such as 4) input value will be accepted as an ID.

ID标量类型表示唯一标识符,通常用于重新获取对象或作为缓存的键。
ID类型在JSON响应中以String形式出现;但是,它并不是为可读的。
当需要作为输入类型时,任何字符串(如“4”)或整数(如4)输入值将被接受为ID。

公用参数

Pagination分页
参数名 类型 是否必须 解释
pageNum int false 页数
pageSize int true 条数
needTotal Boolean false 是否需要总数量(默认false)
Duration时间框
参数名 类型 是否必须 解释
start String true 开始时间
end String true 结束时间
step Step(DAY/HOUR/MINUTE/SECOND) true 时间类型

接口

链路相关

查询链路数据
接口名

queryTrace

请求参数
参数名 类型 解释
traceId ID 链路ID
响应参数
参数名 类型 解释
traceId ID 链路ID
segmentId ID 区间ID,同一线程内相同,跨线程不同
spanId Int spanID,同一个线程中唯一, 从0始递增
parentSpanId Int 父spanID,最上层为-1
refs ref { traceId: ID
parentSegmentId: ID
parentSpanId: Int
type: RefTyp(CROSS_PROCESS/CROSS_THREAD)}
serviceCode String 服务
serviceInstanceName ID 服务实例
startTime Long 起始时间
endTime Long 结束时间
endpointName String 端点
type String 跨度类型(Local/Entry/Exit)
peer String 网络地址(host:port/ip:port)
component String 组件
isError Boolean 是否失败
layer String (Unknown/Database/RPCFramework/Http/MQ/Cache)
tags KeyValue { key: String
value: String; }
详情
1. http服务(url/http.method/http.status_code)
2.数据库(db.type/db.instance/db.statement)
logs LogEntity { time: Long!
data: [KeyValue!]
}
日志
查询Basic链路
接口名

queryBasicTraces

请求参数
参数名 类型 是否必须 解释
condition TraceQueryCondition true 查询对象

TraceQueryCondition

参数名 类型 是否必须 解释
traceState TraceState(ALL/SUCCESS/ERROR) true trace状态
queryOrder QueryOrder(BY_START_TIME/BY_DURATION) true 排序条件
paging Pagination true 分页
traceId String false 链路ID(traceId和queryDuration必须要有一个)
queryDuration Duration false 开始跟踪的时间范围
minTraceDuration int false 最小时间
maxTraceDuration int false 最大时间
serviceId ID false 服务ID,0为所有服务
serviceInstanceId ID false
endpointId ID false 端点ID
endpointName String false 端点名
tags SpanTag(Key/Value) false
响应参数
参数名 类型 是否必须 解释
traces BasicTrace true
total int true 排序条件

BasicTrace

参数名 类型 是否必须 解释
segmentId String true 区间ID
endpointNames String[] true 端点名
duration int true 持续时间(ms)
start String true 开始时间
isError Boolean false 是否失败
traceIds String[] true 链路ID
Logo

DAMO开发者矩阵,由阿里巴巴达摩院和中国互联网协会联合发起,致力于探讨最前沿的技术趋势与应用成果,搭建高质量的交流与分享平台,推动技术创新与产业应用链接,围绕“人工智能与新型计算”构建开放共享的开发者生态。

更多推荐