-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Log Explorer] Add support for log generation in synthtrace (#170107)
Closes - #170133 ## Summary This PR adds support for generating logs using the Synthtrace Client Changes include 1. Changes to Synthtrace package to support new Logs Client and Log Class for helper methods 2. [Stateful Tests] - Change to our FTR Context config to inject the new the Log Synthtrace Client 3. [Serverless Tests] - Injected Synthtrace as a service for serverless tests. 4. A sample test added to `app.ts` to demonstrate how Synthtrace can be used to generate Log data in both Stateful and Serverless 5. Add support to generate logs via CLI. 2 scenarios added - `simple_logs.ts` and `logs_and_metrics.ts` ``` # Live Data node scripts/synthtrace simple_logs.ts --clean --live # Static Data node scripts/synthtrace simple_logs.ts --clean ``` --------- Co-authored-by: kibanamachine <[email protected]> Co-authored-by: Tiago Costa <[email protected]> Co-authored-by: Yngrid Coello <[email protected]>
- Loading branch information
1 parent
0916894
commit db5176b
Showing
48 changed files
with
1,049 additions
and
309 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
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,77 @@ | ||
/* | ||
* 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 { Fields } from '../entity'; | ||
import { Serializable } from '../serializable'; | ||
|
||
export type LogDocument = Fields & | ||
Partial<{ | ||
'input.type': string; | ||
'log.file.path'?: string; | ||
'service.name'?: string; | ||
'data_stream.namespace': string; | ||
'data_stream.type': string; | ||
'data_stream.dataset': string; | ||
message?: string; | ||
'event.dataset': string; | ||
'log.level'?: string; | ||
'host.name'?: string; | ||
'trace.id'?: string; | ||
'agent.name'?: string; | ||
'orchestrator.cluster.name'?: string; | ||
'orchestrator.cluster.id'?: string; | ||
'orchestrator.resource.id'?: string; | ||
'cloud.provider'?: string; | ||
'cloud.region'?: string; | ||
'cloud.availability_zone'?: string; | ||
'cloud.project.id'?: string; | ||
'cloud.instance.id'?: string; | ||
}>; | ||
|
||
class Log extends Serializable<LogDocument> { | ||
service(name: string) { | ||
this.fields['service.name'] = name; | ||
return this; | ||
} | ||
|
||
namespace(value: string) { | ||
this.fields['data_stream.namespace'] = value; | ||
return this; | ||
} | ||
|
||
dataset(value: string) { | ||
this.fields['data_stream.dataset'] = value; | ||
this.fields['event.dataset'] = value; | ||
return this; | ||
} | ||
|
||
logLevel(level: string) { | ||
this.fields['log.level'] = level; | ||
return this; | ||
} | ||
|
||
message(message: string) { | ||
this.fields.message = message; | ||
return this; | ||
} | ||
} | ||
|
||
function create(): Log { | ||
return new Log({ | ||
'input.type': 'logs', | ||
'data_stream.namespace': 'default', | ||
'data_stream.type': 'logs', | ||
'data_stream.dataset': 'synth', | ||
'event.dataset': 'synth', | ||
'host.name': 'synth-host', | ||
}); | ||
} | ||
|
||
export const log = { | ||
create, | ||
}; |
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
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
31 changes: 31 additions & 0 deletions
31
packages/kbn-apm-synthtrace/src/cli/utils/get_logs_es_client.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,31 @@ | ||
/* | ||
* 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 { Client } from '@elastic/elasticsearch'; | ||
import { LogsSynthtraceEsClient } from '../../lib/logs/logs_synthtrace_es_client'; | ||
import { Logger } from '../../lib/utils/create_logger'; | ||
import { RunOptions } from './parse_run_cli_flags'; | ||
|
||
export function getLogsEsClient({ | ||
target, | ||
logger, | ||
concurrency, | ||
}: Pick<RunOptions, 'concurrency'> & { | ||
target: string; | ||
logger: Logger; | ||
}) { | ||
const client = new Client({ | ||
node: target, | ||
}); | ||
|
||
return new LogsSynthtraceEsClient({ | ||
client, | ||
logger, | ||
concurrency, | ||
}); | ||
} |
Oops, something went wrong.