Skip to content

Commit

Permalink
[8.16] [Synthetics] Added error track trace to status/tls rule contex…
Browse files Browse the repository at this point in the history
…t variable !! (#198599) (#198671)

# Backport

This will backport the following commits from `main` to `8.16`:
- [[Synthetics] Added error track trace to status/tls rule context
variable !! (#198599)](#198599)

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

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

<!--BACKPORT
[{"author":{"name":"Shahzad","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-11-01T12:55:20Z","message":"[Synthetics]
Added error track trace to status/tls rule context variable !!
(#198599)\n\n## Summary\n\nFixes
https://github.com/elastic/kibana/issues/198593\n\nAdded error track
trace to status/tls rule context variable !!\n\n<img width=\"1725\"
alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/d04fb6f3-7505-4a01-8a6f-b1b27d50ecdd\">","sha":"5544b1a31439cd8e53d431a9b118d1445eeb79a4","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","v9.0.0","ci:project-deploy-observability","Team:obs-ux-management","v8.16.0","backport:version","v8.17.0"],"title":"[Synthetics]
Added error track trace to status/tls rule context variable
!!","number":198599,"url":"https://github.com/elastic/kibana/pull/198599","mergeCommit":{"message":"[Synthetics]
Added error track trace to status/tls rule context variable !!
(#198599)\n\n## Summary\n\nFixes
https://github.com/elastic/kibana/issues/198593\n\nAdded error track
trace to status/tls rule context variable !!\n\n<img width=\"1725\"
alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/d04fb6f3-7505-4a01-8a6f-b1b27d50ecdd\">","sha":"5544b1a31439cd8e53d431a9b118d1445eeb79a4"}},"sourceBranch":"main","suggestedTargetBranches":["8.16","8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/198599","number":198599,"mergeCommit":{"message":"[Synthetics]
Added error track trace to status/tls rule context variable !!
(#198599)\n\n## Summary\n\nFixes
https://github.com/elastic/kibana/issues/198593\n\nAdded error track
trace to status/tls rule context variable !!\n\n<img width=\"1725\"
alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/d04fb6f3-7505-4a01-8a6f-b1b27d50ecdd\">","sha":"5544b1a31439cd8e53d431a9b118d1445eeb79a4"}},{"branch":"8.16","label":"v8.16.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.x","label":"v8.17.0","branchLabelMappingKey":"^v8.17.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Shahzad <[email protected]>
  • Loading branch information
kibanamachine and shahzad31 authored Nov 1, 2024
1 parent 8a52c06 commit 4cf7f33
Show file tree
Hide file tree
Showing 11 changed files with 53 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ const ObservabilityUptimeAlertOptional = rt.partial({
'anomaly.start': schemaDate,
configId: schemaString,
'error.message': schemaString,
'error.stack_trace': schemaString,
'host.name': schemaString,
'kibana.alert.context': schemaUnknown,
'kibana.alert.evaluation.threshold': schemaStringOrNumber,
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export const OBSERVER_NAME = 'observer.name';
export const SERVICE_NAME = 'service.name';
export const OBSERVER_GEO_NAME = 'observer.geo.name';
export const ERROR_MESSAGE = 'error.message';
export const ERROR_STACK_TRACE = 'error.stack_trace';
export const STATE_ID = 'monitor.state.id';

export const CERT_COMMON_NAME = 'tls.server.x509.subject.common_name';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export const getCertsRequestBody = ({
'service',
'labels',
'tags',
'error.message',
'error',
],
collapse: {
field: 'tls.server.hash.sha256',
Expand Down Expand Up @@ -222,6 +222,7 @@ export const processCertsResult = (result: CertificatesResults): CertResult => {
locationId: ping?.observer?.name,
locationName: ping?.observer?.geo?.name,
errorMessage: ping?.error?.message,
errorStackTrace: ping?.error?.stack_trace,
};
});
const total = result.aggregations?.total?.value ?? 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ export const syntheticsRuleFieldMap: FieldMap = {
type: 'text',
required: false,
},
'error.stack_trace': {
type: 'wildcard',
required: false,
},
'agent.name': {
type: 'keyword',
required: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export const CertType = t.intersection([
'@timestamp': t.string,
serviceName: t.string,
errorMessage: t.string,
errorStackTrace: t.union([t.string, t.null]),
labels: t.record(t.string, t.string),
tags: t.array(t.string),
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
AGENT_NAME,
STATE_ID,
SERVICE_NAME,
ERROR_STACK_TRACE,
} from '../../../common/field_names';
import { OverviewPing } from '../../../common/runtime_types';
import { UNNAMED_LOCATION } from '../../../common/constants';
Expand All @@ -42,6 +43,8 @@ export const getMonitorAlertDocument = (
[OBSERVER_GEO_NAME]: locationNames,
[OBSERVER_NAME]: locationIds,
[ERROR_MESSAGE]: monitorSummary.lastErrorMessage,
// done to avoid assigning null to the field
[ERROR_STACK_TRACE]: monitorSummary.lastErrorStack ? monitorSummary.lastErrorStack : undefined,
[AGENT_NAME]: monitorSummary.hostName,
[ALERT_REASON]: monitorSummary.reason,
[STATE_ID]: monitorSummary.stateId,
Expand Down Expand Up @@ -114,7 +117,9 @@ export const getMonitorSummary = ({
monitorId: monitorInfo.monitor?.id,
monitorName,
monitorType: typeToLabelMap[monitorInfo.monitor?.type] || monitorInfo.monitor?.type,
lastErrorMessage: monitorInfo.error?.message!,
lastErrorMessage: monitorInfo.error?.message,
// done to avoid assigning null to the field
lastErrorStack: monitorInfo.error?.stack_trace ? monitorInfo.error?.stack_trace : undefined,
serviceName: monitorInfo.service?.name,
labels: monitorInfo.labels,
locationName: formattedLocationName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export interface MonitorSummaryStatusRule {
};
stateId?: string;
lastErrorMessage?: string;
lastErrorStack?: string | null;
timestamp: string;
labels?: Record<string, string>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
CERT_VALID_NOT_AFTER,
CERT_VALID_NOT_BEFORE,
ERROR_MESSAGE,
ERROR_STACK_TRACE,
MONITOR_ID,
MONITOR_NAME,
MONITOR_TYPE,
Expand Down Expand Up @@ -103,6 +104,7 @@ export const getCertSummary = (cert: Cert, expirationThreshold: number, ageThres
configId: cert.configId,
monitorTags: cert.tags,
errorMessage: cert.errorMessage,
errorStackTrace: cert.errorStackTrace,
labels: cert.labels,
};
};
Expand All @@ -123,6 +125,8 @@ export const getTLSAlertDocument = (cert: Cert, monitorSummary: CertSummary, uui
[OBSERVER_GEO_NAME]: monitorSummary.locationName ? [monitorSummary.locationName] : [],
[OBSERVER_NAME]: monitorSummary.locationId ? [monitorSummary.locationId] : [],
[ERROR_MESSAGE]: monitorSummary.errorMessage,
// done to avoid assigning null to the field
[ERROR_STACK_TRACE]: monitorSummary.errorStackTrace ? monitorSummary.errorStackTrace : undefined,
'location.id': monitorSummary.locationId ? [monitorSummary.locationId] : [],
'location.name': monitorSummary.locationName ? [monitorSummary.locationName] : [],
labels: cert.labels,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,15 @@ export const commonMonitorStateI18: Array<{
}
),
},
{
name: 'lastErrorStack',
description: i18n.translate(
'xpack.synthetics.alertRules.monitorStatus.actionVariables.state.lastErrorStack',
{
defaultMessage: 'Monitor last error stack trace.',
}
),
},
{
name: 'locationName',
description: i18n.translate(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ export const uptimeRuleFieldMap: FieldMap = {
type: 'text',
required: false,
},
'error.stack_trace': {
type: 'wildcard',
required: false,
},
'agent.name': {
type: 'keyword',
required: false,
Expand Down

0 comments on commit 4cf7f33

Please sign in to comment.