-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Actionable Observability] - Add alert annotation and threshold shade on the APM latency chart on the Alert Details page #147848
[Actionable Observability] - Add alert annotation and threshold shade on the APM latency chart on the Alert Details page #147848
Conversation
Pinging @elastic/actionable-observability (Team: Actionable Observability) |
Pinging @elastic/apm-ui (Team:APM) |
x-pack/plugins/apm/public/components/shared/charts/timeseries_chart.tsx
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
I'm not convinced the proposed change is the way to go - do you mind
waiting a few days so we can get a proper review in? Thanks!
Op do 29 dec. 2022 13:23 schreef Miriam ***@***.***>:
… ***@***.**** approved this pull request.
LGTM
—
Reply to this email directly, view it on GitHub
<#147848 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACWDXAUUMGJTPYGBESWXQ3WPV7FPANCNFSM6AAAAAATELTIYA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
@elasticmachine merge upstream |
/* Error Rate */ | ||
|
||
const getLatencyChartAdditionalData = () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since #143298 is merged so I'll add a comment about the following code in this PR:
const transactionTypes = useServiceTransactionTypesFetcher({
serviceName,
start,
end,
});
const transactionType = getTransactionType({
transactionType: String(alert.fields[TRANSACTION_TYPE]),
transactionTypes,
agentName,
});
I don't understand the above code in this context. We don't want to get a default transaction type. We want the actual transaction type that caused the alert. The transaction type is optional when creating a rule but required on alerts. This means that if the transaction type is not specified for a rule, the rule executor will do a terms agg on transaction.type
to ensure an alert is always associated with the correct transaction type. See:
Line 179 in 2e15fb5
{ field: TRANSACTION_TYPE }, |
tldr: I think the above code is redundant. Get the transaction type from the alert. If the alert doesn't have a transaction type we cannot show the chart (I don't think that's likely to happen anymore but it may have happened to alerts in the past).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the same vain, why is this needed?
const latencyAggregationType = getAggsTypeFromRule(params.aggregationType);
params.aggregationType
is of type LatencyAggregationType
and the returned value is LatencyAggregationType
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This also looks incorrect:
const environment = String(params.environment) || ENVIRONMENT_ALL.value;
environment
(like transaction.type
) is required on the alert (optional on the rule).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the same vain, why is this needed?
const latencyAggregationType = getAggsTypeFromRule(params.aggregationType);
params.aggregationType is of type LatencyAggregationType and the returned value is LatencyAggregationType.
@sqren. Good catch. However, we still need the function getAggsTypeFromRule
.
The issue is in AlertDetailsAppSectionProps
type. The aggregationType
is not LatencyAggregationType
because it returns 95th
and 99th
instead of p95
and p99
.
export interface AlertDetailsAppSectionProps {
rule: Rule<{
environment: string;
aggregationType: LatencyAggregationType;
windowSize: number;
windowUnit: TIME_UNITS;
}>;
alert: TopAlert<{ [SERVICE_NAME]: string; [TRANSACTION_TYPE]: string }>;
timeZone: string;
}
It should beaggregationType: string;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sqren, regarding the transactionType
in https://github.com/elastic/kibana/pull/147848/files#r1062460375
I don't know the workflow and how it should be implemented.
I followed the same steps in the APMServiceContext to get the tansactionType
const transactionTypes = useServiceTransactionTypesFetcher({
serviceName,
start,
end,
});
const currentTransactionType = getOrRedirectToTransactionType({
transactionType: query.transactionType,
transactionTypes,
agentName,
history,
});
The only difference is that I'm using getTransactionType
instead of getOrRedirectToTransactionType
as I don't need/have access to the history
argument because it's part of APM context
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sqren, for the environment
const environment = String(params.environment) || ENVIRONMENT_ALL.value;
It's the rule environment, and it was addressed in this thread #143298 (comment)
We want to display the latency chart for an alert so the user can understand why an alert fired, right? In that case, we should get the environment from the alert - not the rule.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We want to display the latency chart for an alert so the user can understand why an alert fired, right? In that case, we should get the environment from the alert - not the rule.
@sqren, you are right. I updated it. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW, the alert env is fetched from the rule in the createLifecycleRuleType
with some null-checks. But still getting the env from the alert is better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still see
const transactionType = getTransactionType({
transactionType: String(alert.fields[TRANSACTION_TYPE]),
transactionTypes,
agentName,
});
This should be changed to:
const transactionType = alert.fields[TRANSACTION_TYPE];
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
...ic/components/alerting/ui_components/alert_details_app_section/alert_details_app_section.tsx
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The annotation stuff lgtm. But I have some concerns about some of the existing code.
{showAnnotations && ( | ||
<LineAnnotation | ||
id="annotations" | ||
domainType={AnnotationDomainType.XDomain} | ||
dataValues={annotations.map((annotation) => ({ | ||
dataValue: annotation['@timestamp'], | ||
header: asAbsoluteDateTime(annotation['@timestamp']), | ||
details: `${i18n.translate('xpack.apm.chart.annotation.version', { | ||
defaultMessage: 'Version', | ||
})} ${annotation.text}`, | ||
}))} | ||
style={{ | ||
line: { strokeWidth: 1, stroke: annotationColor, opacity: 1 }, | ||
}} | ||
marker={<EuiIcon type="dot" color={annotationColor} />} | ||
markerPosition={Position.Top} | ||
/> | ||
)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't quite wrap my head around whether moving this to the context works out. But it's probably fine.
@elasticmachine merge upstream |
💛 Build succeeded, but was flaky
Failed CI StepsTest Failures
Metrics [docs]Module Count
Async chunks
Page load bundle
History
To update your PR or re-run it, just comment with: cc @fkanout |
Summary
Closes #147779 by adding the following elements to the latency chart for the Latency threshold alert: