forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Synthtrace] Support LogsDb Mode (elastic#190286)
closes [elastic#3757 ](elastic/observability-dev#3757) ## 📝 Summary This PR adds support of `LogsDb` to all current Logs scenarios. To be able to use the newly added flag from CLI: `node scripts/synthtrace degraded_logs.ts --scenarioOpts.logsdb=true` This creates a new `Logsdb` Index template that mimics the default `Logs` one but sets the `mode=logsdb` and matches on index pattern `logs-logsdb.*-*`. ## 🎥 Demo https://github.com/user-attachments/assets/378be9ac-215a-40ca-b57c-3bb9751292b2
- Loading branch information
1 parent
6589cd3
commit 2de0dd6
Showing
13 changed files
with
192 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
packages/kbn-apm-synthtrace/src/lib/logs/custom_logsdb_index_templates.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import type { IndicesPutIndexTemplateRequest } from '@elastic/elasticsearch/lib/api/types'; | ||
|
||
export enum IndexTemplateName { | ||
LogsDb = 'logsdb', | ||
} | ||
|
||
export const indexTemplates: { | ||
[key in IndexTemplateName]: IndicesPutIndexTemplateRequest; | ||
} = { | ||
[IndexTemplateName.LogsDb]: { | ||
name: IndexTemplateName.LogsDb, | ||
_meta: { | ||
managed: false, | ||
description: 'custom logsdb template created by synthtrace tool.', | ||
}, | ||
template: { | ||
settings: { | ||
mode: 'logsdb', | ||
}, | ||
}, | ||
priority: 500, | ||
index_patterns: ['logs-logsdb.*-*'], | ||
composed_of: ['logs@mappings', 'logs@settings', 'ecs@mappings'], | ||
allow_auto_create: true, | ||
data_stream: { | ||
hidden: false, | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
packages/kbn-apm-synthtrace/src/scenarios/helpers/logs_scenario_opts_parser.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
export const parseStringToBoolean = (value: string, defaultValue?: boolean): boolean => { | ||
if (!value) return defaultValue ?? false; | ||
|
||
switch (value.trim().toLowerCase()) { | ||
case 'true': | ||
return true; | ||
case 'false': | ||
return false; | ||
default: | ||
return defaultValue ?? /true/i.test(value); | ||
} | ||
}; | ||
|
||
export interface LogsScenarioOpts { | ||
isLogsDb: boolean; | ||
} | ||
|
||
export const parseLogsScenarioOpts = ( | ||
scenarioOpts: Record<string, any> | undefined | ||
): LogsScenarioOpts => { | ||
const isLogsDb = parseStringToBoolean(scenarioOpts?.logsdb); | ||
|
||
return { | ||
isLogsDb, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.