-
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
[RCA] [Recent events] Create API endpoint to get events #192947
[RCA] [Recent events] Create API endpoint to get events #192947
Conversation
🤖 GitHub commentsExpand to view the GitHub comments
Just comment with:
|
Pinging @elastic/obs-ux-management-team (Team:obs-ux-management) |
run docs-build |
const response = await unwrapEsResponse( | ||
esClient.search( | ||
{ | ||
index: annotationsClient.index, | ||
body, | ||
}, | ||
{ meta: true } | ||
) | ||
); |
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 think it would make sense to use annotationClient find method here?
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 find method currently doesn't accept host.name
and in future we might also want to support other types of sources. Also, it fetches 10000 documents, I limited it to 100 for now. So it looks like we need to either update find
method or keep our custom implementation. I think current implementation in PR is more flexible as it will support all types of sources without any modifications needed in future. Wdyt?
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 will recommend making the required changes on find method since we own it as well.
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 have updated the find
method to support filter
and size
]); | ||
|
||
if (!alertsIndices || isEmpty(alertsIndices)) { | ||
throw Error('No alert indices exist'); |
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.
Always learning about JS... throw Error()
works as throw new Error()
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 !!
Does it mean for the alerts without group by field, we will not call this API or we will show all alerts in the specified time range? I am trying to understand what alert annotations will be shown when there is no group by field. |
If there is no group by field (and therefore we don't pass anything to filter when calling the API), it will return all alerts that newly triggered in the specified time range. |
💚 Build Succeeded
Metrics [docs]Module Count
Public APIs missing comments
Async chunks
History
To update your PR or re-run it, just comment with: cc @benakansara |
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
Closes elastic/observability-dev#3924 Closes elastic/observability-dev#3927 This PR introduces an events API (`/api/observability/events`) that will fetch - - All the "point in time" annotations from` observability-annotations` index. This includes both manual and auto (e.g. service deployment) annotations - The annotations will be filtered with supported source fields (host.name, service.name, slo.id, slo.instanceId) when specified as `filter` - Alerts that newly triggered on same source in given time range. The source needs to be specified as `filter`, when no filter is specified all alerts triggered in given time range will be returned ### Testing - Create annotations (APM service deployment annotations and annotations using Observability UI) - Generate some alerts - API call should return annotations and alerts, example API requests - `http://localhost:5601/kibana/api/observability/events?rangeFrom=2024-09-01T19:53:20.243Z&rangeTo=2024-09-19T19:53:20.243Z&filter={"annotation.type":"deployment"}` - `http://localhost:5601/kibana/api/observability/events?rangeFrom=2024-09-01T19:53:20.243Z&rangeTo=2024-09-19T19:53:20.243Z&filter={"slo.id":"*"}` - `http://localhost:5601/kibana/api/observability/events?rangeFrom=2024-09-01T19:53:20.243Z&rangeTo=2024-09-19T19:53:20.243Z&filter={"host.name":"host-0"}` - `http://localhost:5601/kibana/api/observability/events?rangeFrom=2024-09-01T19:53:20.243Z&rangeTo=2024-09-19T19:53:20.243Z` --------- Co-authored-by: kibanamachine <[email protected]> (cherry picked from commit 808212e)
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
… (#193463) # Backport This will backport the following commits from `main` to `8.x`: - [[RCA] [Recent events] Create API endpoint to get events (#192947)](#192947) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Bena Kansara","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-09-17T09:50:09Z","message":"[RCA] [Recent events] Create API endpoint to get events (#192947)\n\nCloses https://github.com/elastic/observability-dev/issues/3924\r\nCloses https://github.com/elastic/observability-dev/issues/3927\r\n\r\nThis PR introduces an events API (`/api/observability/events`) that will\r\nfetch -\r\n- All the \"point in time\" annotations from` observability-annotations`\r\nindex. This includes both manual and auto (e.g. service deployment)\r\nannotations\r\n- The annotations will be filtered with supported source fields\r\n(host.name, service.name, slo.id, slo.instanceId) when specified as\r\n`filter`\r\n- Alerts that newly triggered on same source in given time range. The\r\nsource needs to be specified as `filter`, when no filter is specified\r\nall alerts triggered in given time range will be returned\r\n\r\n### Testing\r\n- Create annotations (APM service deployment annotations and annotations\r\nusing Observability UI)\r\n- Generate some alerts\r\n- API call should return annotations and alerts, example API requests\r\n-\r\n`http://localhost:5601/kibana/api/observability/events?rangeFrom=2024-09-01T19:53:20.243Z&rangeTo=2024-09-19T19:53:20.243Z&filter={\"annotation.type\":\"deployment\"}`\r\n-\r\n`http://localhost:5601/kibana/api/observability/events?rangeFrom=2024-09-01T19:53:20.243Z&rangeTo=2024-09-19T19:53:20.243Z&filter={\"slo.id\":\"*\"}`\r\n-\r\n`http://localhost:5601/kibana/api/observability/events?rangeFrom=2024-09-01T19:53:20.243Z&rangeTo=2024-09-19T19:53:20.243Z&filter={\"host.name\":\"host-0\"}`\r\n-\r\n`http://localhost:5601/kibana/api/observability/events?rangeFrom=2024-09-01T19:53:20.243Z&rangeTo=2024-09-19T19:53:20.243Z`\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine <[email protected]>","sha":"808212e97e413216655aaa9e755c671656decb46","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","auto-backport","ci:project-deploy-observability","Team:obs-ux-management","v8.16.0","backport:version"],"title":"[RCA] [Recent events] Create API endpoint to get events","number":192947,"url":"https://github.com/elastic/kibana/pull/192947","mergeCommit":{"message":"[RCA] [Recent events] Create API endpoint to get events (#192947)\n\nCloses https://github.com/elastic/observability-dev/issues/3924\r\nCloses https://github.com/elastic/observability-dev/issues/3927\r\n\r\nThis PR introduces an events API (`/api/observability/events`) that will\r\nfetch -\r\n- All the \"point in time\" annotations from` observability-annotations`\r\nindex. This includes both manual and auto (e.g. service deployment)\r\nannotations\r\n- The annotations will be filtered with supported source fields\r\n(host.name, service.name, slo.id, slo.instanceId) when specified as\r\n`filter`\r\n- Alerts that newly triggered on same source in given time range. The\r\nsource needs to be specified as `filter`, when no filter is specified\r\nall alerts triggered in given time range will be returned\r\n\r\n### Testing\r\n- Create annotations (APM service deployment annotations and annotations\r\nusing Observability UI)\r\n- Generate some alerts\r\n- API call should return annotations and alerts, example API requests\r\n-\r\n`http://localhost:5601/kibana/api/observability/events?rangeFrom=2024-09-01T19:53:20.243Z&rangeTo=2024-09-19T19:53:20.243Z&filter={\"annotation.type\":\"deployment\"}`\r\n-\r\n`http://localhost:5601/kibana/api/observability/events?rangeFrom=2024-09-01T19:53:20.243Z&rangeTo=2024-09-19T19:53:20.243Z&filter={\"slo.id\":\"*\"}`\r\n-\r\n`http://localhost:5601/kibana/api/observability/events?rangeFrom=2024-09-01T19:53:20.243Z&rangeTo=2024-09-19T19:53:20.243Z&filter={\"host.name\":\"host-0\"}`\r\n-\r\n`http://localhost:5601/kibana/api/observability/events?rangeFrom=2024-09-01T19:53:20.243Z&rangeTo=2024-09-19T19:53:20.243Z`\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine <[email protected]>","sha":"808212e97e413216655aaa9e755c671656decb46"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/192947","number":192947,"mergeCommit":{"message":"[RCA] [Recent events] Create API endpoint to get events (#192947)\n\nCloses https://github.com/elastic/observability-dev/issues/3924\r\nCloses https://github.com/elastic/observability-dev/issues/3927\r\n\r\nThis PR introduces an events API (`/api/observability/events`) that will\r\nfetch -\r\n- All the \"point in time\" annotations from` observability-annotations`\r\nindex. This includes both manual and auto (e.g. service deployment)\r\nannotations\r\n- The annotations will be filtered with supported source fields\r\n(host.name, service.name, slo.id, slo.instanceId) when specified as\r\n`filter`\r\n- Alerts that newly triggered on same source in given time range. The\r\nsource needs to be specified as `filter`, when no filter is specified\r\nall alerts triggered in given time range will be returned\r\n\r\n### Testing\r\n- Create annotations (APM service deployment annotations and annotations\r\nusing Observability UI)\r\n- Generate some alerts\r\n- API call should return annotations and alerts, example API requests\r\n-\r\n`http://localhost:5601/kibana/api/observability/events?rangeFrom=2024-09-01T19:53:20.243Z&rangeTo=2024-09-19T19:53:20.243Z&filter={\"annotation.type\":\"deployment\"}`\r\n-\r\n`http://localhost:5601/kibana/api/observability/events?rangeFrom=2024-09-01T19:53:20.243Z&rangeTo=2024-09-19T19:53:20.243Z&filter={\"slo.id\":\"*\"}`\r\n-\r\n`http://localhost:5601/kibana/api/observability/events?rangeFrom=2024-09-01T19:53:20.243Z&rangeTo=2024-09-19T19:53:20.243Z&filter={\"host.name\":\"host-0\"}`\r\n-\r\n`http://localhost:5601/kibana/api/observability/events?rangeFrom=2024-09-01T19:53:20.243Z&rangeTo=2024-09-19T19:53:20.243Z`\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine <[email protected]>","sha":"808212e97e413216655aaa9e755c671656decb46"}},{"branch":"8.x","label":"v8.16.0","branchLabelMappingKey":"^v8.16.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Bena Kansara <[email protected]>
Closes https://github.com/elastic/observability-dev/issues/3924
Closes https://github.com/elastic/observability-dev/issues/3927
This PR introduces an events API (
/api/observability/events
) that will fetch -observability-annotations
index. This includes both manual and auto (e.g. service deployment) annotationsfilter
filter
, when no filter is specified all alerts triggered in given time range will be returnedTesting
http://localhost:5601/kibana/api/observability/events?rangeFrom=2024-09-01T19:53:20.243Z&rangeTo=2024-09-19T19:53:20.243Z&filter={"annotation.type":"deployment"}
http://localhost:5601/kibana/api/observability/events?rangeFrom=2024-09-01T19:53:20.243Z&rangeTo=2024-09-19T19:53:20.243Z&filter={"slo.id":"*"}
http://localhost:5601/kibana/api/observability/events?rangeFrom=2024-09-01T19:53:20.243Z&rangeTo=2024-09-19T19:53:20.243Z&filter={"host.name":"host-0"}
http://localhost:5601/kibana/api/observability/events?rangeFrom=2024-09-01T19:53:20.243Z&rangeTo=2024-09-19T19:53:20.243Z