-
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.
[APM] Add transaction name filter in latency threshold rule (#154241)
Part of the #152329 1. Adds a synthrace scenario that generates many transactions per service 2. Fixes the duration chart preview when selecting All option - #152195 3. Introduces the `Transaction name` filter in the rule type. ### Pages loading the rule type 1. APM 2. Alert 3. Management rule ### Consider - [ ] Update/Adding documentation example https://www.elastic.co/guide/en/kibana/master/apm-alerts.html#apm-create-transaction-alert ## Creating a rule https://user-images.githubusercontent.com/3369346/231740745-425c8eb8-6798-4ce4-b375-4ef96afdb334.mov ## Updating a rule https://user-images.githubusercontent.com/3369346/231742035-28f50dfd-64bb-475d-b037-331eea4188d7.mov ### Before https://user-images.githubusercontent.com/3369346/232799038-2edaa199-b970-48f2-b3ca-728273e4bf44.mov ### Notes #### Feedback The default action messages don't include any links. I will create a follow-up ticket to improve the messages with actionable links. Related bugs but out of the scope of the PR - #154818 - #154704 --------- Co-authored-by: Kibana Machine <[email protected]>
- Loading branch information
1 parent
79969fb
commit 7c70508
Showing
17 changed files
with
276 additions
and
26 deletions.
There are no files selected for viewing
84 changes: 84 additions & 0 deletions
84
packages/kbn-apm-synthtrace/src/scenarios/many_transactions_per_service.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,84 @@ | ||
/* | ||
* 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 { ApmFields, apm, Instance } from '@kbn/apm-synthtrace-client'; | ||
import { Scenario } from '../cli/scenario'; | ||
import { getSynthtraceEnvironment } from '../lib/utils/get_synthtrace_environment'; | ||
|
||
const ENVIRONMENT = getSynthtraceEnvironment(__filename); | ||
|
||
const scenario: Scenario<ApmFields> = async (runOptions) => { | ||
const { logger } = runOptions; | ||
const { numServices = 3 } = runOptions.scenarioOpts || {}; | ||
const numTransactions = 100; | ||
|
||
return { | ||
generate: ({ range }) => { | ||
const urls = ['GET /order', 'POST /basket', 'DELETE /basket', 'GET /products']; | ||
|
||
const successfulTimestamps = range.ratePerMinute(180); | ||
const failedTimestamps = range.interval('1m').rate(180); | ||
|
||
const instances = [...Array(numServices).keys()].map((index) => | ||
apm | ||
.service({ name: `synth-go-${index}`, environment: ENVIRONMENT, agentName: 'go' }) | ||
.instance(`instance-${index}`) | ||
); | ||
|
||
const transactionNames = [...Array(numTransactions).keys()].map( | ||
(index) => `${urls[index % urls.length]}/${index}` | ||
); | ||
|
||
const instanceSpans = (instance: Instance, transactionName: string) => { | ||
const successfulTraceEvents = successfulTimestamps.generator((timestamp) => | ||
instance.transaction({ transactionName }).timestamp(timestamp).duration(1000).success() | ||
); | ||
|
||
const failedTraceEvents = failedTimestamps.generator((timestamp) => | ||
instance | ||
.transaction({ transactionName }) | ||
.timestamp(timestamp) | ||
.duration(1000) | ||
.failure() | ||
.errors( | ||
instance | ||
.error({ message: '[ResponseError] index_not_found_exception' }) | ||
.timestamp(timestamp + 50) | ||
) | ||
); | ||
|
||
const metricsets = range | ||
.interval('30s') | ||
.rate(1) | ||
.generator((timestamp) => | ||
instance | ||
.appMetrics({ | ||
'system.memory.actual.free': 800, | ||
'system.memory.total': 1000, | ||
'system.cpu.total.norm.pct': 0.6, | ||
'system.process.cpu.total.norm.pct': 0.7, | ||
}) | ||
.timestamp(timestamp) | ||
); | ||
|
||
return [successfulTraceEvents, failedTraceEvents, metricsets]; | ||
}; | ||
|
||
return logger.perf('generating_apm_events', () => | ||
instances | ||
.flatMap((instance) => | ||
transactionNames.map((transactionName) => ({ instance, transactionName })) | ||
) | ||
.flatMap(({ instance, transactionName }, index) => | ||
instanceSpans(instance, transactionName) | ||
) | ||
); | ||
}, | ||
}; | ||
}; | ||
|
||
export default scenario; |
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
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
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
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
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
Oops, something went wrong.