• Skywalking-10:Skywalking查询协议——GraphQL


    GraphQL

    GraphQL 基础

    参照Getting started with GraphQL Java and Spring Boot这篇文章学习即可

    PS:可以使用 brew install --cask graphql-playground 安装 graphql for mac 客户端。

    IDEA 怎么调试 GraphQL 应用

    安装 JS GraphQL 插件

    点击JS GraphQL安装插件

    GraphQL 定义

    schema.graphqls

    type Query {
        bookById(id: ID): Book
    }
    
    type Book {
        id: ID
        name: String
        pageCount: Int
        author: Author
    }
    
    type Author {
        id: ID
        firstName: String
        lastName: String
    }
    

    GraphQL 配置文件

    .graphqlconfig

    {
      "name": "book-details",
      "schemaPath": "schema.graphqls",
      "extensions": {
        "endpoints": {
          "Default GraphQL Endpoint": {
            "url": "http://localhost:8080/graphql", // 请求路径
            "headers": {
              "user-agent": "JS GraphQL"
            },
            "introspect": false
          }
        }
      }
    }
    

    创建一个查询文件

    query.graphql

    # {"id": "book-1"}
    query queryData($id: ID) {
        bookById(id: $id) {
            id name pageCount author {
                id firstName lastName
            }
        }
    }
    

    GraphQL 脚本目录结构

    resources
    ├── .graphqlconfig  # 配置文件
    ├── query.graphql   # 查询文件
    └── schema.graphqls # 定义文件
    

    执行结果

    GraphQL 在 Skywalking 中的应用

    graphql 协议文件路径: oap-server/server-query-plugin/query-graphql-plugin/src/main/resources/query-protocol

    GraphQL 配置文件

    .graphqlconfig

    {
      "name": "skywalking",
      "schemaPath": "schema.graphql",
      "extensions": {
        "endpoints": {
          "Default GraphQL Endpoint": {
            "url": "http://localhost:8080/graphql",
            "headers": {
              "user-agent": "JS GraphQL"
            },
            "introspect": true
          }
        }
      }
    }
    

    创建一个查询文件

    query.graphql

    query queryData {
        readMetricsValues(
            duration: {start: "2021-07-03 1400",end: "2021-07-03 1401", step: MINUTE},
            condition: {
                name: "instance_jvm_thread_runnable_thread_count",
                entity: {
                    scope: ServiceInstance,
                    serviceName: "business-zone::projectA",
                    serviceInstanceName: "e8cf34a1d54a4058a8c98505877770e2@192.168.50.113",
                    normal: true
                }
            }
        ) { 
            label values{ values{ id value }}
        }
    }
    

    执行结果

    {
      "data": {
        "readMetricsValues": {
          "values": {
            "values": [
              {
                "id": "202107031400_YnVzaW5lc3Mtem9uZTo6cHJvamVjdEE=.1_ZThjZjM0YTFkNTRhNDA1OGE4Yzk4NTA1ODc3NzcwZTJAMTkyLjE2OC41MC4xMTM=",
                "value": 22
              },
              {
                "id": "202107031401_YnVzaW5lc3Mtem9uZTo6cHJvamVjdEE=.1_ZThjZjM0YTFkNTRhNDA1OGE4Yzk4NTA1ODc3NzcwZTJAMTkyLjE2OC41MC4xMTM=",
                "value": 22
              }
            ]
          }
        }
      }
    }
    

    参考文档

  • 相关阅读:
    MD5 SHA1 CRC32
    tf 常用函数 28原则
    matplotlib 28原则
    markdown 基本语法
    tf 数据读取
    django 自定义身份认证
    代理部署
    社区发现算法问题&&NetworkX&&Gephi
    机器学习中的数学——拉格朗日乘子法
    过拟合(Overfitting)和正规化(Regularization)
  • 原文地址:https://www.cnblogs.com/switchvov/p/15375438.html
Copyright © 2020-2023  润新知