elastic / elastic-integration-corpus-generator-tool

Command line tool used for generating events corpus dynamically given a specific integration
Other
21 stars 12 forks source link

Adding more realistic cpu and memory stats for k8s #126

Closed gizas closed 6 months ago

gizas commented 8 months ago

Context

The Cpu and Memory fields of K8s had hardcoded values in previous templates. This PR tries to generate more realistic values for fields:

Tests

With new templates: For container:

{ "@timestamp": "2023-05-16T23:37:20.132977+02:00", "container":{ "memory":{ "usage": 0.6868230728671094 }, "name":"web", "runtime":"containerd", "cpu":{ "usage": 0.0656370192174762 }, "id":"container-51" }, "kubernetes": { "container":{ "start_time":"2023-05-16T23:37:20.132977+02:00", "memory":{ "rss":{ "bytes": 1176338 }, "majorpagefaults": 113937, "usage":{ "node":{ "pct": 0.6868230728671094 }, "bytes": 1857876, "limit":{ "pct": 0.6868230728671094 } }, "available":{ "bytes": 848118 }, "workingset":{ "bytes": 2140746, "limit":{ "pct": 0.6868230728671094 } }, "pagefaults": "113937" }, "rootfs":{ "inodes":{ "used": 17451 }, "available":{ "bytes": 1491347 }, "used":{ "bytes": 1360185 }, "capacity":{ "bytes": 42772 } }, "name":"web", "cpu":{ "usage":{ "core":{ "ns": 3902476148000 }, "node":{ "pct": 0.0656370192174762 }, "nanocores":117216000, "limit":{ "pct": 0.0656370192174762 } } }, "logs":{ "inodes":{ "count": 67506, "used":5, "free": 73492 }, "available":{ "bytes": 1371945 }, "used":{ "bytes": 1298164 }, "capacity":{ "bytes": 2005313 } } }, "node":{ "uid": "host-0" , "hostname":"host-0", "name":"host-0", "labels":{ "cloud_google_com/machine-family":"e2", "cloud_google_com/gke-nodepool":"kubernetes-scale-nl", "kubernetes_io/hostname":"host-0", "cloud_google_com/gke-os-distribution":"cos", "topology_kubernetes_io/zone":"europe-west1-d", "topology_gke_io/zone":"europe-west1-d", "topology_kubernetes_io/region":"europe-west1", "kubernetes_io/arch":"amd64", "cloud_google_com/gke-cpu-scaling-level":"4", "env":"kubernetes-scale", "failure-domain_beta_kubernetes_io/region":"europe-west1", "cloud_google_com/gke-max-pods-per-node":"110", "cloud_google_com/gke-container-runtime":"containerd", "beta_kubernetes_io/instance-type":"e2-standard-4", "failure-domain_beta_kubernetes_io/zone":"europe-west1-d", "node_kubernetes_io/instance-type":"e2-standard-4", "beta_kubernetes_io/os":"linux", "cloud_google_com/gke-boot-disk":"pd-balanced", "kubernetes_io/os":"linux", "cloud_google_com/private-node":"false", "cloud_google_com/gke-logging-variant":"DEFAULT", "beta_kubernetes_io/arch":"amd64" } }, "pod":{ "uid": "demo-pod-51", "ip":"133.237.37.52", "name":"demo-pod-51", "namespace":"demo-51", "namespace_uid":"demo-51", "replicaset":{ "name":"demo-deployment-51" }, "namespace_labels":{ "kubernetes_io/metadata_name":"demo-51" }, "labels":{ "app":"demo", "pod-template-hash":"51", "app-2":"demo-2", "app-1":"demo-1" }, "deployment":{ "name":"demo-deployment-51" } } }, "cloud": { "provider": "gcp", "availability_zone": "europe-west1-d", "instance":{ "name": "kubernetes-scale-123456" , "id": "12f376ef-5186-4e8b-a175-70f1140a8f30" }, "machine":{ "type":"e2-standard-4" }, "service":{ "name":"GCE" }, "project":{ "id":"elastic-obs-integrations-dev" }, "account":{ "id":"elastic-obs-integrations-dev" } }, "orchestrator":{ "cluster":{ "name":"kubernetes-scale", "url":"https://208.180.150.16" } }, "service":{ "address": "https://kubernetes-scale-123456:10250/stats/summary", "type":"kubernetes" }, "data_stream":{ "namespace":"default", "type":"metrics", "dataset":"kubernetes.container" }, "ecs": { "version": "8.2.0" }, "agent": { "id": "12f376ef-5186-4e8b-a175-70f1140a8f30", "name": "kubernetes-scale-123456" , "type": "metricbeat", "version": "8.7.0", "ephemeral_id": "f94220b0-2ca6-4809-8656-eb478a66c541" }, "elastic_agent": { "id": "12f376ef-5186-4e8b-a175-70f1140a8f30" , "version": "8.7.0", "snapshot": true }, "metricset":{ "period": "10000" , "name":"pod" }, "event":{ "duration": "2030293", "agent_id_status": "verified", "ingested": "2023-05-16T23:37:20.132977+02:00", "module":"kubernetes", "dataset":"kubernetes.container" }, "host":{ "hostname":"host-0", "os":{ "kernel":"5.10.161+", "codename":"focal", "name":"Ubuntu", "type":"linux", "family":"debian", "version":"20.04.5 LTS (Focal Fossa)", "platform":"ubuntu" }, "containerized":false, "name": "host-0", "id": "host-0", "architecture":"x86_64" } }
{ "@timestamp": "2023-05-16T20:37:20.882977+02:00", "container":{ "memory":{ "usage": 0.6881419420386284 }, "name":"kube-state-metrics", "runtime":"containerd", "cpu":{ "usage": 0.0655067446214662 }, "id":"container-1883" }, "kubernetes": { "container":{ "start_time":"2023-05-16T20:37:20.882977+02:00", "memory":{ "rss":{ "bytes": 712195 }, "majorpagefaults": 38907, "usage":{ "node":{ "pct": 0.6881419420386284 }, "bytes": 1962744, "limit":{ "pct": 0.6881419420386284 } }, "available":{ "bytes": 1975702 }, "workingset":{ "bytes": 1486773, "limit":{ "pct": 0.6881419420386284 } }, "pagefaults": "38907" }, "rootfs":{ "inodes":{ "used": 46337 }, "available":{ "bytes": 1645060 }, "used":{ "bytes": 2849330 }, "capacity":{ "bytes": 987350 } }, "name":"kube-state-metrics", "cpu":{ "usage":{ "core":{ "ns": 8037983115000 }, "node":{ "pct": 0.0655067446214662 }, "nanocores":6042716000, "limit":{ "pct": 0.0655067446214662 } } }, "logs":{ "inodes":{ "count": 76069, "used":5, "free": 48659 }, "available":{ "bytes": 2931987 }, "used":{ "bytes": 2508296 }, "capacity":{ "bytes": 1573149 } } }, "node":{ "uid": "host-17" , "hostname":"host-17", "name":"host-17", "labels":{ "cloud_google_com/machine-family":"e2", "cloud_google_com/gke-nodepool":"kubernetes-scale-nl", "kubernetes_io/hostname":"host-17", "cloud_google_com/gke-os-distribution":"cos", "topology_kubernetes_io/zone":"europe-west1-d", "topology_gke_io/zone":"europe-west1-d", "topology_kubernetes_io/region":"europe-west1", "kubernetes_io/arch":"amd64", "cloud_google_com/gke-cpu-scaling-level":"4", "env":"kubernetes-scale", "failure-domain_beta_kubernetes_io/region":"europe-west1", "cloud_google_com/gke-max-pods-per-node":"110", "cloud_google_com/gke-container-runtime":"containerd", "beta_kubernetes_io/instance-type":"e2-standard-4", "failure-domain_beta_kubernetes_io/zone":"europe-west1-d", "node_kubernetes_io/instance-type":"e2-standard-4", "beta_kubernetes_io/os":"linux", "cloud_google_com/gke-boot-disk":"pd-balanced", "kubernetes_io/os":"linux", "cloud_google_com/private-node":"false", "cloud_google_com/gke-logging-variant":"DEFAULT", "beta_kubernetes_io/arch":"amd64" } }, "pod":{ "uid": "demo-pod-1883", "ip":"83.18.103.170", "name":"demo-pod-1883", "namespace":"demo-1883", "namespace_uid":"demo-1883", "replicaset":{ "name":"demo-deployment-1883" }, "namespace_labels":{ "kubernetes_io/metadata_name":"demo-1883" }, "labels":{ "app":"demo", "pod-template-hash":"1883", "app-2":"demo-2", "app-1":"demo-1" }, "deployment":{ "name":"demo-deployment-1883" } } }, "cloud": { "provider": "gcp", "availability_zone": "europe-west1-d", "instance":{ "name": "kubernetes-scale-123456" , "id": "12f376ef-5186-4e8b-a175-70f1140a8f30" }, "machine":{ "type":"e2-standard-4" }, "service":{ "name":"GCE" }, "project":{ "id":"elastic-obs-integrations-dev" }, "account":{ "id":"elastic-obs-integrations-dev" } }, "orchestrator":{ "cluster":{ "name":"kubernetes-scale", "url":"https://101.90.165.171" } }, "service":{ "address": "https://kubernetes-scale-123456:10250/stats/summary", "type":"kubernetes" }, "data_stream":{ "namespace":"default", "type":"metrics", "dataset":"kubernetes.container" }, "ecs": { "version": "8.2.0" }, "agent": { "id": "12f376ef-5186-4e8b-a175-70f1140a8f30", "name": "kubernetes-scale-123456" , "type": "metricbeat", "version": "8.7.0", "ephemeral_id": "f94220b0-2ca6-4809-8656-eb478a66c541" }, "elastic_agent": { "id": "12f376ef-5186-4e8b-a175-70f1140a8f30" , "version": "8.7.0", "snapshot": false }, "metricset":{ "period": "10000" , "name":"pod" }, "event":{ "duration": "2054180", "agent_id_status": "verified", "ingested": "2023-05-16T20:37:20.882977+02:00", "module":"kubernetes", "dataset":"kubernetes.container" }, "host":{ "hostname":"host-17", "os":{ "kernel":"5.10.161+", "codename":"focal", "name":"Ubuntu", "type":"linux", "family":"debian", "version":"20.04.5 LTS (Focal Fossa)", "platform":"ubuntu" }, "containerized":false, "name": "host-17", "id": "host-17", "architecture":"x86_64" } }

