Skip to content

Commit

Permalink
[Uptime] Improve monitor charts query (#30561) (#32344)
Browse files Browse the repository at this point in the history
* Refactor chart querying.

* Fix monitor chart query.

* Refactor several inline computations to helper functions. Improve schema naming.

* Move unit conversion to client, remove bare conversion values.

* Add API tests for monitor charts.

* Add test for conversion function.

* Add type annotations to latest schema additions.

* Fix typo.

* Refactor based on PR feedback, add comments asked for in PR feedback.

* Rename fields in schema, update tests. Extract monitor charts to functional component and add unit test.
  • Loading branch information
justinkambic authored Mar 5, 2019
1 parent e6c6a59 commit f5890e7
Show file tree
Hide file tree
Showing 30 changed files with 1,121 additions and 375 deletions.
226 changes: 152 additions & 74 deletions x-pack/plugins/uptime/common/graphql/introspection.json
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,7 @@
"defaultValue": null
}
],
"type": {
"kind": "LIST",
"name": null,
"ofType": { "kind": "OBJECT", "name": "MonitorChartEntry", "ofType": null }
},
"type": { "kind": "OBJECT", "name": "MonitorChart", "ofType": null },
"isDeprecated": false,
"deprecationReason": null
},
Expand Down Expand Up @@ -1575,11 +1571,11 @@
{
"kind": "OBJECT",
"name": "LatestMonitor",
"description": "",
"description": "Represents the latest recorded information about a monitor.",
"fields": [
{
"name": "id",
"description": "",
"description": "The ID of the monitor represented by this data.",
"args": [],
"type": {
"kind": "NON_NULL",
Expand All @@ -1591,15 +1587,15 @@
},
{
"name": "ping",
"description": "",
"description": "Information from the latest document.",
"args": [],
"type": { "kind": "OBJECT", "name": "Ping", "ofType": null },
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "upSeries",
"description": "",
"description": "Buckets of recent up count status data.",
"args": [],
"type": {
"kind": "LIST",
Expand All @@ -1611,7 +1607,7 @@
},
{
"name": "downSeries",
"description": "",
"description": "Buckets of recent down count status data.",
"args": [],
"type": {
"kind": "LIST",
Expand Down Expand Up @@ -1793,86 +1789,133 @@
},
{
"kind": "OBJECT",
"name": "MonitorChartEntry",
"description": "",
"name": "MonitorChart",
"description": "The data used to populate the monitor charts.",
"fields": [
{
"name": "maxContent",
"description": "",
"name": "durationArea",
"description": "The max and min values for the monitor duration.",
"args": [],
"type": { "kind": "OBJECT", "name": "DataPoint", "ofType": null },
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "maxResponse",
"description": "",
"args": [],
"type": { "kind": "OBJECT", "name": "DataPoint", "ofType": null },
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "maxValidate",
"description": "",
"args": [],
"type": { "kind": "OBJECT", "name": "DataPoint", "ofType": null },
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "LIST",
"name": null,
"ofType": {
"kind": "NON_NULL",
"name": null,
"ofType": { "kind": "OBJECT", "name": "MonitorDurationAreaPoint", "ofType": null }
}
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "maxTotal",
"description": "",
"name": "durationLine",
"description": "The average values for the monitor duration.",
"args": [],
"type": { "kind": "OBJECT", "name": "DataPoint", "ofType": null },
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "LIST",
"name": null,
"ofType": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "OBJECT",
"name": "MonitorDurationAveragePoint",
"ofType": null
}
}
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "maxWriteRequest",
"description": "",
"name": "status",
"description": "The counts of up/down checks for the monitor.",
"args": [],
"type": { "kind": "OBJECT", "name": "DataPoint", "ofType": null },
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "LIST",
"name": null,
"ofType": {
"kind": "NON_NULL",
"name": null,
"ofType": { "kind": "OBJECT", "name": "StatusData", "ofType": null }
}
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "maxTcpRtt",
"description": "",
"name": "statusMaxCount",
"description": "The maximum status doc count in this chart.",
"args": [],
"type": { "kind": "OBJECT", "name": "DataPoint", "ofType": null },
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": { "kind": "SCALAR", "name": "Int", "ofType": null }
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "maxDuration",
"description": "",
"name": "durationMaxValue",
"description": "The maximum duration value in this chart.",
"args": [],
"type": { "kind": "OBJECT", "name": "DataPoint", "ofType": null },
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": { "kind": "SCALAR", "name": "Int", "ofType": null }
},
"isDeprecated": false,
"deprecationReason": null
},
}
],
"inputFields": null,
"interfaces": [],
"enumValues": null,
"possibleTypes": null
},
{
"kind": "OBJECT",
"name": "MonitorDurationAreaPoint",
"description": "Represents a monitor's duration performance in microseconds at a point in time.",
"fields": [
{
"name": "minDuration",
"description": "",
"name": "x",
"description": "The timeseries value for this point in time.",
"args": [],
"type": { "kind": "OBJECT", "name": "DataPoint", "ofType": null },
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": { "kind": "SCALAR", "name": "UnsignedInteger", "ofType": null }
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "avgDuration",
"description": "",
"name": "yMin",
"description": "The min duration value in microseconds at this time.",
"args": [],
"type": { "kind": "OBJECT", "name": "DataPoint", "ofType": null },
"type": { "kind": "SCALAR", "name": "Float", "ofType": null },
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "status",
"description": "",
"name": "yMax",
"description": "The max duration value in microseconds at this point.",
"args": [],
"type": { "kind": "OBJECT", "name": "StatusData", "ofType": null },
"type": { "kind": "SCALAR", "name": "Float", "ofType": null },
"isDeprecated": false,
"deprecationReason": null
}
Expand All @@ -1882,22 +1925,36 @@
"enumValues": null,
"possibleTypes": null
},
{
"kind": "SCALAR",
"name": "Float",
"description": "The `Float` scalar type represents signed double-precision fractional values as specified by [IEEE 754](http://en.wikipedia.org/wiki/IEEE_floating_point). ",
"fields": null,
"inputFields": null,
"interfaces": null,
"enumValues": null,
"possibleTypes": null
},
{
"kind": "OBJECT",
"name": "DataPoint",
"description": "",
"name": "MonitorDurationAveragePoint",
"description": "Represents the average monitor duration ms at a point in time.",
"fields": [
{
"name": "x",
"description": "",
"description": "The timeseries value for this point.",
"args": [],
"type": { "kind": "SCALAR", "name": "UnsignedInteger", "ofType": null },
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": { "kind": "SCALAR", "name": "UnsignedInteger", "ofType": null }
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "y",
"description": "",
"description": "The average duration ms for the monitor.",
"args": [],
"type": { "kind": "SCALAR", "name": "Float", "ofType": null },
"isDeprecated": false,
Expand All @@ -1909,48 +1966,42 @@
"enumValues": null,
"possibleTypes": null
},
{
"kind": "SCALAR",
"name": "Float",
"description": "The `Float` scalar type represents signed double-precision fractional values as specified by [IEEE 754](http://en.wikipedia.org/wiki/IEEE_floating_point). ",
"fields": null,
"inputFields": null,
"interfaces": null,
"enumValues": null,
"possibleTypes": null
},
{
"kind": "OBJECT",
"name": "StatusData",
"description": "",
"description": "Represents a bucket of monitor status information.",
"fields": [
{
"name": "x",
"description": "",
"description": "The timeseries point for this status data.",
"args": [],
"type": { "kind": "SCALAR", "name": "UnsignedInteger", "ofType": null },
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": { "kind": "SCALAR", "name": "UnsignedInteger", "ofType": null }
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "up",
"description": "",
"description": "The value of up counts for this point.",
"args": [],
"type": { "kind": "SCALAR", "name": "Int", "ofType": null },
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "down",
"description": "",
"description": "The value for down counts for this point.",
"args": [],
"type": { "kind": "SCALAR", "name": "Int", "ofType": null },
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "total",
"description": "",
"description": "The total down counts for this point.",
"args": [],
"type": { "kind": "SCALAR", "name": "Int", "ofType": null },
"isDeprecated": false,
Expand Down Expand Up @@ -2854,6 +2905,33 @@
}
],
"possibleTypes": null
},
{
"kind": "OBJECT",
"name": "DataPoint",
"description": "",
"fields": [
{
"name": "x",
"description": "",
"args": [],
"type": { "kind": "SCALAR", "name": "UnsignedInteger", "ofType": null },
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "y",
"description": "",
"args": [],
"type": { "kind": "SCALAR", "name": "Float", "ofType": null },
"isDeprecated": false,
"deprecationReason": null
}
],
"inputFields": null,
"interfaces": [],
"enumValues": null,
"possibleTypes": null
}
],
"directives": [
Expand Down
Loading

0 comments on commit f5890e7

Please sign in to comment.