From 48f0f22de697d5e37307ab34ed6b57c09d1c6df4 Mon Sep 17 00:00:00 2001 From: wu-sheng Date: Mon, 25 Dec 2017 15:33:12 +0800 Subject: [PATCH 01/15] Init ui-protocol. --- apm-protocol/{apm-ui-query => apm-ui-protocol}/pom.xml | 0 .../src/main/resources/ui-graphql/alarm.graphqls | 0 .../src/main/resources/ui-graphql/application-layer.graphqls | 0 .../src/main/resources/ui-graphql/common.graphqls | 0 .../src/main/resources/ui-graphql/overview-layer.graphqls | 0 .../src/main/resources/ui-graphql/server-layer.graphqls | 0 .../src/main/resources/ui-graphql/service-layer.graphqls | 0 .../src/main/resources/ui-graphql/trace.graphqls | 0 apm-protocol/pom.xml | 2 +- 9 files changed, 1 insertion(+), 1 deletion(-) rename apm-protocol/{apm-ui-query => apm-ui-protocol}/pom.xml (100%) create mode 100644 apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/alarm.graphqls create mode 100644 apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/application-layer.graphqls create mode 100644 apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/common.graphqls create mode 100644 apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/overview-layer.graphqls create mode 100644 apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/server-layer.graphqls create mode 100644 apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/service-layer.graphqls create mode 100644 apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/trace.graphqls diff --git a/apm-protocol/apm-ui-query/pom.xml b/apm-protocol/apm-ui-protocol/pom.xml similarity index 100% rename from apm-protocol/apm-ui-query/pom.xml rename to apm-protocol/apm-ui-protocol/pom.xml diff --git a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/alarm.graphqls b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/alarm.graphqls new file mode 100644 index 000000000..e69de29bb diff --git a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/application-layer.graphqls b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/application-layer.graphqls new file mode 100644 index 000000000..e69de29bb diff --git a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/common.graphqls b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/common.graphqls new file mode 100644 index 000000000..e69de29bb diff --git a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/overview-layer.graphqls b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/overview-layer.graphqls new file mode 100644 index 000000000..e69de29bb diff --git a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/server-layer.graphqls b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/server-layer.graphqls new file mode 100644 index 000000000..e69de29bb diff --git a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/service-layer.graphqls b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/service-layer.graphqls new file mode 100644 index 000000000..e69de29bb diff --git a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/trace.graphqls b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/trace.graphqls new file mode 100644 index 000000000..e69de29bb diff --git a/apm-protocol/pom.xml b/apm-protocol/pom.xml index cc8684970..fa5708532 100644 --- a/apm-protocol/pom.xml +++ b/apm-protocol/pom.xml @@ -32,6 +32,6 @@ apm-network - apm-ui-query + apm-ui-protocol \ No newline at end of file From 91922544d429ca6fd727d6f45fbcb0a92d29d007 Mon Sep 17 00:00:00 2001 From: wusheng Date: Mon, 25 Dec 2017 22:04:17 +0800 Subject: [PATCH 02/15] Fix a module name. --- apm-protocol/apm-ui-protocol/pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apm-protocol/apm-ui-protocol/pom.xml b/apm-protocol/apm-ui-protocol/pom.xml index f67c5c86e..9ad10c060 100644 --- a/apm-protocol/apm-ui-protocol/pom.xml +++ b/apm-protocol/apm-ui-protocol/pom.xml @@ -27,7 +27,7 @@ 4.0.0 - apm-ui-query + apm-ui-protocol - \ No newline at end of file + From 8ae1b4213b158c3ccab02673bf956e93fd8561db Mon Sep 17 00:00:00 2001 From: gaohongtao Date: Mon, 25 Dec 2017 22:28:00 +0800 Subject: [PATCH 03/15] Add application topology query type --- .../main/resources/ui-graphql/common.graphqls | 21 ++++++++++ .../ui-graphql/overview-layer.graphqls | 38 +++++++++++++++++++ 2 files changed, 59 insertions(+) diff --git a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/common.graphqls b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/common.graphqls index e69de29bb..910fdb7dc 100644 --- a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/common.graphqls +++ b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/common.graphqls @@ -0,0 +1,21 @@ +schema { + query: Query +} + +type Query { + version: String +} + +type Duration{ + start: String! # https://www.ietf.org/rfc/rfc3339.txt + end: String! + step: Step! +} + +enum Step{ + MONTH + DAY + HOUR + MINUTE + SECOND +} diff --git a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/overview-layer.graphqls b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/overview-layer.graphqls index e69de29bb..299561425 100644 --- a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/overview-layer.graphqls +++ b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/overview-layer.graphqls @@ -0,0 +1,38 @@ +type ApplicationTopology { + nodes: [Node]! + edges: [Edge] + duration: Duration! +} + +interface Node { + id: ID! + name: String! + type: String +} + +type ApplicationNode implements Node { + id: ID! + name: String! + type: String + sla: Float! + calls: Long! + apdex: Float! + totalInstance: Int! + totalAlert: Int! +} + +type ResourceNode implements Node { + id: ID! + name: String! + type: String +} + +type Edge { + source: ID! + target: ID! + isAlert: Boolean +} + +extend type Query { + getApplicationTopology: ApplicationTopology +} From d07a91353cf86e4a702cb59d77b8d2ca430c44d3 Mon Sep 17 00:00:00 2001 From: wu-sheng Date: Tue, 26 Dec 2017 10:50:05 +0800 Subject: [PATCH 04/15] Adjust the services and add comments. --- .../main/resources/ui-graphql/common.graphqls | 20 +++++++++- .../ui-graphql/overview-layer.graphqls | 40 ++++++++++++++++--- 2 files changed, 54 insertions(+), 6 deletions(-) diff --git a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/common.graphqls b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/common.graphqls index 910fdb7dc..91d6ba352 100644 --- a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/common.graphqls +++ b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/common.graphqls @@ -6,8 +6,26 @@ type Query { version: String } +# The Duration defines the start and end time for each query operation. +# Fields: `start` and `end` +# represents the time span. And each of them matches the step. +# ref https://www.ietf.org/rfc/rfc3339.txt +# The time formats are +# `SECOND` step: yyyy-MM-dd HHmmss +# `MINUTE` step: yyyy-MM-dd HHmm +# `HOUR` step: yyyy-MM-dd HH +# `DAY` step: yyyy-MM-dd +# `MONTH` step: yyyy-MM +# Field: `step` +# represents the accurate time point. +# e.g. +# if step==HOUR , start=2017-11-08 09, end=2017-11-08 19 +# then +# metrics from the following time points expected +# 2017-11-08 9:00 -> 2017-11-08 19:00 +# there are 11 time points (hours) in the time span. type Duration{ - start: String! # https://www.ietf.org/rfc/rfc3339.txt + start: String! end: String! step: Step! } diff --git a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/overview-layer.graphqls b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/overview-layer.graphqls index 299561425..437e10466 100644 --- a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/overview-layer.graphqls +++ b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/overview-layer.graphqls @@ -1,36 +1,66 @@ +# The overview topology of the whole application cluster, +# which includes all applications and dependencies, e.g. MQ, Database, Cache, outside Web Service type ApplicationTopology { nodes: [Node]! - edges: [Edge] + calls: [Call] duration: Duration! } +# The base Node of all node types in topology interface Node { + # The global id of each node, + # 1. `Application ID` represents application under monitoring + # 2. `Peer ID` string represents the conjectural dependency. id: ID! + # Application Code or literal Peer name: String! + # The type name + # 1. The most important component in the application, from service provider perspective. + # 2. Conjectural dependent component, e.g. MySQL, Redis, Kafka type: String } +# ApplicationNode represents this node is under monitoring by agent. type ApplicationNode implements Node { id: ID! name: String! type: String + # Success rate of all incoming requests. + # Max value is 100. + # 2 Digits after floating point. sla: Float! + # The number of incoming calls calls: Long! + # ref: http://www.apdex.org/ + # Max value is 1 + # 2 Digits after floating point. apdex: Float! - totalInstance: Int! - totalAlert: Int! + # The number of servers in the application code + numOfServer: Int! + # The number of servers alerting + numOfServerAlarm: Int! + # The number of services alerting + numOfServiceAlarm: Int! } -type ResourceNode implements Node { +# The conjectural node generated by exit span +type ConjecturalNode implements Node { id: ID! name: String! type: String } -type Edge { +# The Call represents a directed distributed call, +# from the `source` to the `target`. +type Call { source: ID! target: ID! isAlert: Boolean + # The protocol and tech stack used in this distributed call + callType: String! + callsPerSec: Int! + # Unit: millisecond + responseTimePerSec: Int! } extend type Query { From 131bbb965f269f90a012ac823d24924f7b4ac9d6 Mon Sep 17 00:00:00 2001 From: wu-sheng Date: Tue, 26 Dec 2017 11:47:55 +0800 Subject: [PATCH 05/15] Add two services. --- .../ui-graphql/overview-layer.graphqls | 34 +++++++++++++++++++ .../main/resources/ui-graphql/trace.graphqls | 16 +++++++++ 2 files changed, 50 insertions(+) diff --git a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/overview-layer.graphqls b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/overview-layer.graphqls index 437e10466..6b55b323a 100644 --- a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/overview-layer.graphqls +++ b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/overview-layer.graphqls @@ -63,6 +63,40 @@ type Call { responseTimePerSec: Int! } +# Query the cluster brief based on the given duration +type ClusterBrief { + numOfApplication: Int + numOfService: Int + numOfDatabase: Int + numOfCache: Int + numOfMQ: Int + duration: Duration! +} + +# Query the trend of alarm rate based on the given duration +type AlarmTrend { + numOfAlarmRate: [Int]! + duration: Duration! +} + +# Query all conjectural applications based on the given duration +# All applications here are not installed agent. +type ConjecturalAppBrief { + apps: [ConjecturalApp!] + duration: Duration! +} + +# The basic info of the conjectural application, +# includes the type and num of same type application +type ConjecturalApp { + # The display name of the application + # e.g. MySQL, RocketMQ, Kafka, Nginx + name: String! + num: int! +} + extend type Query { getApplicationTopology: ApplicationTopology + getClusterBrief: ClusterBrief + getAlarmTrend: AlarmTrend } diff --git a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/trace.graphqls b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/trace.graphqls index e69de29bb..950560646 100644 --- a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/trace.graphqls +++ b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/trace.graphqls @@ -0,0 +1,16 @@ +type TraceBrief { + traces: [BasicTrace!] + duration: Duration! + +} + +type BasicTrace { + operationName: String! + duration: Int! + start: String! +} + + +extend type Query { + queryBasicTraces: TraceBrief +} \ No newline at end of file From 4545e431f040939b244e95bf11f4a45017647783 Mon Sep 17 00:00:00 2001 From: wu-sheng Date: Tue, 26 Dec 2017 15:28:34 +0800 Subject: [PATCH 06/15] Add query arguments. --- .../ui-graphql/overview-layer.graphqls | 11 +++----- .../main/resources/ui-graphql/trace.graphqls | 27 ++++++++++++++++--- 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/overview-layer.graphqls b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/overview-layer.graphqls index 6b55b323a..8179ce5ad 100644 --- a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/overview-layer.graphqls +++ b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/overview-layer.graphqls @@ -3,7 +3,6 @@ type ApplicationTopology { nodes: [Node]! calls: [Call] - duration: Duration! } # The base Node of all node types in topology @@ -70,20 +69,17 @@ type ClusterBrief { numOfDatabase: Int numOfCache: Int numOfMQ: Int - duration: Duration! } # Query the trend of alarm rate based on the given duration type AlarmTrend { numOfAlarmRate: [Int]! - duration: Duration! } # Query all conjectural applications based on the given duration # All applications here are not installed agent. type ConjecturalAppBrief { apps: [ConjecturalApp!] - duration: Duration! } # The basic info of the conjectural application, @@ -96,7 +92,8 @@ type ConjecturalApp { } extend type Query { - getApplicationTopology: ApplicationTopology - getClusterBrief: ClusterBrief - getAlarmTrend: AlarmTrend + getApplicationTopology(duration: Duration!): ApplicationTopology + getClusterBrief(duration: Duration!): ClusterBrief + getAlarmTrend(duration: Duration!): AlarmTrend + getConjecturalApps(duration: Duration!): ConjecturalAppBrief } diff --git a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/trace.graphqls b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/trace.graphqls index 950560646..75b8b2003 100644 --- a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/trace.graphqls +++ b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/trace.graphqls @@ -1,16 +1,37 @@ +# The list of traces type TraceBrief { traces: [BasicTrace!] - duration: Duration! - } +# Trace basic info type BasicTrace { operationName: String! duration: Int! start: String! + isError: Boolean + traceId: String } +# Represent the conditions used for query TraceBrief +type TraceQueryCondition { + applicationCodes: [String!] + traceId: String + operationName: String + # The time range of traces started + queryDuration: Duration + # The mix time of trace + minTraceDuration: Int + # The max time of trace + maxTraceDuration: Int + topN: Boolean + needTotal: Int +} + +enum QueryOrder { + BY_START_TIME + BY_DURATION +} extend type Query { - queryBasicTraces: TraceBrief + queryBasicTraces(condition: TraceQueryCondition): TraceBrief } \ No newline at end of file From 0af4f1737ab8280487e14384f84c6bab1b5e0f0d Mon Sep 17 00:00:00 2001 From: wu-sheng Date: Tue, 26 Dec 2017 16:13:32 +0800 Subject: [PATCH 07/15] Add the missing getApplicationBrief query. --- .../main/resources/ui-graphql/overview-layer.graphqls | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/overview-layer.graphqls b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/overview-layer.graphqls index 8179ce5ad..1dbc1455b 100644 --- a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/overview-layer.graphqls +++ b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/overview-layer.graphqls @@ -91,9 +91,19 @@ type ConjecturalApp { num: int! } +type ApplicationBrief { + apps: [ApplicationInfo!] +} + +type ApplicationInfo { + name: String! + tps: int! +} + extend type Query { getApplicationTopology(duration: Duration!): ApplicationTopology getClusterBrief(duration: Duration!): ClusterBrief getAlarmTrend(duration: Duration!): AlarmTrend getConjecturalApps(duration: Duration!): ConjecturalAppBrief + getApplicationBrief(duration: Duration!, topN: Int!): ApplicationBrief } From 84caf87f36835a325b0b405b216e2fb908f9bc14 Mon Sep 17 00:00:00 2001 From: gaohongtao Date: Tue, 26 Dec 2017 22:46:04 +0800 Subject: [PATCH 08/15] Add graphiql servlet --- apm-protocol/apm-ui-protocol/README.md | 6 ++ apm-protocol/apm-ui-protocol/pom.xml | 33 ++++++++ .../apm/ui/protocol/GraphQLInitializer.java | 75 +++++++++++++++++++ .../src/main/resources/application.yml | 20 +++++ .../main/resources/ui-graphql/common.graphqls | 3 +- .../ui-graphql/overview-layer.graphqls | 4 +- .../main/resources/ui-graphql/trace.graphqls | 2 +- 7 files changed, 139 insertions(+), 4 deletions(-) create mode 100644 apm-protocol/apm-ui-protocol/README.md create mode 100644 apm-protocol/apm-ui-protocol/src/main/java/org/apache/skywalking/apm/ui/protocol/GraphQLInitializer.java create mode 100644 apm-protocol/apm-ui-protocol/src/main/resources/application.yml diff --git a/apm-protocol/apm-ui-protocol/README.md b/apm-protocol/apm-ui-protocol/README.md new file mode 100644 index 000000000..f58f1ea6d --- /dev/null +++ b/apm-protocol/apm-ui-protocol/README.md @@ -0,0 +1,6 @@ +## Using graphiql + +Graphiql */ˈɡrafək(ə)l/* is interactive in-browser GraphQL IDE which can be used by following steps. + + 1. Run `org.apache.skywalking.apm.ui.protocol.GraphQLInitializer#main` + 1. Access [http://localhost:8080/graphiql](http://localhost:8080/graphiql) diff --git a/apm-protocol/apm-ui-protocol/pom.xml b/apm-protocol/apm-ui-protocol/pom.xml index 9ad10c060..ab829decd 100644 --- a/apm-protocol/apm-ui-protocol/pom.xml +++ b/apm-protocol/apm-ui-protocol/pom.xml @@ -29,5 +29,38 @@ apm-ui-protocol + + + org.springframework.boot + spring-boot-starter-web + 1.5.9.RELEASE + + + org.springframework.boot + spring-boot-starter-actuator + 1.5.9.RELEASE + + + org.springframework.boot + spring-boot-configuration-processor + 1.5.9.RELEASE + + + org.springframework.boot + spring-boot-devtools + 1.5.9.RELEASE + + + + com.graphql-java + graphql-spring-boot-starter + 3.9.2 + + + com.graphql-java + graphiql-spring-boot-starter + 3.9.2 + + diff --git a/apm-protocol/apm-ui-protocol/src/main/java/org/apache/skywalking/apm/ui/protocol/GraphQLInitializer.java b/apm-protocol/apm-ui-protocol/src/main/java/org/apache/skywalking/apm/ui/protocol/GraphQLInitializer.java new file mode 100644 index 000000000..934c06786 --- /dev/null +++ b/apm-protocol/apm-ui-protocol/src/main/java/org/apache/skywalking/apm/ui/protocol/GraphQLInitializer.java @@ -0,0 +1,75 @@ +package org.apache.skywalking.apm.ui.protocol; + +import graphql.schema.GraphQLObjectType; +import graphql.schema.GraphQLSchema; +import graphql.schema.TypeResolver; +import graphql.schema.idl.FieldWiringEnvironment; +import graphql.schema.idl.InterfaceWiringEnvironment; +import graphql.schema.idl.RuntimeWiring; +import graphql.schema.idl.SchemaGenerator; +import graphql.schema.idl.SchemaParser; +import graphql.schema.idl.TypeDefinitionRegistry; +import graphql.schema.idl.WiringFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.web.support.SpringBootServletInitializer; +import org.springframework.context.ApplicationContext; +import org.springframework.context.annotation.Bean; + +import java.io.File; + +/** + * GraphQL server initializer. + * + * @author gaohongtao + */ +@SpringBootApplication +public class GraphQLInitializer extends SpringBootServletInitializer { + + private Logger logger = LoggerFactory.getLogger(GraphQLInitializer.class); + + public static void main(String[] args) throws Exception { + ApplicationContext applicationContext = SpringApplication.run(GraphQLInitializer.class, args); + } + + @Bean + GraphQLSchema schema() { + SchemaParser schemaParser = new SchemaParser(); + SchemaGenerator schemaGenerator = new SchemaGenerator(); + + TypeDefinitionRegistry typeRegistry = new TypeDefinitionRegistry(); + typeRegistry.merge(schemaParser.parse(loadSchema("common.graphqls"))); + typeRegistry.merge(schemaParser.parse(loadSchema("trace.graphqls"))); + typeRegistry.merge(schemaParser.parse(loadSchema("overview-layer.graphqls"))); + RuntimeWiring wiring = buildRuntimeWiring(); + return schemaGenerator.makeExecutableSchema(typeRegistry, wiring); + } + + private File loadSchema(final String s) { + return new File(GraphQLInitializer.class.getClassLoader().getResource("ui-graphql/" + s).getFile()); + } + + private RuntimeWiring buildRuntimeWiring() { + WiringFactory dynamicWiringFactory = new WiringFactory() { + @Override + public boolean providesTypeResolver(final InterfaceWiringEnvironment environment) { + return true; + } + + @Override + public TypeResolver getTypeResolver(final InterfaceWiringEnvironment environment) { + return env -> GraphQLObjectType.newObject().build(); + } + + @Override + public boolean providesDataFetcher(final FieldWiringEnvironment environment) { + logger.info("data fetcher: {},{}", environment.getFieldDefinition(), environment.getParentType()); + return false; + } + }; + return RuntimeWiring.newRuntimeWiring() + .wiringFactory(dynamicWiringFactory).build(); + } +} diff --git a/apm-protocol/apm-ui-protocol/src/main/resources/application.yml b/apm-protocol/apm-ui-protocol/src/main/resources/application.yml new file mode 100644 index 000000000..0dddee92e --- /dev/null +++ b/apm-protocol/apm-ui-protocol/src/main/resources/application.yml @@ -0,0 +1,20 @@ +# +# Copyright 2017, OpenSkywalking Organization All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Project repository: https://github.com/OpenSkywalking/skywalking-ui +# + +server: + port: 8080 diff --git a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/common.graphqls b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/common.graphqls index 91d6ba352..7473866b3 100644 --- a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/common.graphqls +++ b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/common.graphqls @@ -2,6 +2,7 @@ schema { query: Query } +#Root node type Query { version: String } @@ -24,7 +25,7 @@ type Query { # metrics from the following time points expected # 2017-11-08 9:00 -> 2017-11-08 19:00 # there are 11 time points (hours) in the time span. -type Duration{ +input Duration{ start: String! end: String! step: Step! diff --git a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/overview-layer.graphqls b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/overview-layer.graphqls index 1dbc1455b..c101963ff 100644 --- a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/overview-layer.graphqls +++ b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/overview-layer.graphqls @@ -88,7 +88,7 @@ type ConjecturalApp { # The display name of the application # e.g. MySQL, RocketMQ, Kafka, Nginx name: String! - num: int! + num: Int! } type ApplicationBrief { @@ -97,7 +97,7 @@ type ApplicationBrief { type ApplicationInfo { name: String! - tps: int! + tps: Int! } extend type Query { diff --git a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/trace.graphqls b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/trace.graphqls index 75b8b2003..822f7ce8f 100644 --- a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/trace.graphqls +++ b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/trace.graphqls @@ -13,7 +13,7 @@ type BasicTrace { } # Represent the conditions used for query TraceBrief -type TraceQueryCondition { +input TraceQueryCondition { applicationCodes: [String!] traceId: String operationName: String From e771350812e772c464d18db1c1fdf89e795b908c Mon Sep 17 00:00:00 2001 From: gaohongtao Date: Wed, 27 Dec 2017 08:49:14 +0800 Subject: [PATCH 09/15] Remove spring dependency --- apm-protocol/apm-ui-protocol/README.md | 6 -- apm-protocol/apm-ui-protocol/pom.xml | 31 +------- .../apm/ui/protocol/GraphQLInitializer.java | 75 ------------------- .../apm/ui/protocol/GraphQLScriptTest.java | 54 +++++++++++++ 4 files changed, 56 insertions(+), 110 deletions(-) delete mode 100644 apm-protocol/apm-ui-protocol/README.md delete mode 100644 apm-protocol/apm-ui-protocol/src/main/java/org/apache/skywalking/apm/ui/protocol/GraphQLInitializer.java create mode 100644 apm-protocol/apm-ui-protocol/src/test/java/org/apache/skywalking/apm/ui/protocol/GraphQLScriptTest.java diff --git a/apm-protocol/apm-ui-protocol/README.md b/apm-protocol/apm-ui-protocol/README.md deleted file mode 100644 index f58f1ea6d..000000000 --- a/apm-protocol/apm-ui-protocol/README.md +++ /dev/null @@ -1,6 +0,0 @@ -## Using graphiql - -Graphiql */ˈɡrafək(ə)l/* is interactive in-browser GraphQL IDE which can be used by following steps. - - 1. Run `org.apache.skywalking.apm.ui.protocol.GraphQLInitializer#main` - 1. Access [http://localhost:8080/graphiql](http://localhost:8080/graphiql) diff --git a/apm-protocol/apm-ui-protocol/pom.xml b/apm-protocol/apm-ui-protocol/pom.xml index ab829decd..0e7e75784 100644 --- a/apm-protocol/apm-ui-protocol/pom.xml +++ b/apm-protocol/apm-ui-protocol/pom.xml @@ -30,37 +30,10 @@ apm-ui-protocol - - org.springframework.boot - spring-boot-starter-web - 1.5.9.RELEASE - - - org.springframework.boot - spring-boot-starter-actuator - 1.5.9.RELEASE - - - org.springframework.boot - spring-boot-configuration-processor - 1.5.9.RELEASE - - - org.springframework.boot - spring-boot-devtools - 1.5.9.RELEASE - - - com.graphql-java - graphql-spring-boot-starter - 3.9.2 - - - com.graphql-java - graphiql-spring-boot-starter - 3.9.2 + graphql-java + 6.0 diff --git a/apm-protocol/apm-ui-protocol/src/main/java/org/apache/skywalking/apm/ui/protocol/GraphQLInitializer.java b/apm-protocol/apm-ui-protocol/src/main/java/org/apache/skywalking/apm/ui/protocol/GraphQLInitializer.java deleted file mode 100644 index 934c06786..000000000 --- a/apm-protocol/apm-ui-protocol/src/main/java/org/apache/skywalking/apm/ui/protocol/GraphQLInitializer.java +++ /dev/null @@ -1,75 +0,0 @@ -package org.apache.skywalking.apm.ui.protocol; - -import graphql.schema.GraphQLObjectType; -import graphql.schema.GraphQLSchema; -import graphql.schema.TypeResolver; -import graphql.schema.idl.FieldWiringEnvironment; -import graphql.schema.idl.InterfaceWiringEnvironment; -import graphql.schema.idl.RuntimeWiring; -import graphql.schema.idl.SchemaGenerator; -import graphql.schema.idl.SchemaParser; -import graphql.schema.idl.TypeDefinitionRegistry; -import graphql.schema.idl.WiringFactory; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.web.support.SpringBootServletInitializer; -import org.springframework.context.ApplicationContext; -import org.springframework.context.annotation.Bean; - -import java.io.File; - -/** - * GraphQL server initializer. - * - * @author gaohongtao - */ -@SpringBootApplication -public class GraphQLInitializer extends SpringBootServletInitializer { - - private Logger logger = LoggerFactory.getLogger(GraphQLInitializer.class); - - public static void main(String[] args) throws Exception { - ApplicationContext applicationContext = SpringApplication.run(GraphQLInitializer.class, args); - } - - @Bean - GraphQLSchema schema() { - SchemaParser schemaParser = new SchemaParser(); - SchemaGenerator schemaGenerator = new SchemaGenerator(); - - TypeDefinitionRegistry typeRegistry = new TypeDefinitionRegistry(); - typeRegistry.merge(schemaParser.parse(loadSchema("common.graphqls"))); - typeRegistry.merge(schemaParser.parse(loadSchema("trace.graphqls"))); - typeRegistry.merge(schemaParser.parse(loadSchema("overview-layer.graphqls"))); - RuntimeWiring wiring = buildRuntimeWiring(); - return schemaGenerator.makeExecutableSchema(typeRegistry, wiring); - } - - private File loadSchema(final String s) { - return new File(GraphQLInitializer.class.getClassLoader().getResource("ui-graphql/" + s).getFile()); - } - - private RuntimeWiring buildRuntimeWiring() { - WiringFactory dynamicWiringFactory = new WiringFactory() { - @Override - public boolean providesTypeResolver(final InterfaceWiringEnvironment environment) { - return true; - } - - @Override - public TypeResolver getTypeResolver(final InterfaceWiringEnvironment environment) { - return env -> GraphQLObjectType.newObject().build(); - } - - @Override - public boolean providesDataFetcher(final FieldWiringEnvironment environment) { - logger.info("data fetcher: {},{}", environment.getFieldDefinition(), environment.getParentType()); - return false; - } - }; - return RuntimeWiring.newRuntimeWiring() - .wiringFactory(dynamicWiringFactory).build(); - } -} diff --git a/apm-protocol/apm-ui-protocol/src/test/java/org/apache/skywalking/apm/ui/protocol/GraphQLScriptTest.java b/apm-protocol/apm-ui-protocol/src/test/java/org/apache/skywalking/apm/ui/protocol/GraphQLScriptTest.java new file mode 100644 index 000000000..795a01b92 --- /dev/null +++ b/apm-protocol/apm-ui-protocol/src/test/java/org/apache/skywalking/apm/ui/protocol/GraphQLScriptTest.java @@ -0,0 +1,54 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.apm.ui.protocol; + +import graphql.schema.idl.EchoingWiringFactory; +import graphql.schema.idl.RuntimeWiring; +import graphql.schema.idl.SchemaGenerator; +import graphql.schema.idl.SchemaParser; +import graphql.schema.idl.TypeDefinitionRegistry; +import java.io.File; +import org.junit.Test; + +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; + +public class GraphQLScriptTest { + + @Test + public void assertScriptFormat() { + SchemaParser schemaParser = new SchemaParser(); + SchemaGenerator schemaGenerator = new SchemaGenerator(); + + TypeDefinitionRegistry typeRegistry = new TypeDefinitionRegistry(); + typeRegistry.merge(schemaParser.parse(loadSchema("common.graphqls"))); + typeRegistry.merge(schemaParser.parse(loadSchema("trace.graphqls"))); + typeRegistry.merge(schemaParser.parse(loadSchema("overview-layer.graphqls"))); + RuntimeWiring wiring = buildRuntimeWiring(); + assertThat(schemaGenerator.makeExecutableSchema(typeRegistry, wiring).getAllTypesAsList().size(), is(32)); + } + + private File loadSchema(final String s) { + return new File(GraphQLScriptTest.class.getClassLoader().getResource("ui-graphql/" + s).getFile()); + } + + private RuntimeWiring buildRuntimeWiring() { + return RuntimeWiring.newRuntimeWiring().wiringFactory(new EchoingWiringFactory()).build(); + } +} From 5d801fbd02a69aae17b4abec657ae38723cfa024 Mon Sep 17 00:00:00 2001 From: wu-sheng Date: Wed, 27 Dec 2017 09:59:40 +0800 Subject: [PATCH 10/15] Add application layer protocol and some common types. --- .../src/main/resources/application.yml | 20 ------------------- .../ui-graphql/application-layer.graphqls | 8 ++++++++ .../main/resources/ui-graphql/common.graphqls | 15 ++++++++++++++ .../ui-graphql/overview-layer.graphqls | 3 ++- .../ui-graphql/server-layer.graphqls | 19 ++++++++++++++++++ 5 files changed, 44 insertions(+), 21 deletions(-) delete mode 100644 apm-protocol/apm-ui-protocol/src/main/resources/application.yml diff --git a/apm-protocol/apm-ui-protocol/src/main/resources/application.yml b/apm-protocol/apm-ui-protocol/src/main/resources/application.yml deleted file mode 100644 index 0dddee92e..000000000 --- a/apm-protocol/apm-ui-protocol/src/main/resources/application.yml +++ /dev/null @@ -1,20 +0,0 @@ -# -# Copyright 2017, OpenSkywalking Organization All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Project repository: https://github.com/OpenSkywalking/skywalking-ui -# - -server: - port: 8080 diff --git a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/application-layer.graphqls b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/application-layer.graphqls index e69de29bb..4889edf3f 100644 --- a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/application-layer.graphqls +++ b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/application-layer.graphqls @@ -0,0 +1,8 @@ +type AppServerList { + servers: [AppServerInfo!] +} + +extend type Query { + getApplicationTopology(appId: ID!, duration: Duration!): ApplicationTopology + getServers(appId: ID!, duration: Duration!): AppServerList +} \ No newline at end of file diff --git a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/common.graphqls b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/common.graphqls index 7473866b3..679379c0f 100644 --- a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/common.graphqls +++ b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/common.graphqls @@ -38,3 +38,18 @@ enum Step{ MINUTE SECOND } + +###################################### +# Common Metrics and Trends +###################################### +type ResponseTimeTrend { + trendList: [Int!] +} + +type TPSTrend { + trendList: [Int!] +} + +type ThroughputTrend { + trendList: [Int!] +} \ No newline at end of file diff --git a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/overview-layer.graphqls b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/overview-layer.graphqls index c101963ff..e06e9445a 100644 --- a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/overview-layer.graphqls +++ b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/overview-layer.graphqls @@ -96,12 +96,13 @@ type ApplicationBrief { } type ApplicationInfo { + id: ID! name: String! tps: Int! } extend type Query { - getApplicationTopology(duration: Duration!): ApplicationTopology + getClusterTopology(duration: Duration!): ApplicationTopology getClusterBrief(duration: Duration!): ClusterBrief getAlarmTrend(duration: Duration!): AlarmTrend getConjecturalApps(duration: Duration!): ConjecturalAppBrief diff --git a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/server-layer.graphqls b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/server-layer.graphqls index e69de29bb..3335dcd66 100644 --- a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/server-layer.graphqls +++ b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/server-layer.graphqls @@ -0,0 +1,19 @@ +# The server info. +# At here, `Server` represents a process in OS, +# e.g. +# 1. Spring boot application +# 2. A Tomcat server instance +type AppServerInfo { + id: ID! + name: String! + tps: Int! + os: String + host: String + pid: Int + IPv4: String + IPv6: String +} + +extend type Query { + +} \ No newline at end of file From d3ab94bee31c88a84b0dab8a3386f50dd0c11a6a Mon Sep 17 00:00:00 2001 From: wu-sheng Date: Wed, 27 Dec 2017 11:05:42 +0800 Subject: [PATCH 11/15] Add server query. --- .../ui-graphql/server-layer.graphqls | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/server-layer.graphqls b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/server-layer.graphqls index 3335dcd66..cd86957f0 100644 --- a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/server-layer.graphqls +++ b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/server-layer.graphqls @@ -14,6 +14,29 @@ type AppServerInfo { IPv6: String } +type CPUTrend { + cost: [Int!] +} + +# The gc trend represents the numbers of Garbage Collector execution +type GCTrend { + youngGC: [Int!] + oldGC: [Int!] +} + +# The memory used and max limit in heap and noheap space. +type MemoryTrend { + heap: [int!] + maxHeap: [int!] + noheap: [int!] + maxNoheap: [int!] +} + + extend type Query { - + getServerResponseTimeTrend(serverId: ID!, duration: Duration!): ResponseTimeTrend + getServerTPSTrend(serverId: ID!, duration: Duration!): TPSTrend + getCPUTrend(serverId: ID!, duration: Duration!): CPUTrend + getGCTrend(serverId: ID!, duration: Duration!): GCTrend + getMemoryTrend(serverId: ID!, duration: Duration!): MemoryTrend } \ No newline at end of file From 6d96cf6bf2cbb608a7cd358a73bb6cc4591134b8 Mon Sep 17 00:00:00 2001 From: gaohongtao Date: Wed, 27 Dec 2017 12:41:28 +0800 Subject: [PATCH 12/15] Finish all protocol --- .../main/resources/ui-graphql/alarm.graphqls | 15 +++ .../ui-graphql/application-layer.graphqls | 37 +++++- .../main/resources/ui-graphql/common.graphqls | 81 ++++++++++--- .../ui-graphql/overview-layer.graphqls | 107 +++--------------- .../ui-graphql/server-layer.graphqls | 42 +++---- .../ui-graphql/service-layer.graphqls | 28 +++++ .../apm/ui/protocol/GraphQLScriptTest.java | 9 +- 7 files changed, 183 insertions(+), 136 deletions(-) diff --git a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/alarm.graphqls b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/alarm.graphqls index e69de29bb..b63946d8b 100644 --- a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/alarm.graphqls +++ b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/alarm.graphqls @@ -0,0 +1,15 @@ +type AlarmItem { + content: String! + startTime: String! + alertType: AlarmType! +} + +enum AlarmType { + APPLICATION, + SERVER, + SERVICE +} + +extend type Query { + loadAlertList(keyword: String, alertType: AlarmType, duration:Duration!):[AlarmItem] +} \ No newline at end of file diff --git a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/application-layer.graphqls b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/application-layer.graphqls index 4889edf3f..572b038ea 100644 --- a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/application-layer.graphqls +++ b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/application-layer.graphqls @@ -1,8 +1,37 @@ -type AppServerList { - servers: [AppServerInfo!] +# ApplicationNode represents this node is under monitoring by agent. +type ApplicationNode implements Node { + id: ID! + name: String! + type: String + # Success rate of all incoming requests. + # Max value is 100. + # 2 Digits after floating point. + sla: Float! + # The number of incoming calls + calls: Long! + # ref: http://www.apdex.org/ + # Max value is 1 + # 2 Digits after floating point. + apdex: Float! + # The number of servers in the application code + numOfServer: Int! + # The number of servers alerting + numOfServerAlarm: Int! + # The number of services alerting + numOfServiceAlarm: Int! } +# The conjectural node generated by exit span +type ConjecturalNode implements Node { + id: ID! + name: String! + type: String +} + + extend type Query { - getApplicationTopology(appId: ID!, duration: Duration!): ApplicationTopology - getServers(appId: ID!, duration: Duration!): AppServerList + getAllApplication(duration: Duration!): [ApplicationNode] + getApplicationTopology(appId: ID!, duration: Duration!): Topology + getSlowService(appId: ID!, duration: Duration!): [DurationItem] + getServerThroughput(appId: ID!, duration: Duration!): [ThroughputItem] } \ No newline at end of file diff --git a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/common.graphqls b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/common.graphqls index 679379c0f..0520b4b20 100644 --- a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/common.graphqls +++ b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/common.graphqls @@ -1,10 +1,10 @@ schema { - query: Query + query: Query } #Root node type Query { - version: String + version: String } # The Duration defines the start and end time for each query operation. @@ -25,31 +25,76 @@ type Query { # metrics from the following time points expected # 2017-11-08 9:00 -> 2017-11-08 19:00 # there are 11 time points (hours) in the time span. -input Duration{ - start: String! - end: String! - step: Step! +input Duration { + start: String! + end: String! + step: Step! } -enum Step{ - MONTH - DAY - HOUR - MINUTE - SECOND +enum Step { + MONTH + DAY + HOUR + MINUTE + SECOND } ###################################### # Common Metrics and Trends ###################################### type ResponseTimeTrend { - trendList: [Int!] -} - -type TPSTrend { - trendList: [Int!] + trendList: [Int!] } type ThroughputTrend { - trendList: [Int!] + trendList: [Int!] +} + +type SLATrend { + trendList: [Int!] +} + +# The overview topology of the whole application cluster or services, +type Topology { + nodes: [Node]! + calls: [Call] +} + +# The base Node of all node types in topology +interface Node { + # The global id of each node, + # 1. `Application ID` represents application under monitoring + # 2. `Peer ID` string represents the conjectural dependency. + id: ID! + # Application Code or literal Peer + name: String! + # The type name + # 1. The most important component in the application, from service provider perspective. + # 2. Conjectural dependent component, e.g. MySQL, Redis, Kafka + type: String +} + +# The Call represents a directed distributed call, +# from the `source` to the `target`. +type Call { + source: ID! + target: ID! + isAlert: Boolean + # The protocol and tech stack used in this distributed call + callType: String! + callsPerSec: Int! + # Unit: millisecond + responseTimePerSec: Int! +} + +# The item of slow service list +type DurationItem { + name: String! + duration: Int! +} + +# The item of throughput list +type ThroughputItem { + name: String! + tps: Int! } \ No newline at end of file diff --git a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/overview-layer.graphqls b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/overview-layer.graphqls index e06e9445a..aae527e31 100644 --- a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/overview-layer.graphqls +++ b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/overview-layer.graphqls @@ -1,110 +1,37 @@ -# The overview topology of the whole application cluster, -# which includes all applications and dependencies, e.g. MQ, Database, Cache, outside Web Service -type ApplicationTopology { - nodes: [Node]! - calls: [Call] -} - -# The base Node of all node types in topology -interface Node { - # The global id of each node, - # 1. `Application ID` represents application under monitoring - # 2. `Peer ID` string represents the conjectural dependency. - id: ID! - # Application Code or literal Peer - name: String! - # The type name - # 1. The most important component in the application, from service provider perspective. - # 2. Conjectural dependent component, e.g. MySQL, Redis, Kafka - type: String -} - -# ApplicationNode represents this node is under monitoring by agent. -type ApplicationNode implements Node { - id: ID! - name: String! - type: String - # Success rate of all incoming requests. - # Max value is 100. - # 2 Digits after floating point. - sla: Float! - # The number of incoming calls - calls: Long! - # ref: http://www.apdex.org/ - # Max value is 1 - # 2 Digits after floating point. - apdex: Float! - # The number of servers in the application code - numOfServer: Int! - # The number of servers alerting - numOfServerAlarm: Int! - # The number of services alerting - numOfServiceAlarm: Int! -} - -# The conjectural node generated by exit span -type ConjecturalNode implements Node { - id: ID! - name: String! - type: String -} - -# The Call represents a directed distributed call, -# from the `source` to the `target`. -type Call { - source: ID! - target: ID! - isAlert: Boolean - # The protocol and tech stack used in this distributed call - callType: String! - callsPerSec: Int! - # Unit: millisecond - responseTimePerSec: Int! -} - # Query the cluster brief based on the given duration type ClusterBrief { - numOfApplication: Int - numOfService: Int - numOfDatabase: Int - numOfCache: Int - numOfMQ: Int + numOfApplication: Int + numOfService: Int + numOfDatabase: Int + numOfCache: Int + numOfMQ: Int } # Query the trend of alarm rate based on the given duration type AlarmTrend { - numOfAlarmRate: [Int]! + numOfAlarmRate: [Int]! } # Query all conjectural applications based on the given duration # All applications here are not installed agent. type ConjecturalAppBrief { - apps: [ConjecturalApp!] + apps: [ConjecturalApp!] } # The basic info of the conjectural application, # includes the type and num of same type application type ConjecturalApp { - # The display name of the application - # e.g. MySQL, RocketMQ, Kafka, Nginx - name: String! - num: Int! -} - -type ApplicationBrief { - apps: [ApplicationInfo!] -} - -type ApplicationInfo { - id: ID! - name: String! - tps: Int! + # The display name of the application + # e.g. MySQL, RocketMQ, Kafka, Nginx + name: String! + num: Int! } extend type Query { - getClusterTopology(duration: Duration!): ApplicationTopology - getClusterBrief(duration: Duration!): ClusterBrief - getAlarmTrend(duration: Duration!): AlarmTrend - getConjecturalApps(duration: Duration!): ConjecturalAppBrief - getApplicationBrief(duration: Duration!, topN: Int!): ApplicationBrief + getClusterTopology(duration: Duration!): Topology + getClusterBrief(duration: Duration!): ClusterBrief + getAlarmTrend(duration: Duration!): AlarmTrend + getConjecturalApps(duration: Duration!): ConjecturalAppBrief + getTopNSlowService(duration: Duration!, topN: Int!): [DurationItem] + getTopNServerThroughput(duration: Duration!, topN: Int!): [ThroughputItem] } diff --git a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/server-layer.graphqls b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/server-layer.graphqls index cd86957f0..eac33a7dc 100644 --- a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/server-layer.graphqls +++ b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/server-layer.graphqls @@ -4,39 +4,39 @@ # 1. Spring boot application # 2. A Tomcat server instance type AppServerInfo { - id: ID! - name: String! - tps: Int! - os: String - host: String - pid: Int - IPv4: String - IPv6: String + id: ID! + name: String! + tps: Int! + os: String + host: String + pid: Int + IPv4: String + IPv6: String } type CPUTrend { - cost: [Int!] + cost: [Int!] } # The gc trend represents the numbers of Garbage Collector execution type GCTrend { - youngGC: [Int!] - oldGC: [Int!] + youngGC: [Int!] + oldGC: [Int!] } # The memory used and max limit in heap and noheap space. type MemoryTrend { - heap: [int!] - maxHeap: [int!] - noheap: [int!] - maxNoheap: [int!] + heap: [Int!] + maxHeap: [Int!] + noheap: [Int!] + maxNoheap: [Int!] } - extend type Query { - getServerResponseTimeTrend(serverId: ID!, duration: Duration!): ResponseTimeTrend - getServerTPSTrend(serverId: ID!, duration: Duration!): TPSTrend - getCPUTrend(serverId: ID!, duration: Duration!): CPUTrend - getGCTrend(serverId: ID!, duration: Duration!): GCTrend - getMemoryTrend(serverId: ID!, duration: Duration!): MemoryTrend + searchServer(keyword: String!, duration: Duration!): [AppServerInfo] + getServerResponseTimeTrend(serverId: ID!, duration: Duration!): ResponseTimeTrend + getServerTPSTrend(serverId: ID!, duration: Duration!): ThroughputTrend + getCPUTrend(serverId: ID!, duration: Duration!): CPUTrend + getGCTrend(serverId: ID!, duration: Duration!): GCTrend + getMemoryTrend(serverId: ID!, duration: Duration!): MemoryTrend } \ No newline at end of file diff --git a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/service-layer.graphqls b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/service-layer.graphqls index e69de29bb..2d7a90685 100644 --- a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/service-layer.graphqls +++ b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/service-layer.graphqls @@ -0,0 +1,28 @@ +type ServiceNode implements Node { + id: ID! + name: String! + type: String + # Success rate of all incoming requests. + # Max value is 100. + # 2 Digits after floating point. + sla: Float! + # The number of incoming calls + calls: Long! + # The number of services alerting + numOfServiceAlarm: Int! +} + +type TraceItem { + time: String! + entry: String! + duration: Int! +} + +extend type Query { + searchService(keyword: String!, duration: Duration!): [ServiceNode] + getServiceResponseTimeTrend(serviceId: ID!, duration: Duration!): ResponseTimeTrend + getServiceTPSTrend(serviceId: ID!, duration: Duration!): ThroughputTrend + getServiceSLATrend(serviceId: ID!, duration: Duration!): SLATrend + getServiceTopology(serviceId: ID!, duration: Duration!): Topology + getServiceSlowTrace(serviceId: ID!, duration: Duration!): [TraceItem] +} \ No newline at end of file diff --git a/apm-protocol/apm-ui-protocol/src/test/java/org/apache/skywalking/apm/ui/protocol/GraphQLScriptTest.java b/apm-protocol/apm-ui-protocol/src/test/java/org/apache/skywalking/apm/ui/protocol/GraphQLScriptTest.java index 795a01b92..f017d6844 100644 --- a/apm-protocol/apm-ui-protocol/src/test/java/org/apache/skywalking/apm/ui/protocol/GraphQLScriptTest.java +++ b/apm-protocol/apm-ui-protocol/src/test/java/org/apache/skywalking/apm/ui/protocol/GraphQLScriptTest.java @@ -26,8 +26,7 @@ import graphql.schema.idl.TypeDefinitionRegistry; import java.io.File; import org.junit.Test; -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; public class GraphQLScriptTest { @@ -40,8 +39,12 @@ public class GraphQLScriptTest { typeRegistry.merge(schemaParser.parse(loadSchema("common.graphqls"))); typeRegistry.merge(schemaParser.parse(loadSchema("trace.graphqls"))); typeRegistry.merge(schemaParser.parse(loadSchema("overview-layer.graphqls"))); + typeRegistry.merge(schemaParser.parse(loadSchema("application-layer.graphqls"))); + typeRegistry.merge(schemaParser.parse(loadSchema("server-layer.graphqls"))); + typeRegistry.merge(schemaParser.parse(loadSchema("service-layer.graphqls"))); + typeRegistry.merge(schemaParser.parse(loadSchema("alarm.graphqls"))); RuntimeWiring wiring = buildRuntimeWiring(); - assertThat(schemaGenerator.makeExecutableSchema(typeRegistry, wiring).getAllTypesAsList().size(), is(32)); + assertTrue(schemaGenerator.makeExecutableSchema(typeRegistry, wiring).getAllTypesAsList().size() > 0); } private File loadSchema(final String s) { From d3b357a447a6cf4b024cb72b7630fb748e9d5eab Mon Sep 17 00:00:00 2001 From: wu-sheng Date: Thu, 28 Dec 2017 16:16:12 +0800 Subject: [PATCH 13/15] Finish all services and readme. --- .../src/main/resources/ui-graphql/README.md | 34 ++++++++++++ .../main/resources/ui-graphql/trace.graphqls | 52 +++++++++++++++++++ 2 files changed, 86 insertions(+) create mode 100644 apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/README.md diff --git a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/README.md b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/README.md new file mode 100644 index 000000000..eba013053 --- /dev/null +++ b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/README.md @@ -0,0 +1,34 @@ +# Abstract +**apm-ui-protocol** declares all services, using GraphQL API style, which provide by Collector UI module. + +## Services +### [Common](common.graphqls) + +Include common objects, which used in global + +### [Overview Layer Service](overview-layer.graphqls) + +Query data without specific application, server or service. It includes info for overview the whole cluster. + +### [Application Layer Service](application-layer.graphqls) + +Query application related data with specific application code. + +### [Server Layer Service](server-layer.graphqls) + +Query server related data with specific server id. + +### [Service Layer Service](service-layer.graphqls) + +Query service related data with specific service id + +### [Trace Service](trace.graphqls) + +Query trace by some conditions. + +### [Alarm Service](alarm.graphqls) + +Query alarm info. + +## Version +1.0-alpha \ No newline at end of file diff --git a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/trace.graphqls b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/trace.graphqls index 822f7ce8f..4e2e1a0ec 100644 --- a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/trace.graphqls +++ b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/trace.graphqls @@ -32,6 +32,58 @@ enum QueryOrder { BY_DURATION } +# The trace represents a distributed trace, includes all segments and spans. +type Trace { + traceId: ID! + segments: [Segment!] +} + +type Segment { + segmentId: ID! + appName: String! + isSizeLimited: Boolean! + spans: [Span!]! +} + +type Span { + refs: [Ref!] + spanId: Int! + parentSpanId: Int! + startTime: Long! + endTime: Long! + operationName: String + # There are three span types: Local, Entry and Exit + type: String! + # Peer network id, e.g. host+port, ip+port + peer: String + component: String + isError: Boolean + # There are 5 layers: Unknown, Database, RPCFramework, Http, MQ and Cache + layer: String + tags: [KeyValue!] + logs: [LogEntity!] +} + +# Ref represents the link between the segment and its parents. +type Ref { + parentSegmentId: ID! + parentSpanId: Int! + # Ref type represents why did the ref happen. + # Include: 1) CrossProcess 2) CrossThread + type: String! +} + +type KeyValue { + key: String! + value: String +} + +type LogEntity { + time: String + data: [KeyValue!] +} + extend type Query { queryBasicTraces(condition: TraceQueryCondition): TraceBrief + queryTrace(traceId: ID!): Trace } \ No newline at end of file From 6b68a2cb6db49e04cc315d679021f54fc75e6084 Mon Sep 17 00:00:00 2001 From: wusheng Date: Sat, 30 Dec 2017 17:59:20 +0800 Subject: [PATCH 14/15] * `DurationItem` and `ThroughputItem` have been removed. Service defines must be explicit and clear. * In server layer, AppServerInfo type represents the basic server info and related metrics * In service layer, ServiceInfo type represents the basic service info and related metrics * `getServiceSlowTrace` service has been provided by `queryBasicTraces` service. All trace query should be included in that. --- .../resources/ui-graphql/application-layer.graphqls | 8 ++++---- .../src/main/resources/ui-graphql/common.graphqls | 12 ------------ .../resources/ui-graphql/overview-layer.graphqls | 4 ++-- .../main/resources/ui-graphql/service-layer.graphqls | 11 +++++++++-- 4 files changed, 15 insertions(+), 20 deletions(-) diff --git a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/application-layer.graphqls b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/application-layer.graphqls index 572b038ea..ef9fc7007 100644 --- a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/application-layer.graphqls +++ b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/application-layer.graphqls @@ -31,7 +31,7 @@ type ConjecturalNode implements Node { extend type Query { getAllApplication(duration: Duration!): [ApplicationNode] - getApplicationTopology(appId: ID!, duration: Duration!): Topology - getSlowService(appId: ID!, duration: Duration!): [DurationItem] - getServerThroughput(appId: ID!, duration: Duration!): [ThroughputItem] -} \ No newline at end of file + getApplicationTopology(applicationId: ID!, duration: Duration!): Topology + getSlowService(applicationId: ID!, duration: Duration!): [ServiceInfo!] + getServerThroughput(applicationId: ID!, duration: Duration!): [AppServerInfo!] +} diff --git a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/common.graphqls b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/common.graphqls index 0520b4b20..853f36258 100644 --- a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/common.graphqls +++ b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/common.graphqls @@ -86,15 +86,3 @@ type Call { # Unit: millisecond responseTimePerSec: Int! } - -# The item of slow service list -type DurationItem { - name: String! - duration: Int! -} - -# The item of throughput list -type ThroughputItem { - name: String! - tps: Int! -} \ No newline at end of file diff --git a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/overview-layer.graphqls b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/overview-layer.graphqls index aae527e31..e7b0bc2d6 100644 --- a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/overview-layer.graphqls +++ b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/overview-layer.graphqls @@ -32,6 +32,6 @@ extend type Query { getClusterBrief(duration: Duration!): ClusterBrief getAlarmTrend(duration: Duration!): AlarmTrend getConjecturalApps(duration: Duration!): ConjecturalAppBrief - getTopNSlowService(duration: Duration!, topN: Int!): [DurationItem] - getTopNServerThroughput(duration: Duration!, topN: Int!): [ThroughputItem] + getTopNSlowService(duration: Duration!, topN: Int!): [ServiceInfo!] + getTopNServerThroughput(duration: Duration!, topN: Int!): [AppServerInfo!] } diff --git a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/service-layer.graphqls b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/service-layer.graphqls index 2d7a90685..3e33c8f9e 100644 --- a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/service-layer.graphqls +++ b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/service-layer.graphqls @@ -12,6 +12,14 @@ type ServiceNode implements Node { numOfServiceAlarm: Int! } +type ServiceInfo { + id: ID! + name: String + # The unit is millisecond. + avgResponseTime: Int! + tps: Int! +} + type TraceItem { time: String! entry: String! @@ -24,5 +32,4 @@ extend type Query { getServiceTPSTrend(serviceId: ID!, duration: Duration!): ThroughputTrend getServiceSLATrend(serviceId: ID!, duration: Duration!): SLATrend getServiceTopology(serviceId: ID!, duration: Duration!): Topology - getServiceSlowTrace(serviceId: ID!, duration: Duration!): [TraceItem] -} \ No newline at end of file +} From 20973f5a283da2f02bddadc4adb930e788aed505 Mon Sep 17 00:00:00 2001 From: wusheng Date: Sat, 30 Dec 2017 22:30:19 +0800 Subject: [PATCH 15/15] Announce the version policy --- .../src/main/resources/ui-graphql/README.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/README.md b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/README.md index eba013053..60ddb04aa 100644 --- a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/README.md +++ b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/README.md @@ -31,4 +31,11 @@ Query trace by some conditions. Query alarm info. ## Version -1.0-alpha \ No newline at end of file +v1alpha1 + +### Versioning +Use URI Versioning, to follow the most straightforward approach, +though it does violate the principle that a URI should refer to a unique resource. + +e.g. +http://collector.host/graphql/v1alpha1