-
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.
[ObsAssistant] Add Insights component to alerts details (#178330)
Depends on: #179380 This PR adds contextual insights to the alert details page. This makes it possible to get good explanation of why an error occurred. <img width="1469" alt="image" src="https://github.com/elastic/kibana/assets/209966/ec3faae6-d29a-437a-8e59-234457e152eb"> **Video** https://github.com/elastic/kibana/assets/209966/2cbdae10-298b-4817-aa92-052bbb11e913
- Loading branch information
Showing
41 changed files
with
1,412 additions
and
332 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
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
165 changes: 165 additions & 0 deletions
165
packages/kbn-apm-synthtrace/src/scenarios/spiked_latency.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,165 @@ | ||
/* | ||
* 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 { random } from 'lodash'; | ||
import { | ||
apm, | ||
log, | ||
ApmFields, | ||
generateLongId, | ||
generateShortId, | ||
Instance, | ||
} from '@kbn/apm-synthtrace-client'; | ||
import { Scenario } from '../cli/scenario'; | ||
import { getSynthtraceEnvironment } from '../lib/utils/get_synthtrace_environment'; | ||
import { withClient } from '../lib/utils/with_client'; | ||
|
||
const ENVIRONMENT = getSynthtraceEnvironment(__filename); | ||
const alwaysSpikeTransactionName = 'GET /always-spike'; | ||
const sometimesSpikeTransactionName = 'GET /sometimes-spike'; | ||
|
||
const scenario: Scenario<ApmFields> = async ({ logger }) => { | ||
return { | ||
generate: ({ range, clients: { apmEsClient, logsEsClient } }) => { | ||
const serviceNames = ['spikey-frontend', 'spikey-backend']; | ||
|
||
const clusters = [ | ||
{ provider: 'gcp', region: 'eu-central-1' }, | ||
{ provider: 'aws', region: 'us-east-1' }, | ||
{ provider: 'azure', region: 'area-51' }, | ||
].map((cluster, index) => ({ | ||
clusterName: `synth-cluster-${index}`, | ||
clusterId: generateShortId(), | ||
projectId: generateShortId(), | ||
ressourceId: generateShortId(), | ||
instanceId: generateShortId(), | ||
cloudProvider: cluster.provider, | ||
cloudRegion: cluster.region, | ||
})); | ||
|
||
const containerId = `spiked-${generateShortId()}`; | ||
const hostName = `spiked-${generateShortId()}`; | ||
|
||
function buildLogs(serviceName: string) { | ||
return range | ||
.interval('1m') | ||
.rate(100) | ||
.generator((timestamp) => { | ||
const clusterIndex = Math.floor(Math.random() * clusters.length); | ||
const { | ||
clusterId, | ||
clusterName, | ||
projectId, | ||
ressourceId, | ||
instanceId, | ||
cloudRegion, | ||
cloudProvider, | ||
} = clusters[clusterIndex]; | ||
|
||
return log | ||
.create() | ||
.message(`Error message #${generateShortId()} from ${serviceName}`) | ||
.logLevel('error') | ||
.service(serviceName) | ||
.containerId(containerId) | ||
.hostName(hostName) | ||
.defaults({ | ||
'trace.id': generateShortId(), | ||
'agent.name': 'synth-agent', | ||
'orchestrator.cluster.name': clusterName, | ||
'orchestrator.cluster.id': clusterId, | ||
'orchestrator.resource.id': ressourceId, | ||
'cloud.provider': cloudProvider, | ||
'cloud.region': cloudRegion, | ||
'cloud.availability_zone': `${cloudRegion}`, | ||
'cloud.project.id': projectId, | ||
'cloud.instance.id': instanceId, | ||
'log.file.path': `/logs/${generateLongId()}/error.txt`, | ||
}) | ||
.timestamp(timestamp); | ||
}); | ||
} | ||
|
||
const serviceInstances = serviceNames.map((serviceName) => | ||
apm | ||
.service({ name: serviceName, environment: ENVIRONMENT, agentName: 'go' }) | ||
.instance(`my-instance`) | ||
); | ||
|
||
const transactionNames = [ | ||
'GET /order', | ||
'GET /product', | ||
alwaysSpikeTransactionName, | ||
sometimesSpikeTransactionName, | ||
]; | ||
|
||
const buildTransactions = (serviceInstance: Instance, transactionName: string) => { | ||
const interval = random(1, 100, false); | ||
const rangeWithInterval = range.interval(`${interval}s`); | ||
|
||
return rangeWithInterval.generator((timestamp, i) => { | ||
const duration = getDuration(transactionName); | ||
return serviceInstance | ||
.containerId(containerId) | ||
.hostName(hostName) | ||
.transaction({ transactionName }) | ||
.timestamp(timestamp) | ||
.duration(duration) | ||
.children( | ||
serviceInstance | ||
.span({ | ||
spanName: 'GET apm-*/_search', | ||
spanType: 'db', | ||
spanSubtype: 'elasticsearch', | ||
}) | ||
.duration(duration * 0.9) | ||
.destination('elasticsearch') | ||
.timestamp(timestamp) | ||
.outcome('success') | ||
) | ||
.success(); | ||
}); | ||
}; | ||
|
||
return [ | ||
withClient( | ||
logsEsClient, | ||
logger.perf('generating_logs', () => | ||
serviceNames.map((serviceName) => buildLogs(serviceName)) | ||
) | ||
), | ||
withClient( | ||
apmEsClient, | ||
logger.perf('generating_apm_events', () => | ||
serviceInstances.flatMap((serviceInstance) => | ||
transactionNames.flatMap((transactionName) => | ||
buildTransactions(serviceInstance, transactionName) | ||
) | ||
) | ||
) | ||
), | ||
]; | ||
}, | ||
}; | ||
}; | ||
|
||
function getDuration(transactionName: string) { | ||
const spikedDuration = random(40000, 41000, false); | ||
const normalDuration = random(400, 500, false); | ||
|
||
switch (transactionName) { | ||
case alwaysSpikeTransactionName: | ||
return spikedDuration; | ||
case sometimesSpikeTransactionName: | ||
return Math.random() > 0.01 ? spikedDuration : normalDuration; | ||
default: | ||
return normalDuration; | ||
} | ||
} | ||
|
||
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
32 changes: 32 additions & 0 deletions
32
...plugins/alerting/server/integration_tests/__snapshots__/alert_as_data_fields.test.ts.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.