Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

feat(streams): add significant events and queries API #216221

Open
wants to merge 28 commits into
base: main
Choose a base branch
from

Conversation

kdelemme
Copy link
Contributor

@kdelemme kdelemme commented Mar 27, 2025

Summary

Resolves #214374

This PR adds a significant events API that executes the saved queries from the streams and returns the histogram and change points values.
It also adds the upsert, delete and bulk queries API.

@dgieselaar let me know if you want me to clean it up: there are some UI works in there as well but I don't want to mess with your history since your other branch is based on this one...

@kdelemme kdelemme added release_note:skip Skip the PR/issue when compiling release notes backport:version Backport to applied version labels Feature:Streams This is the label for the Streams Project v9.1.0 v8.19.0 labels Mar 27, 2025
@dgieselaar
Copy link
Member

@kdelemme cheers, I think it's fine to remove the UI entirely then I can just diff my changes on top of main

@kdelemme
Copy link
Contributor Author

/ci

kibanamachine and others added 4 commits March 27, 2025 19:27
…t --include-path /api/status --include-path /api/alerting/rule/ --include-path /api/alerting/rules --include-path /api/actions --include-path /api/security/role --include-path /api/spaces --include-path /api/streams --include-path /api/fleet --include-path /api/dashboards --update'
@kdelemme kdelemme marked this pull request as ready for review March 27, 2025 21:00
@kdelemme kdelemme requested review from a team as code owners March 27, 2025 21:00
@kdelemme kdelemme requested a review from a team as a code owner March 27, 2025 21:00
@kdelemme kdelemme requested a review from maximpn March 27, 2025 21:00
return [];
}

const searchRequests = assetQueries.flatMap((asset) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we do this in ESQL instead? Since very recently, CHANGE_POINT is also an ESQL command

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a little too early? I'm not sure if it's available outside of snapshot builds, it has a limit of 1000 values and not sure if we can already group by values (which might not matter for now, but will later). There's also no _msearch equivalent for ES|QL queries. We don't need it, but just a couple of things that make me feel like it's too early.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No strong opinion, but based on the early nature of this app and the way we want to go with ESQL, it might be good to put pressure on it where possible, to highlight problems.

.fetch('DELETE /api/streams/{name}/queries/{queryId} 2023-10-31', {
params: { path: { name: STREAM_NAME, queryId } },
})
.expect(200)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should return a 404, similar to when you delete an index that does not exist

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought we wanted to handle them as a successful noop - will change 👍🏻

data: DataPublicPluginStart;
dataViews: DataViewsPublicPluginStart;
discover?: DiscoverStart;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can probably make this required?

import { createServerRoute } from '../../create_server_route';
import { readSignificantEvents } from './read_significant_events';

const stringToDate = z.string().transform((arg) => new Date(arg));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we have an existing zod type for this?

const stringToDate = z.string().transform((arg) => new Date(arg));

export const readSignificantEventsRoute = createServerRoute({
endpoint: 'GET /api/streams/{name}/significant_events 2023-10-31',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@flash1293 any opinions on making these public vs internal?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question, I'd say public since there is a good use case for people to integrate with this via API (while there isn't really for things like the sample APIs). To me it's basically CRUD

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
automaticImport 726 727 +1
inventory 234 235 +1
securitySolution 7104 7105 +1
streamsApp 424 428 +4
total +7

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
@kbn/storage-adapter 76 75 -1
@kbn/streams-schema 305 326 +21
@kbn/zod-helpers 23 24 +1
streams 13 11 -2
total +19

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
streamsApp 392.0KB 392.5KB +501.0B

Public APIs missing exports

Total count of every type that is part of your API that should be exported but is not. This will cause broken links in the API documentation system. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats exports for more detailed information.

id before after diff
@kbn/streams-schema 3 1 -2
streams 17 24 +7
total +5
Unknown metric groups

API count

id before after diff
@kbn/storage-adapter 77 76 -1
@kbn/streams-schema 309 330 +21
@kbn/zod-helpers 33 34 +1
streams 13 11 -2
total +19

History

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
backport:version Backport to applied version labels Feature:Streams This is the label for the Streams Project release_note:skip Skip the PR/issue when compiling release notes v8.19.0 v9.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Streams] CRUD API for Significant Events
5 participants