For Pod:

{"@timestamp":"2023-05-16T23:38:17.622315+02:00", "container":{ "network":{ "ingress":{ "bytes": 5051 }, "egress":{ "bytes": 3937 } } }, "kubernetes": { "node":{ "uid": "host-84" , "hostname":"host-84", "name":"host-84", "labels":{ "cloud_google_com/machine-family":"e2", "cloud_google_com/gke-nodepool":"kubernetes-scale-nl", "kubernetes_io/hostname":"host-84", "cloud_google_com/gke-os-distribution":"cos", "topology_kubernetes_io/zone":"europe-west1-d", "topology_gke_io/zone":"europe-west1-d", "topology_kubernetes_io/region":"europe-west1", "kubernetes_io/arch":"amd64", "cloud_google_com/gke-cpu-scaling-level":"4", "env":"kubernetes-scale", "failure-domain_beta_kubernetes_io/region":"europe-west1", "cloud_google_com/gke-max-pods-per-node":"110", "cloud_google_com/gke-container-runtime":"containerd", "beta_kubernetes_io/instance-type":"e2-standard-4", "failure-domain_beta_kubernetes_io/zone":"europe-west1-d", "node_kubernetes_io/instance-type":"e2-standard-4", "beta_kubernetes_io/os":"linux", "cloud_google_com/gke-boot-disk":"pd-balanced", "kubernetes_io/os":"linux", "cloud_google_com/private-node":"false", "cloud_google_com/gke-logging-variant":"DEFAULT", "beta_kubernetes_io/arch":"amd64" } }, "pod":{ "uid": "demo-pod-9320", "start_time": "2023-05-16T23:38:17.622315+02:00", "memory":{ "rss":{ "bytes":"1267990" }, "major_page_faults":0, "usage":{ "node":{ "pct": 0.0656370192174762 }, "bytes": "1176338", "limit":{ "pct":0.0656370192174762 } }, "available":{ "bytes":0 }, "page_faults":1386, "working_set":{ "bytes": "1857876", "limit":{ "pct": 0.0656370192174762 } } }, "ip":"42.59.88.239", "name":"demo-pod-9320", "cpu":{ "usage":{ "node":{ "pct":0.1565192547327913 }, "nanocores": 117216000, "limit":{ "pct":0.1565192547327913 } } }, "network":{ "tx":{ "bytes": 3937, "errors":0 }, "rx":{ "bytes": 5051, "errors":0 } } }, "namespace":"demo-9320", "namespace_uid":"demo-9320", "replicaset":{ "name":"demo-deployment-9320" }, "namespace_labels":{ "kubernetes_io/metadata_name":"demo-9320" }, "labels":{ "app":"demo", "pod-template-hash":"9320", "app-2":"demo-2", "app-1":"demo-1" }, "deployment":{ "name":"demo-deployment-9320" } }, "cloud": { "provider": "gcp", "availability_zone": "europe-west1-d", "instance":{ "name": "kubernetes-scale-123456" , "id": "12f376ef-5186-4e8b-a175-70f1140a8f30" }, "machine":{ "type":"e2-standard-4" }, "service":{ "name":"GCE" }, "project":{ "id":"elastic-obs-integrations-dev" }, "account":{ "id":"elastic-obs-integrations-dev" } }, "orchestrator":{ "cluster":{ "name":"kubernetes-scale", "url":"https://96.155.167.131" } }, "service":{ "address": "https://kubernetes-scale-123456:10250/stats/summary", "type":"kubernetes" }, "data_stream":{ "namespace":"default", "type":"metrics", "dataset":"kubernetes.pod" }, "ecs": { "version": "8.2.0" }, "agent": { "id": "12f376ef-5186-4e8b-a175-70f1140a8f30", "name": "kubernetes-scale-123456" , "type": "metricbeat", "version": "8.7.0", "ephemeral_id": "f94220b0-2ca6-4809-8656-eb478a66c541" }, "elastic_agent": { "id": "12f376ef-5186-4e8b-a175-70f1140a8f30" , "version": "8.7.0", "snapshot": true }, "metricset":{ "period": "10000" , "name":"pod" }, "event":{ "duration": "3191769", "agent_id_status": "verified", "ingested": "2023-05-16T23:38:17.622315+02:00", "module":"kubernetes", "dataset":"kubernetes.pod" }, "host":{ "hostname":"host-84", "os":{ "kernel":"5.10.161+", "codename":"focal", "name":"Ubuntu", "type":"linux", "family":"debian", "version":"20.04.5 LTS (Focal Fossa)", "platform":"ubuntu" }, "containerized":false, "name": "host-84", "id": "host-84", "architecture":"x86_64"}}
{"@timestamp":"2023-05-15T15:38:18.069315+02:00", "container":{ "network":{ "ingress":{ "bytes": 11109 }, "egress":{ "bytes": 2072 } } }, "kubernetes": { "node":{ "uid": "host-87" , "hostname":"host-87", "name":"host-87", "labels":{ "cloud_google_com/machine-family":"e2", "cloud_google_com/gke-nodepool":"kubernetes-scale-nl", "kubernetes_io/hostname":"host-87", "cloud_google_com/gke-os-distribution":"cos", "topology_kubernetes_io/zone":"europe-west1-d", "topology_gke_io/zone":"europe-west1-d", "topology_kubernetes_io/region":"europe-west1", "kubernetes_io/arch":"amd64", "cloud_google_com/gke-cpu-scaling-level":"4", "env":"kubernetes-scale", "failure-domain_beta_kubernetes_io/region":"europe-west1", "cloud_google_com/gke-max-pods-per-node":"110", "cloud_google_com/gke-container-runtime":"containerd", "beta_kubernetes_io/instance-type":"e2-standard-4", "failure-domain_beta_kubernetes_io/zone":"europe-west1-d", "node_kubernetes_io/instance-type":"e2-standard-4", "beta_kubernetes_io/os":"linux", "cloud_google_com/gke-boot-disk":"pd-balanced", "kubernetes_io/os":"linux", "cloud_google_com/private-node":"false", "cloud_google_com/gke-logging-variant":"DEFAULT", "beta_kubernetes_io/arch":"amd64" } }, "pod":{ "uid": "demo-pod-9650", "start_time": "2023-05-15T15:38:18.069315+02:00", "memory":{ "rss":{ "bytes":"1435884" }, "major_page_faults":0, "usage":{ "node":{ "pct": 0.0658768142301682 }, "bytes": "1485414", "limit":{ "pct":0.0658768142301682 } }, "available":{ "bytes":0 }, "page_faults":1386, "working_set":{ "bytes": "2408647", "limit":{ "pct": 0.0658768142301682 } } }, "ip":"174.11.72.211", "name":"demo-pod-9650", "cpu":{ "usage":{ "node":{ "pct":0.1568271581049344 }, "nanocores": 3888344000, "limit":{ "pct":0.1568271581049344 } } }, "network":{ "tx":{ "bytes": 2072, "errors":0 }, "rx":{ "bytes": 11109, "errors":0 } } }, "namespace":"demo-9650", "namespace_uid":"demo-9650", "replicaset":{ "name":"demo-deployment-9650" }, "namespace_labels":{ "kubernetes_io/metadata_name":"demo-9650" }, "labels":{ "app":"demo", "pod-template-hash":"9650", "app-2":"demo-2", "app-1":"demo-1" }, "deployment":{ "name":"demo-deployment-9650" } }, "cloud": { "provider": "gcp", "availability_zone": "europe-west1-d", "instance":{ "name": "kubernetes-scale-123456" , "id": "12f376ef-5186-4e8b-a175-70f1140a8f30" }, "machine":{ "type":"e2-standard-4" }, "service":{ "name":"GCE" }, "project":{ "id":"elastic-obs-integrations-dev" }, "account":{ "id":"elastic-obs-integrations-dev" } }, "orchestrator":{ "cluster":{ "name":"kubernetes-scale", "url":"https://45.156.103.220" } }, "service":{ "address": "https://kubernetes-scale-123456:10250/stats/summary", "type":"kubernetes" }, "data_stream":{ "namespace":"default", "type":"metrics", "dataset":"kubernetes.pod" }, "ecs": { "version": "8.2.0" }, "agent": { "id": "12f376ef-5186-4e8b-a175-70f1140a8f30", "name": "kubernetes-scale-123456" , "type": "metricbeat", "version": "8.7.0", "ephemeral_id": "f94220b0-2ca6-4809-8656-eb478a66c541" }, "elastic_agent": { "id": "12f376ef-5186-4e8b-a175-70f1140a8f30" , "version": "8.7.0", "snapshot": false }, "metricset":{ "period": "10000" , "name":"pod" }, "event":{ "duration": "636398", "agent_id_status": "verified", "ingested": "2023-05-15T15:38:18.069315+02:00", "module":"kubernetes", "dataset":"kubernetes.pod" }, "host":{ "hostname":"host-87", "os":{ "kernel":"5.10.161+", "codename":"focal", "name":"Ubuntu", "type":"linux", "family":"debian", "version":"20.04.5 LTS (Focal Fossa)", "platform":"ubuntu" }, "containerized":false, "name": "host-87", "id": "host-87", "architecture":"x86_64"}}
gizas commented 8 months ago

