[8.8] [Fleet] Datastreams api do not query warm nodes anymore (#160234) (#160254)

# Backport

This will backport the following commits from `main` to `8.8`:
- [[Fleet] Datastreams api do not query warm nodes anymore
(#160234)](https://github.com/elastic/kibana/pull/160234)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Cristina
Amico","email":"criamico@users.noreply.github.com"},"sourceCommit":{"committedDate":"2023-06-22T10:38:50Z","message":"[Fleet]
Datastreams api do not query warm nodes anymore (#160234)\n\nFixes
https://github.com/elastic/kibana/issues/159977\r\n\r\n##
Summary\r\n\r\nIn https://github.com/elastic/kibana/pull/159253/files we
removed cold\r\nnodes from datastreams apis because of performance
issues. Now we are\r\nalso removing warm nodes as they were still
causing high
load.","sha":"924da11c89955b6c5e7acf6bbb8c6dcd5f2f499e","branchLabelMapping":{"^v8.9.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:Fleet","v8.9.0","v8.8.2"],"number":160234,"url":"https://github.com/elastic/kibana/pull/160234","mergeCommit":{"message":"[Fleet]
Datastreams api do not query warm nodes anymore (#160234)\n\nFixes
https://github.com/elastic/kibana/issues/159977\r\n\r\n##
Summary\r\n\r\nIn https://github.com/elastic/kibana/pull/159253/files we
removed cold\r\nnodes from datastreams apis because of performance
issues. Now we are\r\nalso removing warm nodes as they were still
causing high
load.","sha":"924da11c89955b6c5e7acf6bbb8c6dcd5f2f499e"}},"sourceBranch":"main","suggestedTargetBranches":["8.8"],"targetPullRequestStates":[{"branch":"main","label":"v8.9.0","labelRegex":"^v8.9.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/160234","number":160234,"mergeCommit":{"message":"[Fleet]
Datastreams api do not query warm nodes anymore (#160234)\n\nFixes
https://github.com/elastic/kibana/issues/159977\r\n\r\n##
Summary\r\n\r\nIn https://github.com/elastic/kibana/pull/159253/files we
removed cold\r\nnodes from datastreams apis because of performance
issues. Now we are\r\nalso removing warm nodes as they were still
causing high
load.","sha":"924da11c89955b6c5e7acf6bbb8c6dcd5f2f499e"}},{"branch":"8.8","label":"v8.8.2","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Cristina Amico <criamico@users.noreply.github.com>
This commit is contained in:
Kibana Machine 2023-06-22 09:55:04 -04:00 committed by GitHub
parent db8521641e
commit 3888dc0309
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 3 deletions

View file

@ -47,3 +47,7 @@ export const FLEET_SERVER_INDICES = [
'.fleet-policies-leader',
FLEET_SERVER_SERVERS_INDEX,
];
// Nodes that can be queried by datastreams API
// Warm and cold nodes have been excluded because of performance issues
export const DATA_TIERS = ['data_hot'];

View file

@ -6,6 +6,8 @@
*/
import type { ElasticsearchClient } from '@kbn/core/server';
import { DATA_TIERS } from '../../../common/constants';
export async function getDataStreamsQueryMetadata({
dataStreamName,
esClient,
@ -15,7 +17,7 @@ export async function getDataStreamsQueryMetadata({
}) {
const termsEnumIndexFilter = {
terms: {
_tier: ['data_hot', 'data_warm'],
_tier: DATA_TIERS,
},
};

View file

@ -9,6 +9,7 @@ import type { ElasticsearchClient } from '@kbn/core/server';
import type { Agent } from '../../types';
import { appContextService } from '../app_context';
import { DATA_TIERS } from '../../../common/constants';
export async function fetchAndAssignAgentMetrics(esClient: ElasticsearchClient, agents: Agent[]) {
try {
@ -72,7 +73,7 @@ const aggregationQueryBuilder = (agentIds: string[]) => ({
must: [
{
terms: {
_tier: ['data_hot', 'data_warm'],
_tier: DATA_TIERS,
},
},
{
@ -166,7 +167,7 @@ const aggregationQueryBuilder = (agentIds: string[]) => ({
},
script: {
source: `if (params.cpu_total > 0) {
return params.cpu_total / params._interval
return params.cpu_total / params._interval
}
`,
lang: 'painless',