forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpod.ts
More file actions
54 lines (47 loc) · 1.63 KB
/
pod.ts
File metadata and controls
54 lines (47 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*
* 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", the "GNU Affero General Public License v3.0 only", 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", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
/* eslint-disable max-classes-per-file */
import type { Fields } from '../entity';
import { Entity } from '../entity';
import { Serializable } from '../serializable';
import { k8sContainer } from './k8s_container';
interface PodDocument extends Fields {
'agent.id': string;
'host.hostname': string;
'host.name': string;
'kubernetes.pod.uid': string;
'kubernetes.node.name': string;
'metricset.name'?: string;
'event.module'?: string;
}
export class Pod extends Entity<PodDocument> {
metrics() {
return new PodMetrics({
...this.fields,
'kubernetes.pod.cpu.usage.limit.pct': 46,
});
}
container(id: string) {
return k8sContainer(id, this.fields['kubernetes.pod.uid'], this.fields['kubernetes.node.name']);
}
}
export interface PodMetricsDocument extends PodDocument {
'kubernetes.pod.cpu.usage.limit.pct': number;
}
class PodMetrics extends Serializable<PodMetricsDocument> {}
export function pod(uid: string, nodeName: string) {
return new Pod({
'kubernetes.pod.uid': uid,
'kubernetes.node.name': nodeName,
'agent.id': 'synthtrace',
'host.hostname': nodeName,
'host.name': nodeName,
'event.module': 'kubernetes',
});
}