-
Notifications
You must be signed in to change notification settings - Fork 51
/
common.ts
73 lines (64 loc) · 3.09 KB
/
common.ts
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import { ItemMetadata, ItemProperty, ValueType, getDerivedProperty } from "./types";
// Common K8s properties
export const k8sKeys = ["k8s.node", "k8s.namespace", "k8s.podName", "k8s.containerName"] as const;
export type K8sKey = (typeof k8sKeys)[number];
export const k8sKeyMetadata: ItemMetadata<K8sKey> = {
"k8s.node": { identifier: "node", name: "Node" },
"k8s.namespace": { identifier: "namespace", name: "Namespace" },
"k8s.podName": { identifier: "pod", name: "Pod" },
"k8s.containerName": { identifier: "container", name: "Container" },
};
// Commands
export const commandKeys = ["comm"] as const;
export type CommandKey = (typeof commandKeys)[number];
export const commandKeyMetadata: ItemMetadata<CommandKey> = {
comm: { identifier: "comm", name: "Command" },
};
// Events
export const eventKeys = ["type", "message"] as const;
export type EventKey = (typeof eventKeys)[number];
export const eventKeyMetadata: ItemMetadata<EventKey> = {
type: { identifier: "type", name: "Type" },
message: { identifier: "message", name: "Message" },
};
// Mount namespace
export const mountNsKeys = ["mountnsid"] as const;
export type MountNsKey = (typeof mountNsKeys)[number];
export const mountNsKeyMetadata: ItemMetadata<MountNsKey> = {
mountnsid: { identifier: "mntns", name: "MountNsID" },
};
// Network endpoints
export const networkEndpointKeys = ["src.addr", "src.port", "dst.addr", "dst.port"] as const;
export type NetworkEndpointKey = (typeof networkEndpointKeys)[number];
export const networkEndpointKeyMetadata: ItemMetadata<NetworkEndpointKey> = {
"src.addr": { identifier: "src.addr", name: "SrcAddr" },
"src.port": { identifier: "src.port", name: "SrcPort" },
"dst.addr": { identifier: "dst.addr", name: "DstAddr" },
"dst.port": { identifier: "dst.port", name: "DstPort" },
};
export const derivedNetworkEndpointKeys = ["src", "dst"] as const;
export type DerivedNetworkEndpointKey = (typeof derivedNetworkEndpointKeys)[number];
export const derivedNetworkEndpointProperties: ItemProperty<NetworkEndpointKey | DerivedNetworkEndpointKey>[] = [
getDerivedProperty("Src", "src", (item) => `${item["src.addr"]}:${item["src.port"]}`),
getDerivedProperty("Dst", "dst", (item) => `${item["dst.addr"]}:${item["dst.port"]}`),
];
// Processes/threads
export const processThreadKeys = ["pid", "tid"] as const;
export type ProcessThreadKey = (typeof processThreadKeys)[number];
export const processThreadKeyMetadata: ItemMetadata<ProcessThreadKey> = {
pid: { identifier: "pid", name: "PID" },
tid: { identifier: "tid", name: "TID" },
};
// Timestamp
export const timestampKeys = ["timestamp"] as const;
export type TimestampKey = (typeof timestampKeys)[number];
export const timestampKeyMetadata: ItemMetadata<TimestampKey> = {
timestamp: { identifier: "timestamp", name: "Timestamp", valueType: ValueType.Timestamp },
};
// User/group IDs
export const userKeys = ["uid", "gid"] as const;
export type UserKey = (typeof userKeys)[number];
export const userKeyMetadata: ItemMetadata<UserKey> = {
uid: { identifier: "uid", name: "UID" },
gid: { identifier: "gid", name: "GID" },
};