@martijnvg FYI the kubernetes.pod.status.scheduled , kubernetes.pod.status.ready and kubernetes.pod.status.phase belong to kubernetes.state_pod and respectively the kubernetes.container.status.phase belongs to kubernetes.state_container datasets.

The current datasets in the template are for container and pod that come from kubelet and not from kube-state metrics as the above

Screenshots that prove the above Screenshot 2024-01-10 at 1 54 24 PM

Screenshot 2024-01-10 at 1 53 08 PM

martijnvg commented 8 months ago

The current datasets in the template are for container and pod that come from kubelet and not from kube-state metrics as the above

@gizas The reason why I mentioned these fields to you before is that we do have searches using these fields (status_per_pod_* searches). So then I think this searches are targeting the wrong data stream? Currently the it targets the k8s-pod data stream. I think we should either remove these searches or add the kube state data stream back to the track?

ruflin commented 8 months ago

@gizas Why are we adding these here instead of the integration repo?

gizas commented 7 months ago

@martijnvg (as we synced inetrnally) this the visualisation that needs update: Operations file

So either we remove "status_perpod{{name}}", either we can remove just the filters. I will try to see If I can produce one without the filter. I will include this in the next rally track update

@ruflin nw, it is still this time where we housekeep both repos. I will sync with @aspacca and will also update the integrations. Eventually the integrations will be the only source of truth

