[Fleet] Use metering API in serverless#200063
Conversation
|
Pinging @elastic/fleet (Team:Fleet) |
|
@elasticmachine merge upstream |
| }; | ||
|
|
||
| try { | ||
| const useMeteringApi = appContextService.getConfig()?.internal?.useMeteringApi; |
There was a problem hiding this comment.
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.
Unfortunately it's only available in serverless
| ] = await Promise.all([ | ||
| dataStreamService.getAllFleetDataStreams(esClient), | ||
| dataStreamService.getAllFleetDataStreamsStats(esClient), | ||
| useMeteringApi |
There was a problem hiding this comment.
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.
why use asSecondaryAuthUser here?
There was a problem hiding this comment.
The API is only available as internal, and calling it as current user fail for that reason.
juliaElastic
left a comment
There was a problem hiding this comment.
LGTM, added a few questions
azasypkin
left a comment
There was a problem hiding this comment.
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? |
|
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":"nicolas.chaulet@elastic.co"},"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/datastreamsused to power the datastreams tab in fleet to not use_datastreams/_statsin 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