Skip to content

Commit 24dc9be

Browse files
authored
[9.2] Allow excluding indices on logs status check in observability onboarding (#245324) (#248159)
# Backport This will backport the following commits from `main` to `9.2`: - [Allow excluding indices on logs status check in observability onboarding (#245324)](#245324) <!--- Backport version: 10.2.0 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Michel Losier","email":"michel.losier@elastic.co"},"sourceCommit":{"committedDate":"2026-01-07T16:35:24Z","message":"Allow excluding indices on logs status check in observability onboarding (#245324)\n\nResolves: https://github.com/elastic/kibana/issues/245163\n\n* Updates `LogDataService.getStatus` to receive an option to exclude\nindices from the status check\n* Has Observability LandingPage component provide FLEET_LOG_INDICES to\nexclude from this check\n* Right now that constant just contains the agent_status_change index\nwhich is written to when the fleet server agent comes up.\n\nThis helps resolve the issue of having the landing page redirect to the\nlogging view when this log data is present.","sha":"baafff9adb5a7790618c0bb0fe3b80e4c744ac9c","branchLabelMapping":{"^v9.4.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:Fleet","ci:cloud-deploy","backport:version","v9.3.0","v9.4.0","Team:obs-ux-management","v9.2.4"],"title":"Allow excluding indices on logs status check in observability onboarding","number":245324,"url":"https://github.com/elastic/kibana/pull/245324","mergeCommit":{"message":"Allow excluding indices on logs status check in observability onboarding (#245324)\n\nResolves: https://github.com/elastic/kibana/issues/245163\n\n* Updates `LogDataService.getStatus` to receive an option to exclude\nindices from the status check\n* Has Observability LandingPage component provide FLEET_LOG_INDICES to\nexclude from this check\n* Right now that constant just contains the agent_status_change index\nwhich is written to when the fleet server agent comes up.\n\nThis helps resolve the issue of having the landing page redirect to the\nlogging view when this log data is present.","sha":"baafff9adb5a7790618c0bb0fe3b80e4c744ac9c"}},"sourceBranch":"main","suggestedTargetBranches":["9.3","9.2"],"targetPullRequestStates":[{"branch":"9.3","label":"v9.3.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.4.0","branchLabelMappingKey":"^v9.4.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/245324","number":245324,"mergeCommit":{"message":"Allow excluding indices on logs status check in observability onboarding (#245324)\n\nResolves: https://github.com/elastic/kibana/issues/245163\n\n* Updates `LogDataService.getStatus` to receive an option to exclude\nindices from the status check\n* Has Observability LandingPage component provide FLEET_LOG_INDICES to\nexclude from this check\n* Right now that constant just contains the agent_status_change index\nwhich is written to when the fleet server agent comes up.\n\nThis helps resolve the issue of having the landing page redirect to the\nlogging view when this log data is present.","sha":"baafff9adb5a7790618c0bb0fe3b80e4c744ac9c"}},{"branch":"9.2","label":"v9.2.4","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT-->
1 parent 21de3b7 commit 24dc9be

File tree

13 files changed

+64
-28
lines changed

13 files changed

+64
-28
lines changed

x-pack/platform/plugins/shared/fleet/common/constants/agent.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,10 @@ export const PRIVILEGED_AGENT_KUERY = `not ${AGENTS_PREFIX}.local_metadata.elast
6767

6868
// Kuery to find fips agents
6969
export const FIPS_AGENT_KUERY = `${AGENTS_PREFIX}.local_metadata.elastic.agent.fips: true`;
70+
71+
export const AGENT_STATUS_CHANGE_DATA_STREAM = {
72+
type: 'logs',
73+
dataset: 'elastic_agent.status_change',
74+
namespace: 'default',
75+
};
76+
export const AGENT_STATUS_CHANGE_DATA_STREAM_NAME = `${AGENT_STATUS_CHANGE_DATA_STREAM.type}-${AGENT_STATUS_CHANGE_DATA_STREAM.dataset}-${AGENT_STATUS_CHANGE_DATA_STREAM.namespace}`;

x-pack/platform/plugins/shared/fleet/common/constants/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
* 2.0.
66
*/
77

8+
import { AGENT_STATUS_CHANGE_DATA_STREAM_NAME } from './agent';
9+
810
export { INTEGRATIONS_PLUGIN_ID, PLUGIN_ID } from './plugin';
911
export {
1012
INGEST_SAVED_OBJECT_INDEX,
@@ -65,3 +67,5 @@ export const REQUEST_DIAGNOSTICS_TIMEOUT_MS = 3 * 60 * 60 * 1000; // 3 hours;
6567
export * from './mappings';
6668

6769
export const AUTO_UPGRADE_DEFAULT_RETRIES = ['30m', '1h', '2h', '4h', '8h', '16h', '24h'];
70+
71+
export const FLEET_LOG_INDICES = [AGENT_STATUS_CHANGE_DATA_STREAM_NAME];

x-pack/platform/plugins/shared/fleet/common/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ export {
6565
FLEET_ENROLLMENT_API_PREFIX,
6666
API_VERSIONS,
6767
APP_API_ROUTES,
68+
FLEET_LOG_INDICES,
6869
} from './constants';
6970
export {
7071
// Route services

x-pack/platform/plugins/shared/fleet/cypress/e2e/agents/agent_list.cy.ts

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,14 @@
44
* 2.0; you may not use this file except in compliance with the Elastic License
55
* 2.0.
66
*/
7+
import type { CreateAgentPolicyRequest } from '@kbn/fleet-plugin/common/types';
8+
import { API_VERSIONS } from '@kbn/fleet-plugin/common/constants';
79

810
import { FLEET_AGENT_LIST_PAGE } from '../../screens/fleet';
9-
1011
import { createAgentDoc } from '../../tasks/agents';
1112
import { setupFleetServer } from '../../tasks/fleet_server';
1213
import { deleteAgentDocs, cleanupAgentPolicies } from '../../tasks/cleanup';
13-
import type { CreateAgentPolicyRequest } from '@kbn/fleet-plugin/common/types';
1414
import { setUISettings } from '../../tasks/ui_settings';
15-
16-
import { API_VERSIONS } from '@kbn/fleet-plugin/common/constants';
1715
import { request } from '../../tasks/common';
1816
import { login } from '../../tasks/login';
1917

@@ -208,11 +206,11 @@ describe('View agents list', () => {
208206
describe('Agent status filter', () => {
209207
const clearFilters = () => {
210208
cy.getBySel(FLEET_AGENT_LIST_PAGE.STATUS_FILTER).click();
211-
cy.get('li').contains('Healthy').click();
212-
cy.get('li').contains('Unhealthy').click();
213-
cy.get('li').contains('Updating').click();
214-
cy.get('li').contains('Offline').click();
215-
cy.get('li').contains('Orphaned').click();
209+
cy.get('li').contains('Healthy').click({ force: true });
210+
cy.get('li').contains('Unhealthy').click({ force: true });
211+
cy.get('li').contains('Updating').click({ force: true });
212+
cy.get('li').contains('Offline').click({ force: true });
213+
cy.get('li').contains('Orphaned').click({ force: true });
216214
cy.getBySel(FLEET_AGENT_LIST_PAGE.STATUS_FILTER).click();
217215
cy.wait('@getAgents');
218216
};
@@ -221,7 +219,7 @@ describe('View agents list', () => {
221219
clearFilters();
222220
cy.getBySel(FLEET_AGENT_LIST_PAGE.STATUS_FILTER).click();
223221

224-
cy.get('li').contains('Healthy').click();
222+
cy.get('li').contains('Healthy').click({ force: true });
225223
cy.wait('@getAgents');
226224

227225
assertTableContainsNAgents(18);
@@ -233,7 +231,7 @@ describe('View agents list', () => {
233231
clearFilters();
234232
cy.getBySel(FLEET_AGENT_LIST_PAGE.STATUS_FILTER).click();
235233

236-
cy.get('li').contains('Unhealthy').click();
234+
cy.get('li').contains('Unhealthy').click({ force: true });
237235
cy.wait('@getAgents');
238236

239237
assertTableContainsNAgents(1);
@@ -246,7 +244,7 @@ describe('View agents list', () => {
246244

247245
cy.getBySel(FLEET_AGENT_LIST_PAGE.STATUS_FILTER).click();
248246

249-
cy.get('li').contains('Inactive').click();
247+
cy.get('li').contains('Inactive').click({ force: true });
250248

251249
cy.getBySel(FLEET_AGENT_LIST_PAGE.TABLE).contains('No agents found');
252250
});
@@ -257,8 +255,8 @@ describe('View agents list', () => {
257255

258256
cy.getBySel(FLEET_AGENT_LIST_PAGE.STATUS_FILTER).click();
259257

260-
cy.get('li').contains('Healthy').click();
261-
cy.get('li').contains('Unhealthy').click();
258+
cy.get('li').contains('Healthy').click({ force: true });
259+
cy.get('li').contains('Unhealthy').click({ force: true });
262260
cy.wait('@getAgents');
263261

264262
assertTableContainsNAgents(18);

x-pack/platform/plugins/shared/fleet/server/tasks/agent_status_change_task.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ import { getDeleteTaskRunResult } from '@kbn/task-manager-plugin/server/task';
2020
import type { LoggerFactory, SavedObjectsClientContract } from '@kbn/core/server';
2121
import { errors, type estypes } from '@elastic/elasticsearch';
2222

23+
import {
24+
AGENT_STATUS_CHANGE_DATA_STREAM,
25+
AGENT_STATUS_CHANGE_DATA_STREAM_NAME,
26+
} from '../../common/constants/agent';
2327
import { agentPolicyService, appContextService } from '../services';
2428
import { bulkUpdateAgents, fetchAllAgentsByKuery } from '../services/agents';
2529
import type { Agent } from '../types';
@@ -33,12 +37,6 @@ const SCOPE = ['fleet'];
3337
const DEFAULT_INTERVAL = '1m';
3438
const TIMEOUT = '1m';
3539
const AGENTS_BATCHSIZE = 10000;
36-
const AGENT_STATUS_CHANGE_DATA_STREAM = {
37-
type: 'logs',
38-
dataset: 'elastic_agent.status_change',
39-
namespace: 'default',
40-
};
41-
const AGENT_STATUS_CHANGE_DATA_STREAM_NAME = `${AGENT_STATUS_CHANGE_DATA_STREAM.type}-${AGENT_STATUS_CHANGE_DATA_STREAM.dataset}-${AGENT_STATUS_CHANGE_DATA_STREAM.namespace}`;
4240

4341
export const HAS_CHANGED_RUNTIME_FIELD: estypes.SearchRequest['runtime_mappings'] = {
4442
hasChanged: {

x-pack/platform/plugins/shared/logs_data_access/public/services/log_data_service/log_data_service.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,17 @@ export function createLogDataService(
1515
): LogDataService {
1616
const { logSourcesService, deps } = params;
1717

18-
async function getStatus() {
18+
async function getStatus(opts?: { excludeIndices?: string[] }) {
19+
const excludeLogSourcesIndex = (opts?.excludeIndices ?? [])
20+
.map((index) => `-${index}`)
21+
.join(',');
1922
const logSourcesIndex = await logSourcesService.getFlattenedLogSources();
2023
const status = await lastValueFrom(
2124
deps.search.search({
2225
params: {
2326
ignore_unavailable: true,
2427
allow_no_indices: true,
25-
index: logSourcesIndex,
28+
index: [logSourcesIndex, excludeLogSourcesIndex].join(','),
2629
size: 0,
2730
terminate_after: 1,
2831
track_total_hits: 1,

x-pack/platform/plugins/shared/logs_data_access/public/services/log_data_service/types.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,7 @@
88
export type LogDataStatus = 'available' | 'empty' | 'missing' | 'unknown';
99

1010
export interface LogDataService {
11-
getStatus(): Promise<{ status: LogDataStatus; hasData: boolean }>;
11+
getStatus(opts?: {
12+
excludeIndices?: string[];
13+
}): Promise<{ status: LogDataStatus; hasData: boolean }>;
1214
}

x-pack/solutions/observability/plugins/observability/kibana.jsonc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
"cases",
6666
"data",
6767
"discover",
68+
"fleet",
6869
"logsShared",
6970
"kibanaReact",
7071
"kibanaUtils",

x-pack/solutions/observability/plugins/observability/moon.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ dependsOn:
140140
- '@kbn/core-elasticsearch-server-utils'
141141
- '@kbn/core-http-browser-mocks'
142142
- '@kbn/react-query'
143+
- '@kbn/fleet-plugin'
143144
tags:
144145
- plugin
145146
- prod

x-pack/solutions/observability/plugins/observability/public/pages/landing/landing.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ import React, { useEffect } from 'react';
88
import { LOGS_LOCATOR_ID } from '@kbn/logs-shared-plugin/common';
99
import { OBSERVABILITY_ONBOARDING_LOCATOR } from '@kbn/deeplinks-observability';
1010
import type { SharePublicStart } from '@kbn/share-plugin/public/plugin';
11+
import { FLEET_LOG_INDICES } from '@kbn/fleet-plugin/common';
1112
import { OBSERVABILITY_COMPLETE_LANDING_PAGE_FEATURE } from '../../../common';
1213
import { useHasData } from '../../hooks/use_has_data';
1314
import { useKibana } from '../../utils/kibana_react';
1415
import { APM_APP_LOCATOR_ID } from '../../components/alert_sources/get_apm_app_url';
1516

1617
export function LandingPage() {
1718
const { pricing } = useKibana().services;
18-
1919
const hasCompleteLandingPage = pricing.isFeatureAvailable(
2020
OBSERVABILITY_COMPLETE_LANDING_PAGE_FEATURE.id
2121
);
@@ -34,7 +34,9 @@ function ObservabilityCompleteLandingPage() {
3434
useEffect(() => {
3535
async function redirectToLanding() {
3636
if (isAllRequestsComplete) {
37-
const { hasData: hasLogsData } = await logsDataAccess.services.logDataService.getStatus();
37+
const { hasData: hasLogsData } = await logsDataAccess.services.logDataService.getStatus({
38+
excludeIndices: FLEET_LOG_INDICES,
39+
});
3840
const hasApmData = hasDataMap.apm?.hasData;
3941

4042
const locators = getLocators(share);
@@ -60,7 +62,9 @@ function ObservabilityLogsEssentialsLandingPage() {
6062

6163
useEffect(() => {
6264
async function redirectToLanding() {
63-
const { hasData: hasLogsData } = await logsDataAccess.services.logDataService.getStatus();
65+
const { hasData: hasLogsData } = await logsDataAccess.services.logDataService.getStatus({
66+
excludeIndices: FLEET_LOG_INDICES,
67+
});
6468

6569
const locators = getLocators(share);
6670

0 commit comments

Comments
 (0)