martijnvg commented 7 months ago

So either we remove "status_perpod{{name}}", either we can remove just the filters. I will try to see If I can produce one without the filter. I will include this in the next rally track update

+1 - If the search doesn't make logical sense without the filters we can remove it.

On Thu, Jan 11, 2024 at 3:52 PM Andrew Gizas @.***> wrote:

@martijnvg https://github.com/martijnvg (as we synced inetrnally) this the visualisation that needs update: Operations file https://github.com/elastic/rally-tracks/blob/master/tsdb_k8s_queries/operations/default.json#L789

So either we remove "status_perpod{{name}}", either we can remove just the filters. I will try to see If I can produce one without the filter. I will include this in the next rally track update

@ruflin https://github.com/ruflin nw, it is still this time where we housekeep both repos. I will sync with @aspacca https://github.com/aspacca and will also update the integrations. Eventually the integrations will be the only source of truth

— Reply to this email directly, view it on GitHub https://github.com/elastic/elastic-integration-corpus-generator-tool/pull/126#issuecomment-1887348924, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAENWRKRT4SCBN22BLUDXGDYN74BNAVCNFSM6AAAAABBU5BQ52VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOBXGM2DQOJSGQ . You are receiving this because you were mentioned.Message ID: <elastic/elastic-integration-corpus-generator-tool/pull/126/c1887348924@ github.com>

gizas commented 7 months ago

@aspacca , @martijnvg can we also merge this as long as the relevant https://github.com/elastic/rally-tracks/pull/551 is already merged? If no objections

gizas commented 7 months ago

@aspacca once you get back I see that my ci tests are failing:

RUN   Test_CardinalityWithTextTemplate
    generator_with_text_template_test.go:57: for type keyword, with template: {"alpha":"{{generate "alpha"}}", "beta":"{{generate "beta"}}"}
    generator_with_text_template_test.go:57: for type integer, with template: {"alpha":{{generate "alpha"}}, "beta":{{generate "beta"}}}
    generator_with_text_template_test.go:124: Expected cardinality of 200 got 116
    generator_with_text_template_test.go:57: for type float, with template: {"alpha":{{generate "alpha"}}, "beta":{{generate "beta"}}}
    generator_with_text_template_test.go:57: for type geo_point, with template: {"alpha":"{{generate "alpha"}}", "beta":"{{generate "beta"}}"}
    generator_with_text_template_test.go:57: for type ip, with template: {"alpha":"{{generate "alpha"}}", "beta":"{{generate "beta"}}"}
    generator_with_text_template_test.go:57: for type date, with template: {"alpha":"{{generate "alpha"}}", "beta":"{{generate "beta"}}"}
--- FAIL: Test_CardinalityWithTextTemplate (1.29s)

Although locally in my pc are successful. Not urgent but let see it once back

aspacca commented 6 months ago

@aspacca once you get back I see that my ci tests are failing:

it seems they are floating tests. I will review once they will pop up again