[8.13] [Uptime alerts] Add monitor config id to context (#180921) (#180983)

# Backport

This will backport the following commits from `main` to `8.13`:
- [[Uptime alerts] Add monitor config id to context
(#180921)](https://github.com/elastic/kibana/pull/180921)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT
[{"author":{"name":"Shahzad","email":"shahzad31comp@gmail.com"},"sourceCommit":{"committedDate":"2024-04-16T20:54:05Z","message":"[Uptime
alerts] Add monitor config id to context (#180921)\n\n##
Summary\r\n\r\nThis is needed where users want to generate links to
synthetics monitors\r\nusing uptime alerts !!\r\n\r\n### Example usage
\r\n\r\n<img width=\"625\"
alt=\"image\"\r\nsrc=\"4f2f7833-9313-4c3a-8ea0-a383cb2ec857\">\r\n\r\n\r\n<img
width=\"956\"
alt=\"image\"\r\nsrc=\"10541a9c-987b-427c-a55e-4e0ba01891cf\">","sha":"09cc4ac9a753b41a812e910c8c548f63a31a35f5","branchLabelMapping":{"^v8.14.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v8.14.0","v8.13.3"],"title":"[Uptime
alerts] Add monitor config id to
context","number":180921,"url":"https://github.com/elastic/kibana/pull/180921","mergeCommit":{"message":"[Uptime
alerts] Add monitor config id to context (#180921)\n\n##
Summary\r\n\r\nThis is needed where users want to generate links to
synthetics monitors\r\nusing uptime alerts !!\r\n\r\n### Example usage
\r\n\r\n<img width=\"625\"
alt=\"image\"\r\nsrc=\"4f2f7833-9313-4c3a-8ea0-a383cb2ec857\">\r\n\r\n\r\n<img
width=\"956\"
alt=\"image\"\r\nsrc=\"10541a9c-987b-427c-a55e-4e0ba01891cf\">","sha":"09cc4ac9a753b41a812e910c8c548f63a31a35f5"}},"sourceBranch":"main","suggestedTargetBranches":["8.13"],"targetPullRequestStates":[{"branch":"main","label":"v8.14.0","branchLabelMappingKey":"^v8.14.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/180921","number":180921,"mergeCommit":{"message":"[Uptime
alerts] Add monitor config id to context (#180921)\n\n##
Summary\r\n\r\nThis is needed where users want to generate links to
synthetics monitors\r\nusing uptime alerts !!\r\n\r\n### Example usage
\r\n\r\n<img width=\"625\"
alt=\"image\"\r\nsrc=\"4f2f7833-9313-4c3a-8ea0-a383cb2ec857\">\r\n\r\n\r\n<img
width=\"956\"
alt=\"image\"\r\nsrc=\"10541a9c-987b-427c-a55e-4e0ba01891cf\">","sha":"09cc4ac9a753b41a812e910c8c548f63a31a35f5"}},{"branch":"8.13","label":"v8.13.3","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Shahzad <shahzad31comp@gmail.com>
This commit is contained in:
Kibana Machine 2024-04-16 18:28:17 -04:00 committed by GitHub
parent ad8cb2e3ed
commit 6a81c1c95e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 22 additions and 0 deletions

View file

@ -279,6 +279,7 @@ describe('status check alert', () => {
Array [
Object {
"checkedAt": "July 6, 2020 9:14 PM",
"configId": undefined,
"currentTriggerStarted": "foo date string",
"firstCheckedAt": "foo date string",
"firstTriggeredAt": "foo date string",
@ -305,6 +306,7 @@ describe('status check alert', () => {
Object {
"alertDetailsUrl": "mockedAlertsLocator > getLocation",
"checkedAt": "July 6, 2020 9:14 PM",
"configId": undefined,
"latestErrorMessage": "error message 1",
"monitorId": "first",
"monitorName": "First",
@ -361,6 +363,7 @@ describe('status check alert', () => {
Array [
Object {
"checkedAt": "July 6, 2020 9:14 PM",
"configId": undefined,
"currentTriggerStarted": "foo date string",
"firstCheckedAt": "foo date string",
"firstTriggeredAt": "foo date string",
@ -387,6 +390,7 @@ describe('status check alert', () => {
Object {
"alertDetailsUrl": "mockedAlertsLocator > getLocation",
"checkedAt": "July 6, 2020 9:14 PM",
"configId": undefined,
"latestErrorMessage": "error message 1",
"monitorId": "first",
"monitorName": "First",
@ -434,6 +438,7 @@ describe('status check alert', () => {
Array [
Object {
"checkedAt": "July 6, 2020 9:14 PM",
"configId": undefined,
"currentTriggerStarted": "7.7 date",
"firstCheckedAt": "7.7 date",
"firstTriggeredAt": "7.7 date",
@ -651,6 +656,7 @@ describe('status check alert', () => {
Array [
Object {
"checkedAt": "July 6, 2020 9:14 PM",
"configId": undefined,
"currentTriggerStarted": "foo date string",
"firstCheckedAt": "foo date string",
"firstTriggeredAt": "foo date string",
@ -845,6 +851,7 @@ describe('status check alert', () => {
Array [
Object {
"checkedAt": "July 6, 2020 9:14 PM",
"configId": undefined,
"currentTriggerStarted": "availability test",
"firstCheckedAt": "availability test",
"firstTriggeredAt": "availability test",
@ -872,6 +879,7 @@ describe('status check alert', () => {
Object {
"alertDetailsUrl": "mockedAlertsLocator > getLocation",
"checkedAt": "July 6, 2020 9:14 PM",
"configId": undefined,
"latestErrorMessage": undefined,
"monitorId": "foo",
"monitorName": "Foo",
@ -889,6 +897,7 @@ describe('status check alert', () => {
Object {
"alertDetailsUrl": "mockedAlertsLocator > getLocation",
"checkedAt": "July 6, 2020 9:14 PM",
"configId": undefined,
"latestErrorMessage": undefined,
"monitorId": "foo",
"monitorName": "Foo",
@ -906,6 +915,7 @@ describe('status check alert', () => {
Object {
"alertDetailsUrl": "mockedAlertsLocator > getLocation",
"checkedAt": "July 6, 2020 9:14 PM",
"configId": undefined,
"latestErrorMessage": undefined,
"monitorId": "unreliable",
"monitorName": "Unreliable",
@ -923,6 +933,7 @@ describe('status check alert', () => {
Object {
"alertDetailsUrl": "mockedAlertsLocator > getLocation",
"checkedAt": "July 6, 2020 9:14 PM",
"configId": undefined,
"latestErrorMessage": undefined,
"monitorId": "no-name",
"monitorName": "no-name",

View file

@ -160,6 +160,7 @@ export const getMonitorSummary = (
checkedAt,
monitorUrl: monitorInfo.url?.full,
monitorId: monitorInfo.monitor?.id,
configId: monitorInfo.config_id,
monitorName: monitorInfo.monitor?.name ?? monitorInfo.monitor?.id,
monitorType: monitorInfo.monitor?.type,
latestErrorMessage: monitorInfo.error?.message,
@ -204,6 +205,7 @@ export const getReasonMessage = ({
export const getMonitorAlertDocument = (monitorSummary: Record<string, string | undefined>) => ({
'monitor.id': monitorSummary.monitorId,
configId: monitorSummary.configId,
'monitor.type': monitorSummary.monitorType,
'monitor.name': monitorSummary.monitorName,
'url.full': monitorSummary.monitorUrl,

View file

@ -23,6 +23,15 @@ export const commonMonitorStateI18 = [
}
),
},
{
name: 'configId',
description: i18n.translate(
'xpack.uptime.alerts.monitorStatus.actionVariables.state.configId',
{
defaultMessage: 'Config ID of the monitor.',
}
),
},
{
name: 'monitorUrl',
description: i18n.translate(