SkyWalking GraphQL API 查询实例
所属分类 skywalking
浏览量 373
SkyWalking 查询指标两种方法
GraphQL API
PromQL API
https://skywalking.apache.org/docs/main/v9.4.0/en/api/query-protocol/
https://github.com/apache/skywalking-query-protocol
与 RESTful 不同,每一个的 GraphQL 服务对外只提供一个 endpoint
http://{SKYWALKING_oap}:{port}/graphql
http://192.168.1.10:12800/graphql
grpc端口 agent数据报送 11800
http端口 12800 ,给ui 提供 graphql接口
ui端口 8080
LogQL API 端口 3100
PromQL API 端口 9090
java -javaagent:/xxx/skywalking-agent.jar -Dskywalking.agent.service_name=demoapp -Dskywalking.collector.backend_service=192.168.1.10:11800 -jar demoapp-1.0.jar
-Dskywalking.collector.backend_service=192.168.1.10:11800
query {
getTimeInfo {
timezone
currentTimestamp
}
}
query 可省略
{
getTimeInfo {
timezone
currentTimestamp
}
}
使用json格式
{
"query":"{查询语句}"
"variables":"{参数和参数值}"
}
{
"query":"{getTimeInfo {timezone currentTimestamp}}"
}
query ReadMetricsValues {
readMetricsValues(condition: {
name: "service_cpm", entity: {scope: Service, serviceName: "demoapp", normal: true}
}, duration: {
start: "2024-03-25 00",
end: "2024-03-26 13",
step: HOUR
}) {
label
values {
values {
id
value
}
}
}
}
查询service
{
"query": "query queryServices($duration: Duration!,$keyword: String!) { services: getAllServices(duration: $duration, group: $keyword) { key: id label: name group } }",
"variables": {
"duration": {
"start": "2024-03-26 00",
"end": "2024-03-26 15",
"step": "HOUR"},
"keyword": ""
}
}
返回结果
{
"data": {
"services": [
{
"key": "ZGVtb2FwcDAwMQ==.1",
"label": "demoapp001",
"group": ""
},
{
"key": "MTAuMTc2LjU2LjQ6NjQ1NA==.0",
"label": "192.168.1.10:6454",
"group": ""
}
]
}
}
查询instance
{
"query":"query queryServiceInstance($duration: Duration!, $serviceId: ID!){ instanceId: getServiceInstances(duration: $duration, serviceId: $serviceId) { key: id label: name }}",
"variables":{
"duration":{
"start":"2024-03-26 15",
"end":"2024-03-26 15",
"step":"HOUR"},
"serviceId":"ZGVtb2FwcDAwMQ==.1"}
}
{
"data": {
"instanceId": [
{
"key": "ZGVtb2FwcDAwMQ==.1_NDVjNzVmODU1YmEzNDYyMmE5OWRjYTVjNWZhY2JjMTNAMTAuMTc2LjE4Mi4xMzQ=",
"label": "45c75f855ba34622a99dca5c5facbc13@10.176.182.134"
}
]
}
}
查询追踪列表
{
"query":"query queryTraces($condition: TraceQueryCondition) { data: queryBasicTraces(condition: $condition) { traces { key: segmentId endpointNames duration start isError traceIds } total }}",
"variables":{
"condition":{
"queryDuration":{
"start":"2022-02-08 0534",
"end":"2022-02-08 0549",
"step":"MINUTE"},
"traceState":"ALL",
"paging":{
"pageNum":1,
"pageSize":15,
"needTotal":true},
"queryOrder":"BY_START_TIME",
"serviceId":"aGJvcy1kdGM=.1"
}
}
}
查询追踪详情
{
"query":"query queryTrace($traceId: ID!) { trace: queryTrace(traceId: $traceId) { spans { traceId segmentId spanId parentSpanId refs { traceId parentSegmentId parentSpanId type } serviceCode serviceInstanceName startTime endTime endpointName type peer component isError layer tags { key value } logs { time data { key value } } } } }",
"variables":{
"traceId":"12dbf0f5f72d40a58f4b27742c149413.264.16520813026010455"
}
}
上一篇
下一篇
mysql监控 mysqld_exporter
SkyWalking 慢sql 数据获取 ,graphQL 接口 例子
西湖古诗词
Java实现GraphQL服务
杭州西湖三十景
GraphQL 基础