Skip to content

Commit

Permalink
[Infra UI] Add AWS metrics to node detail page (#42153) (#43181)
Browse files Browse the repository at this point in the history
* Add cloudId to metrics graphql query.

* Add server-side TSVB model for aws cpu utilization

* Use cloud id for cloud metrics

* Add AWS layout to host page

* Add cloudId to useMetadata

* Refactor: move aws modules into separate directory

* Add AWS network chart to node details

* Add AWS Overview to node details

* Add aws network packets chart to node details

* Add TODO reference to aws network bytes model

* Add AWS diskio ops to node details

* Add AWS diskio bytes to node details

* Check that cloudId is given when needed

* Use network packets on node details AWS overview

* Remove requires on layout level.

* Fix layout creator type signature.

* Add gaugeMax to layout types
  • Loading branch information
skh authored Aug 13, 2019
1 parent 8b10071 commit 7021666
Show file tree
Hide file tree
Showing 23 changed files with 778 additions and 16 deletions.
15 changes: 14 additions & 1 deletion x-pack/legacy/plugins/infra/common/graphql/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,12 @@ export interface InfraSnapshotMetricInput {
/** The type of metric */
type: InfraSnapshotMetricType;
}

export interface InfraNodeIdsInput {
nodeId: string;

cloudId?: string | null;
}
/** The properties to update the source with */
export interface UpdateSourceInput {
/** The name of the data source */
Expand Down Expand Up @@ -493,7 +499,7 @@ export interface SnapshotInfraSourceArgs {
filterQuery?: string | null;
}
export interface MetricsInfraSourceArgs {
nodeId: string;
nodeIds: InfraNodeIdsInput;

nodeType: InfraNodeType;

Expand Down Expand Up @@ -582,6 +588,12 @@ export enum InfraMetric {
nginxRequestRate = 'nginxRequestRate',
nginxActiveConnections = 'nginxActiveConnections',
nginxRequestsPerConnection = 'nginxRequestsPerConnection',
awsOverview = 'awsOverview',
awsCpuUtilization = 'awsCpuUtilization',
awsNetworkBytes = 'awsNetworkBytes',
awsNetworkPackets = 'awsNetworkPackets',
awsDiskioBytes = 'awsDiskioBytes',
awsDiskioOps = 'awsDiskioOps',
custom = 'custom',
}

Expand Down Expand Up @@ -794,6 +806,7 @@ export namespace MetricsQuery {
timerange: InfraTimerangeInput;
metrics: InfraMetric[];
nodeId: string;
cloudId?: string | null;
nodeType: InfraNodeType;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,12 @@ export function useMetadata(
filteredLayouts: (response && getFilteredLayouts(layouts, response.features)) || [],
error: (error && error.message) || null,
loading,
cloudId:
(response &&
response.info &&
response.info.cloud &&
response.info.cloud.instance &&
response.info.cloud.instance.id) ||
'',
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,17 @@ export const metricsQuery = gql`
$timerange: InfraTimerangeInput!
$metrics: [InfraMetric!]!
$nodeId: ID!
$cloudId: ID
$nodeType: InfraNodeType!
) {
source(id: $sourceId) {
id
metrics(nodeId: $nodeId, timerange: $timerange, metrics: $metrics, nodeType: $nodeType) {
metrics(
nodeIds: { nodeId: $nodeId, cloudId: $cloudId }
timerange: $timerange
metrics: $metrics
nodeType: $nodeType
) {
id
series {
id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ interface WithMetricsProps {
layouts: InfraMetricLayout[];
nodeType: InfraNodeType;
nodeId: string;
cloudId: string;
sourceId: string;
timerange: InfraTimerangeInput;
}
Expand All @@ -39,6 +40,7 @@ export const WithMetrics = ({
timerange,
nodeType,
nodeId,
cloudId,
}: WithMetricsProps) => {
const metrics = layouts.reduce(
(acc, item) => {
Expand All @@ -57,6 +59,7 @@ export const WithMetrics = ({
metrics,
nodeType,
nodeId,
cloudId,
timerange,
}}
>
Expand Down
67 changes: 65 additions & 2 deletions x-pack/legacy/plugins/infra/public/graphql/introspection.json
Original file line number Diff line number Diff line change
Expand Up @@ -471,12 +471,12 @@
"description": "",
"args": [
{
"name": "nodeId",
"name": "nodeIds",
"description": "",
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": { "kind": "SCALAR", "name": "ID", "ofType": null }
"ofType": { "kind": "INPUT_OBJECT", "name": "InfraNodeIdsInput", "ofType": null }
},
"defaultValue": null
},
Expand Down Expand Up @@ -2316,6 +2316,33 @@
"enumValues": null,
"possibleTypes": null
},
{
"kind": "INPUT_OBJECT",
"name": "InfraNodeIdsInput",
"description": "",
"fields": null,
"inputFields": [
{
"name": "nodeId",
"description": "",
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": { "kind": "SCALAR", "name": "ID", "ofType": null }
},
"defaultValue": null
},
{
"name": "cloudId",
"description": "",
"type": { "kind": "SCALAR", "name": "ID", "ofType": null },
"defaultValue": null
}
],
"interfaces": null,
"enumValues": null,
"possibleTypes": null
},
{
"kind": "ENUM",
"name": "InfraMetric",
Expand Down Expand Up @@ -2486,6 +2513,42 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "awsOverview",
"description": "",
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "awsCpuUtilization",
"description": "",
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "awsNetworkBytes",
"description": "",
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "awsNetworkPackets",
"description": "",
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "awsDiskioBytes",
"description": "",
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "awsDiskioOps",
"description": "",
"isDeprecated": false,
"deprecationReason": null
},
{ "name": "custom", "description": "", "isDeprecated": false, "deprecationReason": null }
],
"possibleTypes": null
Expand Down
15 changes: 14 additions & 1 deletion x-pack/legacy/plugins/infra/public/graphql/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,12 @@ export interface InfraSnapshotMetricInput {
/** The type of metric */
type: InfraSnapshotMetricType;
}

export interface InfraNodeIdsInput {
nodeId: string;

cloudId?: string | null;
}
/** The properties to update the source with */
export interface UpdateSourceInput {
/** The name of the data source */
Expand Down Expand Up @@ -493,7 +499,7 @@ export interface SnapshotInfraSourceArgs {
filterQuery?: string | null;
}
export interface MetricsInfraSourceArgs {
nodeId: string;
nodeIds: InfraNodeIdsInput;

nodeType: InfraNodeType;

Expand Down Expand Up @@ -582,6 +588,12 @@ export enum InfraMetric {
nginxRequestRate = 'nginxRequestRate',
nginxActiveConnections = 'nginxActiveConnections',
nginxRequestsPerConnection = 'nginxRequestsPerConnection',
awsOverview = 'awsOverview',
awsCpuUtilization = 'awsCpuUtilization',
awsNetworkBytes = 'awsNetworkBytes',
awsNetworkPackets = 'awsNetworkPackets',
awsDiskioBytes = 'awsDiskioBytes',
awsDiskioOps = 'awsDiskioOps',
custom = 'custom',
}

Expand Down Expand Up @@ -794,6 +806,7 @@ export namespace MetricsQuery {
timerange: InfraTimerangeInput;
metrics: InfraMetric[];
nodeId: string;
cloudId?: string | null;
nodeType: InfraNodeType;
};

Expand Down
3 changes: 2 additions & 1 deletion x-pack/legacy/plugins/infra/public/pages/metrics/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export const MetricDetail = withMetricPageProviders(
}
const { sourceId } = useContext(Source.Context);
const layouts = layoutCreator(theme);
const { name, filteredLayouts, loading: metadataLoading } = useMetadata(
const { name, filteredLayouts, loading: metadataLoading, cloudId } = useMetadata(
nodeId,
nodeType,
layouts,
Expand Down Expand Up @@ -148,6 +148,7 @@ export const MetricDetail = withMetricPageProviders(
timerange={timeRange as InfraTimerangeInput}
nodeType={nodeType}
nodeId={nodeId}
cloudId={cloudId}
>
{({ metrics, error, loading, refetch }) => {
if (error) {
Expand Down
Loading

0 comments on commit 7021666

Please sign in to comment.