Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[receiver/awscontainerinsightreceiver] Add option for adding container name as a metric label #21411

Closed
wants to merge 7 commits into from

Conversation

sky333999
Copy link
Contributor

Description: Add option for adding container name as a metric label. Currently, the container name tag/label is copied over to the kubernetes blob and there is no way to retain it as a label.
Example:

{
  "AutoScalingGroupName": "eks-cw1-ng-5ec244c0-bedf-d668-e90c-18064cc7c293",
  "ClusterName": "cw_gpu",
  "InstanceId": "i-0e1104896e4b76eb8",
  "InstanceType": "t3.small",
  "Namespace": "kube-system",
  "NodeName": "ip-192-168-228-23.ec2.internal",
  "PodName": "kube-proxy",
  "Sources": [
    "cadvisor",
    "pod",
    "calculated"
  ],
  "Timestamp": "1682460806199",
  "Type": "Container",
  "Version": "0",
  "container_cpu_request": 100,
  "container_cpu_usage_system": 0.2375214653312615,
  "container_cpu_usage_total": 0.44476191624426764,
  "container_cpu_usage_user": 0.1357265516178637,
  "container_cpu_utilization": 0.022238095812213383,
  "container_last_termination_reason": "Unknown",
  "container_memory_cache": 40144896,
  "container_memory_failcnt": 0,
  "container_memory_hierarchical_pgfault": 21.946983396608566,
  "container_memory_hierarchical_pgmajfault": 0,
  "container_memory_mapped_file": 29736960,
  "container_memory_max_usage": 52666368,
  "container_memory_pgfault": 21.946983396608566,
  "container_memory_pgmajfault": 0,
  "container_memory_rss": 9596928,
  "container_memory_swap": 0,
  "container_memory_usage": 50728960,
  "container_memory_utilization": 0.9148512534571693,
  "container_memory_working_set": 18575360,
  "container_status": "Running",
  "kubernetes": {
    "container_name": "kube-proxy",
    "containerd": {
      "container_id": "4837b6e1a389cc04ee5e1352f8b855414c98edbba36c8141e4ec13a20545e8a5"
    },
    "host": "ip-192-168-228-23.ec2.internal",
    "labels": {
      "controller-revision-hash": "5795b88684",
      "k8s-app": "kube-proxy",
      "pod-template-generation": "2"
    },
    "namespace_name": "kube-system",
    "pod_id": "8fd74bbf-be8c-4727-a8ec-d5c25f051b9a",
    "pod_name": "kube-proxy-ph9fp",
    "pod_owners": [
      {
        "owner_kind": "DaemonSet",
        "owner_name": "kube-proxy"
      }
    ]
  }
}

With this change, when set to true, the ContainerName should be retained as a label in the log event.
Example:

{
  "AutoScalingGroupName": "eks-cw1-ng-5ec244c0-bedf-d668-e90c-18064cc7c293",
  "ClusterName": "cw_gpu",
  "ContainerName": "kube-proxy", 
  "InstanceId": "i-0e1104896e4b76eb8",
  "InstanceType": "t3.small",
  "Namespace": "kube-system",
  "NodeName": "ip-192-168-228-23.ec2.internal",
  "PodName": "kube-proxy",
  "Sources": [
    "cadvisor",
    "pod",
    "calculated"
  ],
  "Timestamp": "1682460806199",
  "Type": "Container",
  "Version": "0",
  "container_cpu_request": 100,
  "container_cpu_usage_system": 0.2375214653312615,
  "container_cpu_usage_total": 0.44476191624426764,
  "container_cpu_usage_user": 0.1357265516178637,
  "container_cpu_utilization": 0.022238095812213383,
  "container_last_termination_reason": "Unknown",
  "container_memory_cache": 40144896,
  "container_memory_failcnt": 0,
  "container_memory_hierarchical_pgfault": 21.946983396608566,
  "container_memory_hierarchical_pgmajfault": 0,
  "container_memory_mapped_file": 29736960,
  "container_memory_max_usage": 52666368,
  "container_memory_pgfault": 21.946983396608566,
  "container_memory_pgmajfault": 0,
  "container_memory_rss": 9596928,
  "container_memory_swap": 0,
  "container_memory_usage": 50728960,
  "container_memory_utilization": 0.9148512534571693,
  "container_memory_working_set": 18575360,
  "container_status": "Running",
  "kubernetes": {
    "container_name": "kube-proxy",
    "containerd": {
      "container_id": "4837b6e1a389cc04ee5e1352f8b855414c98edbba36c8141e4ec13a20545e8a5"
    },
    "host": "ip-192-168-228-23.ec2.internal",
    "labels": {
      "controller-revision-hash": "5795b88684",
      "k8s-app": "kube-proxy",
      "pod-template-generation": "2"
    },
    "namespace_name": "kube-system",
    "pod_id": "8fd74bbf-be8c-4727-a8ec-d5c25f051b9a",
    "pod_name": "kube-proxy-ph9fp",
    "pod_owners": [
      {
        "owner_kind": "DaemonSet",
        "owner_name": "kube-proxy"
      }
    ]
  }
}

Testing:

  • Updated unit tests that verify the existence and absence of the ContainerName tag for both cases.
  • Manual integration test with CWA EKS CI in progress.

Documentation: Updated README.md

khanhntd and others added 7 commits April 4, 2023 14:13
Co-authored-by: matianjun1 <mtj334510983@163.com>
* Add support AWS Embedded Metric Format Version 0

* Merge from main
… name (#3)

* Add option to override cluster name
#4)

[receiver/awscontainerinsightreceiver] Parameterize EKS CI leader lock name
Skip flaky test

(cherry picked from commit 14983a6)
Getting 404s when trying to run apt update w/ debian 9

---------

Signed-off-by: Alex Boten <aboten@lightstep.com>
(cherry picked from commit 80069fb)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants