mirror of
https://github.com/elastic/kibana.git
synced 2025-06-28 19:13:14 -04:00
## Summary Moving synthtrace clients init inside kbn-journeys: esArchiver does not always solve the issue with data generation. We already have afew journeys using Synthtrace instead and expect more to come. In order to simplify the process of creating new journeys, this PR moves Synthtrace client initialisation into kbn-journey package and exposes a way to define client type, generator function & its input arguments: ``` import { Journey, SynthtraceOptions } from '@kbn/journeys'; import { subj } from '@kbn/test-subj-selector'; import { generateApmData } from '../synthtrace_data/apm_data'; export const journey = new Journey({ synthtrace: { type: 'apm', generator: generateApmData, options: { from: new Date(Date.now() - 1000 * 60 * 15), to: new Date(Date.now() + 1000 * 60 * 15), }, }, }) ``` PR also needs review from teams who use Synthtrace to understand if the implementation is matching expectations. --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
37 lines
995 B
TypeScript
37 lines
995 B
TypeScript
/*
|
|
* 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; you may not use this file except in compliance with the Elastic License
|
|
* 2.0.
|
|
*/
|
|
import { infra, timerange } from '@kbn/apm-synthtrace-client';
|
|
|
|
export function generateHostsData({
|
|
from,
|
|
to,
|
|
count = 1,
|
|
}: {
|
|
from: Date;
|
|
to: Date;
|
|
count?: number;
|
|
}) {
|
|
const range = timerange(from.toISOString(), to.toISOString());
|
|
|
|
const hosts = Array(count)
|
|
.fill(0)
|
|
.map((_, idx) => infra.host(`my-host-${idx}`));
|
|
|
|
return range
|
|
.interval('30s')
|
|
.rate(1)
|
|
.generator((timestamp, index) =>
|
|
hosts.flatMap((host) => [
|
|
host.cpu().timestamp(timestamp),
|
|
host.memory().timestamp(timestamp),
|
|
host.network().timestamp(timestamp),
|
|
host.load().timestamp(timestamp),
|
|
host.filesystem().timestamp(timestamp),
|
|
host.diskio().timestamp(timestamp),
|
|
])
|
|
);
|
|
}
|