Finish all protocol

This commit is contained in:
gaohongtao 2017-12-27 12:41:28 +08:00
parent d3ab94bee3
commit 6d96cf6bf2
7 changed files with 183 additions and 136 deletions

View File

@ -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]
}

View File

@ -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]
}

View File

@ -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!
}

View File

@ -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]
}

View File

@ -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
}

View File

@ -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]
}

View File

@ -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) {