-
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
[Fleet] Use metering API in serverless #200063
[Fleet] Use metering API in serverless #200063
Conversation
Pinging @elastic/fleet (Team:Fleet) |
@elasticmachine merge upstream |
@@ -51,10 +56,22 @@ export const getListHandler: RequestHandler = async (context, request, response) | |||
}; | |||
|
|||
try { | |||
const useMeteringApi = appContextService.getConfig()?.internal?.useMeteringApi; |
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'm wondering if we could use the metering API in stateful too, or is it only for serverless?
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.
Unfortunately it's only available in serverless
dataStreamService.getAllFleetDataStreams(esClient), | ||
dataStreamService.getAllFleetDataStreamsStats(esClient), | ||
useMeteringApi |
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.
nit: we could simplify by moving these out of Promise.all
and await
the dataStreamService
call below in the conditional
? undefined | ||
: dataStreamService.getAllFleetDataStreamsStats(elasticsearch.client.asSecondaryAuthUser), | ||
useMeteringApi | ||
? dataStreamService.getAllFleetMeteringStats(elasticsearch.client.asSecondaryAuthUser) |
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.
why use asSecondaryAuthUser
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 API is only available as internal, and calling it as current user fail for that reason.
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, added a few questions
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.
Config changes LGTM
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.
Changes in config/serverless.yml
LGTM
@elasticmachine merge upstream |
💚 Build Succeeded
Metrics [docs]
History
cc @nchaulet |
@elastic/security-solution can we get some eyes on this please? |
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
cc/ @joeypoon
Starting backport for target branches: 8.x https://github.com/elastic/kibana/actions/runs/11901548609 |
💔 All backports failed
Manual backportTo create the backport manually run:
Questions ?Please refer to the Backport tool documentation |
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
(cherry picked from commit 1fd3f41) # Conflicts: # x-pack/plugins/fleet/server/config.ts
# Backport This will backport the following commits from `main` to `8.x`: - [[Fleet] Use metering API in serverless (#200063)](#200063) <!--- Backport version: 8.9.8 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Nicolas Chaulet","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-11-18T21:36:27Z","message":"[Fleet] Use metering API in serverless (#200063)","sha":"1fd3f412e13ed234524915cc87d058f05b840528","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:skip","Team:Fleet","v9.0.0","backport:prev-minor"],"number":200063,"url":"https://github.com/elastic/kibana/pull/200063","mergeCommit":{"message":"[Fleet] Use metering API in serverless (#200063)","sha":"1fd3f412e13ed234524915cc87d058f05b840528"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","labelRegex":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/200063","number":200063,"mergeCommit":{"message":"[Fleet] Use metering API in serverless (#200063)","sha":"1fd3f412e13ed234524915cc87d058f05b840528"}}]}] BACKPORT-->
Summary
Resolve #198737
Fix the
GET /api/fleet/datastreams
used to power the datastreams tab in fleet to not use_datastreams/_stats
in serverless but the metering API instead.Tests
I added specific test in serverless for that endpoint
And you can test locally by running kibana in serverless and check the datastreams tab is working