mirror of
https://github.com/yldio/copilot.git
synced 2024-11-15 07:40:07 +02:00
feat: support metrics in schema and mock server
This commit is contained in:
parent
55f387e247
commit
e5187ff4c5
56
packages/cp-gql-mock-server/src/metric-data.json
Normal file
56
packages/cp-gql-mock-server/src/metric-data.json
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"name": "AVG_MEM_BYTES",
|
||||||
|
"instance": "joyentportal_compose-api_1",
|
||||||
|
"metrics": [
|
||||||
|
{
|
||||||
|
"time": "2017-08-16T15:10:17.371Z",
|
||||||
|
"value": 60518400
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"time": "2017-08-16T16:10:17.371Z",
|
||||||
|
"value": 60641280
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"time": "2017-08-16T17:10:17.371Z",
|
||||||
|
"value": 60575744
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "AVG_LOAD_PERCENT",
|
||||||
|
"instance": "joyentportal_compose-api_1",
|
||||||
|
"metrics": [
|
||||||
|
{
|
||||||
|
"time": "2017-08-16T15:10:17.371Z",
|
||||||
|
"value": 23.2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"time": "2017-08-16T16:10:17.371Z",
|
||||||
|
"value": 23.6
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"time": "2017-08-16T17:10:17.371Z",
|
||||||
|
"value": 23.7
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "AGG_NETWORK_BYTES",
|
||||||
|
"instance": "joyentportal_compose-api_1",
|
||||||
|
"metrics": [
|
||||||
|
{
|
||||||
|
"time": "2017-08-16T15:10:17.371Z",
|
||||||
|
"value": 64262042
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"time": "2017-08-16T16:10:17.371Z",
|
||||||
|
"value": 65743772
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"time": "2017-08-16T17:10:17.371Z",
|
||||||
|
"value": 67226695
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
@ -15,6 +15,7 @@ const Boom = require('boom');
|
|||||||
const wpData = require('./wp-data.json');
|
const wpData = require('./wp-data.json');
|
||||||
const cpData = require('./cp-data.json');
|
const cpData = require('./cp-data.json');
|
||||||
const complexData = require('./complex-data.json');
|
const complexData = require('./complex-data.json');
|
||||||
|
const metricData = require('./metric-data.json');
|
||||||
|
|
||||||
const { datacenter, portal } = require('./data.json');
|
const { datacenter, portal } = require('./data.json');
|
||||||
|
|
||||||
@ -527,6 +528,10 @@ const config = ({
|
|||||||
return _plain ? config : Promise.resolve(config);
|
return _plain ? config : Promise.resolve(config);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const getMetrics = () => {
|
||||||
|
return Promise.resolve(metricData);
|
||||||
|
};
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
portal: getPortal,
|
portal: getPortal,
|
||||||
deploymentGroups: getDeploymentGroups,
|
deploymentGroups: getDeploymentGroups,
|
||||||
@ -549,5 +554,6 @@ module.exports = {
|
|||||||
restartServices: (options, request, fn) => fn(null, restartServices(options)),
|
restartServices: (options, request, fn) => fn(null, restartServices(options)),
|
||||||
stopServices: (options, request, fn) => fn(null, stopServices(options)),
|
stopServices: (options, request, fn) => fn(null, stopServices(options)),
|
||||||
startServices: (options, request, fn) => fn(null, startServices(options)),
|
startServices: (options, request, fn) => fn(null, startServices(options)),
|
||||||
config
|
config,
|
||||||
|
metrics: getMetrics
|
||||||
};
|
};
|
||||||
|
@ -183,6 +183,25 @@ type Datacenter {
|
|||||||
region: String!
|
region: String!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
type Metric {
|
||||||
|
time: String!
|
||||||
|
value: Float!
|
||||||
|
}
|
||||||
|
|
||||||
|
enum MetricName {
|
||||||
|
AVG_MEM_BYTES,
|
||||||
|
AVG_LOAD_PERCENT,
|
||||||
|
AGG_NETWORK_BYTES
|
||||||
|
}
|
||||||
|
|
||||||
|
type InstanceMetric {
|
||||||
|
instance: String!
|
||||||
|
name: MetricName!
|
||||||
|
metrics: [Metrics]
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
# we probably wont use some of these queries or arguments
|
# we probably wont use some of these queries or arguments
|
||||||
# but this way we expose the entire db through gql
|
# but this way we expose the entire db through gql
|
||||||
type Query {
|
type Query {
|
||||||
@ -243,6 +262,8 @@ type Query {
|
|||||||
raw: String!
|
raw: String!
|
||||||
): [Service]
|
): [Service]
|
||||||
importableDeploymentGroups: [DeploymentGroup]
|
importableDeploymentGroups: [DeploymentGroup]
|
||||||
|
# start and end should be .toISOString() date strings
|
||||||
|
metrics(names: [MerticName], instances: [String], start: String, end: String): [InstanceMetric]
|
||||||
}
|
}
|
||||||
|
|
||||||
type Mutation {
|
type Mutation {
|
||||||
|
Loading…
Reference in New Issue
Block a user