-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
draft of aws rds synthtrace scenario
- Loading branch information
1 parent
3fd71e7
commit 86319b2
Showing
5 changed files
with
120 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
packages/kbn-apm-synthtrace-client/src/lib/infra/aws/rds.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* 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 { AWSRedisAsset } from '../../assets'; | ||
import { Entity, Fields } from '../../entity'; | ||
import { Serializable } from '../../serializable'; | ||
|
||
interface AWSRdsDocument extends Fields { | ||
'aws.rds.db_instance.arn': string; | ||
'aws.rds.db_instance.identifier': string; | ||
'metricset.name'?: string; | ||
'event.dataset'?: string; | ||
} | ||
|
||
export class AWSRds extends Entity<AWSRdsDocument> { | ||
metrics() { | ||
return new AWSRdsMetrics({ | ||
...this.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, | ||
'event.dataset': 'aws.rds', | ||
}); | ||
} | ||
|
||
asset() { | ||
return new AWSRedisAsset({ | ||
'asset.kind': 'aws_rds', | ||
'asset.id': this.fields['aws.rds.db_instance.arn'], | ||
'asset.name': this.fields['aws.rds.db_instance.identifier'], | ||
'asset.ean': `aws_rds:${'aws.rds.db_instance.arn'}`, | ||
}); | ||
} | ||
} | ||
|
||
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 function awsRds(arn: string, name: string): AWSRds { | ||
return new AWSRds({ | ||
'aws.rds.db_instance.arn': arn, | ||
'aws.rds.db_instance.identifier': name, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
packages/kbn-apm-synthtrace/src/scenarios/infra_aws_rds.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* 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, infra, ApmFields } 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().timestamp(timestamp)])); | ||
|
||
return [ | ||
withClient( | ||
infraEsClient, | ||
logger.perf('generating_infra_aws_rds', () => rds) | ||
), | ||
]; | ||
}, | ||
}; | ||
}; | ||
|
||
export default scenario; |