Skip to content

Commit

Permalink
[OnWeek][ObsUX] Add fields to hosts in synthtrace to improve data gen…
Browse files Browse the repository at this point in the history
…eration (elastic#187147)

## Summary

After improving the synthtrace data creation for containers we were able
to add more specific tests for container view, the aim of this spacetime
is to add some improvements to hosts so we can in the future use
synthtrace for testing

### What was done

First I thought that adding `event.dataset` was needed to get the
metadata, or make the request work, as I did for containers, but in
containers was needed not because of the metadata query itself but the
integration check to know if we need to display k8s or docker metrics.
I simplified the scenarios and data generation in the tests, adding the
metadata fields we need in the synthtrace clients for host and docker
and k8s containers, the values of the metadata fields doesn't need to
change for different scenarios, so it's ok to have them set in the
client.
  • Loading branch information
MiriamAparicio authored Jul 3, 2024
1 parent 988795d commit 7274f44
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,13 @@ class DockerContainerMetrics extends Serializable<DockerContainerMetricsDocument
export function dockerContainer(id: string): DockerContainer {
return new DockerContainer({
'container.id': id,
'container.name': `container-${id}`,
'container.runtime': 'docker',
'container.image.name': 'image-1',
'host.name': 'host-1',
'cloud.instance.id': 'instance-1',
'cloud.image.id': 'image-1',
'cloud.provider': 'aws',
'event.dataset': 'docker.container',
});
}
8 changes: 8 additions & 0 deletions packages/kbn-apm-synthtrace-client/src/lib/infra/host.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ interface HostDocument extends Fields {
'metricset.name'?: string;
'event.module'?: string;
'service.name'?: string;
'host.ip'?: string;
'host.os.name'?: string;
'host.os.version'?: string;
'cloud.provider'?: string;
}

class Host extends Entity<HostDocument> {
Expand Down Expand Up @@ -126,5 +130,9 @@ export function host(name: string): Host {
'agent.id': 'synthtrace',
'host.hostname': name,
'host.name': name,
'host.ip': '10.128.0.2',
'host.os.name': 'Linux',
'host.os.version': '4.19.76-linuxkit',
'cloud.provider': 'gcp',
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,13 @@ export function k8sContainer(id: string, uid: string, nodeName: string): K8sCont
'container.id': id,
'kubernetes.pod.uid': uid,
'kubernetes.node.name': nodeName,
'container.name': `container-${id}`,
'container.runtime': 'containerd',
'container.image.name': 'image-1',
'host.name': 'host-1',
'cloud.instance.id': 'instance-1',
'cloud.image.id': 'image-1',
'cloud.provider': 'aws',
'event.dataset': 'kubernetes.container',
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,7 @@ const scenario: Scenario<InfraDocument> = async (runOptions) => {
.fill(0)
.map((_, idx) => {
const id = generateShortId();
return infra.dockerContainer(id).defaults({
'container.name': `container-${idx}`,
'container.id': id,
'container.runtime': 'docker',
'container.image.name': 'image-1',
'host.name': 'host-1',
'cloud.instance.id': 'instance-1',
'cloud.image.id': 'image-1',
'cloud.provider': 'aws',
'event.dataset': 'docker.container',
});
return infra.dockerContainer(id);
});

const containers = range
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,7 @@ const scenario: Scenario<InfraDocument> = async (runOptions) => {
.fill(0)
.map((_, idx) => {
const id = generateShortId();
return infra.k8sContainer(id, `pod-${idx}`, `node-${idx}`).defaults({
'container.id': id,
'kubernetes.pod.uid': `pod-${idx}`,
'kubernetes.node.name': `node-${idx}`,
'container.name': `container-${idx}`,
'container.runtime': 'docker',
'container.image.name': 'image-1',
'host.name': 'host-1',
'cloud.instance.id': 'instance-1',
'cloud.image.id': 'image-1',
'cloud.provider': 'aws',
'event.dataset': 'kubernetes.container',
});
return infra.k8sContainer(id, `pod-${idx}`, `node-${idx}`);
});

const containers = range
Expand Down
14 changes: 1 addition & 13 deletions x-pack/test/functional/apps/infra/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,7 @@ export function generateDockerContainersData({

const containers = Array(count)
.fill(0)
.map((_, idx) =>
infra.dockerContainer(`container-id-${idx}`).defaults({
'container.name': `container-id-${idx}`,
'container.id': `container-id-${idx}`,
'container.runtime': 'docker',
'container.image.name': 'image-1',
'host.name': 'host-1',
'cloud.instance.id': 'instance-1',
'cloud.image.id': 'image-1',
'cloud.provider': 'aws',
'event.dataset': 'docker.container',
})
);
.map((_, idx) => infra.dockerContainer(`container-id-${idx}`));

return range
.interval('30s')
Expand Down

0 comments on commit 7274f44

Please sign in to comment.