mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
fixed rds and aws cpu percentages. (#188768)
## Summary This PR fixes incorrect cpu percentage values in AWS and Redis metrics displayed on the Infra inventory page. (#179807) I also added synthtrace for redis based off #179809 <img width="2672" alt="Screenshot 2024-07-19 at 09 32 55" src="https://github.com/user-attachments/assets/23dd4c83-a11c-4ad9-87df-b0bf620b8e31">
This commit is contained in:
parent
a7047c31d5
commit
80cd581ee8
10 changed files with 117 additions and 6 deletions
|
@ -22,6 +22,7 @@ export { httpExitSpan } from './src/lib/apm/span';
|
|||
export { DistributedTrace } from './src/lib/dsl/distributed_trace_client';
|
||||
export { serviceMap } from './src/lib/dsl/service_map';
|
||||
export type { Fields } from './src/lib/entity';
|
||||
export { Entity } from './src/lib/entity';
|
||||
export { infra, type InfraDocument } from './src/lib/infra';
|
||||
export { parseInterval } from './src/lib/interval';
|
||||
export { monitoring, type MonitoringDocument } from './src/lib/monitoring';
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
import { Fields } from '../entity';
|
||||
import { Serializable } from '../serializable';
|
||||
|
||||
type AssetType = 'host' | 'pod' | 'container' | 'service';
|
||||
type AssetType = 'host' | 'pod' | 'container' | 'service' | 'aws_rds';
|
||||
|
||||
export interface AssetDocument extends Fields {
|
||||
'asset.id': string;
|
||||
|
|
49
packages/kbn-apm-synthtrace-client/src/lib/infra/aws/rds.ts
Normal file
49
packages/kbn-apm-synthtrace-client/src/lib/infra/aws/rds.ts
Normal file
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
||||
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
||||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
/* eslint-disable max-classes-per-file */
|
||||
import { Entity, Fields } from '../../entity';
|
||||
import { Serializable } from '../../serializable';
|
||||
|
||||
export interface AWSRdsDocument extends Fields {
|
||||
'aws.rds.db_instance.arn': string;
|
||||
'aws.rds.db_instance.identifier': string;
|
||||
'metricset.name'?: string;
|
||||
'event.dataset'?: string;
|
||||
}
|
||||
|
||||
export interface AWSRdsMetricsDocument extends AWSRdsDocument {
|
||||
'aws.rds.cpu.total.pct'?: number;
|
||||
'aws.rds.database_connections'?: number;
|
||||
'aws.rds.latency.dml'?: number;
|
||||
'aws.rds.latency.read'?: number;
|
||||
'aws.rds.latency.write'?: number;
|
||||
'aws.rds.latency.insert'?: number;
|
||||
'aws.rds.latency.update'?: number;
|
||||
'aws.rds.latency.commit'?: number;
|
||||
'aws.rds.queries'?: number;
|
||||
}
|
||||
|
||||
class AWSRdsMetrics extends Serializable<AWSRdsMetricsDocument> {}
|
||||
|
||||
export class AWSRds extends Entity<AWSRdsDocument> {
|
||||
metrics(metricsFields: AWSRdsMetricsDocument) {
|
||||
return new AWSRdsMetrics({
|
||||
...this.fields,
|
||||
...metricsFields,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export function awsRds(arn: string, name: string): AWSRds {
|
||||
return new AWSRds({
|
||||
'aws.rds.db_instance.arn': arn,
|
||||
'aws.rds.db_instance.identifier': name,
|
||||
'event.dataset': 'aws.rds',
|
||||
});
|
||||
}
|
|
@ -10,16 +10,19 @@ import { dockerContainer, DockerContainerMetricsDocument } from './docker_contai
|
|||
import { host, HostMetricsDocument } from './host';
|
||||
import { k8sContainer, K8sContainerMetricsDocument } from './k8s_container';
|
||||
import { pod, PodMetricsDocument } from './pod';
|
||||
import { awsRds, AWSRdsMetricsDocument } from './aws/rds';
|
||||
|
||||
export type InfraDocument =
|
||||
| HostMetricsDocument
|
||||
| PodMetricsDocument
|
||||
| DockerContainerMetricsDocument
|
||||
| K8sContainerMetricsDocument;
|
||||
| K8sContainerMetricsDocument
|
||||
| AWSRdsMetricsDocument;
|
||||
|
||||
export const infra = {
|
||||
host,
|
||||
pod,
|
||||
dockerContainer,
|
||||
k8sContainer,
|
||||
awsRds,
|
||||
};
|
||||
|
|
|
@ -64,6 +64,8 @@ function getRoutingTransform() {
|
|||
document._index = 'metrics-kubernetes.container-default';
|
||||
} else if ('kubernetes.pod.uid' in document) {
|
||||
document._index = 'metrics-kubernetes.pod-default';
|
||||
} else if ('aws.rds.db_instance.arn' in document) {
|
||||
document._index = 'metrics-aws.rds-default';
|
||||
} else {
|
||||
throw new Error('Cannot determine index for event');
|
||||
}
|
||||
|
|
56
packages/kbn-apm-synthtrace/src/scenarios/infra_aws_rds.ts
Normal file
56
packages/kbn-apm-synthtrace/src/scenarios/infra_aws_rds.ts
Normal file
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
||||
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
||||
* Side Public License, v 1.
|
||||
*/
|
||||
import { InfraDocument, ApmFields, infra } from '@kbn/apm-synthtrace-client';
|
||||
import { Scenario } from '../cli/scenario';
|
||||
import { withClient } from '../lib/utils/with_client';
|
||||
|
||||
const numRds = 50;
|
||||
const scenario: Scenario<InfraDocument | ApmFields> = async (runOptions) => {
|
||||
return {
|
||||
generate: ({ range, clients: { infraEsClient } }) => {
|
||||
const { logger } = runOptions;
|
||||
|
||||
// Infra hosts Data logic
|
||||
|
||||
const RDS = Array(numRds)
|
||||
.fill(0)
|
||||
.map((_, idx) => infra.awsRds(`redis-${idx}`, `redis-${idx}`));
|
||||
|
||||
const rds = range
|
||||
.interval('30s')
|
||||
.rate(1)
|
||||
.generator((timestamp) =>
|
||||
RDS.flatMap((item) => [
|
||||
item
|
||||
.metrics({
|
||||
...item.fields,
|
||||
'aws.rds.cpu.total.pct': 0.4,
|
||||
'aws.rds.database_connections': 5,
|
||||
'aws.rds.latency.read': 500 * 1000,
|
||||
'aws.rds.latency.write': 500 * 1000,
|
||||
'aws.rds.latency.insert': 500 * 1000,
|
||||
'aws.rds.latency.update': 500 * 1000,
|
||||
'aws.rds.latency.commit': 500 * 1000,
|
||||
'aws.rds.latency.dml': 500 * 1000,
|
||||
'aws.rds.queries': 100,
|
||||
})
|
||||
.timestamp(timestamp),
|
||||
])
|
||||
);
|
||||
|
||||
return [
|
||||
withClient(
|
||||
infraEsClient,
|
||||
logger.perf('generating_infra_aws_rds', () => rds)
|
||||
),
|
||||
];
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
export default scenario;
|
|
@ -19,7 +19,7 @@ export const cpu: MetricsUIAggregation = {
|
|||
cpu: 'cpu_avg',
|
||||
},
|
||||
script: {
|
||||
source: 'params.cpu / 100',
|
||||
source: 'params.cpu',
|
||||
lang: 'painless',
|
||||
},
|
||||
gap_policy: 'skip',
|
||||
|
|
|
@ -22,7 +22,7 @@ export const awsEC2CpuUtilization = createTSVBModel(
|
|||
},
|
||||
{
|
||||
id: 'convert-to-percent',
|
||||
script: 'params.avg / 100',
|
||||
script: 'params.avg',
|
||||
type: 'calculation',
|
||||
variables: [
|
||||
{
|
||||
|
|
|
@ -19,7 +19,7 @@ export const cpu: MetricsUIAggregation = {
|
|||
cpu: 'cpu_avg',
|
||||
},
|
||||
script: {
|
||||
source: 'params.cpu / 100',
|
||||
source: 'params.cpu',
|
||||
lang: 'painless',
|
||||
},
|
||||
gap_policy: 'skip',
|
||||
|
|
|
@ -22,7 +22,7 @@ export const awsRDSCpuTotal = createTSVBModel(
|
|||
},
|
||||
{
|
||||
id: 'convert-to-percent',
|
||||
script: 'params.avg / 100',
|
||||
script: 'params.avg',
|
||||
type: 'calculation',
|
||||
variables: [
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue