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

Metricbeat on Kubernetes stores incorrect container.id for pods with multiple containers #34533

Closed
eedugon opened this issue Feb 9, 2023 · 1 comment · Fixed by #34516
Closed
Assignees
Labels
kubernetes Enable builds in the CI for kubernetes Metricbeat Metricbeat needs_team Indicates that the issue/PR needs a Team:* label

Comments

@eedugon
Copy link
Contributor

eedugon commented Feb 9, 2023

Issue reproduced with Metricbeat 8.4.x and 8.5.x.
Kuberenetes: 1.24

The container metricset from kubernetes module is setting wrong container IDs when pods have multiple containers.

For example:
container id duplicate

Both container3 and container4 of the previous example belongs to the same pod, and internally they have different container IDs. But metricbeat for some reason is using the same container.id for all containers of the pod.

Example of POD with multiple containers that can be used to reproduce the issue:

apiVersion: v1
kind: Pod
metadata:
  namespace: default
  name: command-multi-containers-2
  labels:
    purpose: multiple-containers
spec:
  containers:
  - name: container3
    image: endeveit/docker-jq
    env:
    - name: MESSAGE
      value: "field1value|field2value"
    command: ["/bin/sh"]
    args: ["-c", "while true; do echo \"$(date -u +\"%Y-%m-%dT%H:%M:%SZ\")|$MESSAGE container3\"; sleep 10; done"]
  - name: container4
    image: endeveit/docker-jq
    env:
    - name: MESSAGE
      value: "field1value|field2value"
    command: ["/bin/sh"]
    args: ["-c", "while true; do echo \"$(date -u +\"%Y-%m-%dT%H:%M:%SZ\")|$MESSAGE container4\"; sleep 10; done"]
  restartPolicy: OnFailure

This has been reported by some users with Istio enabled (which adds sidecar containers to pods).

Reproducing this is very easy, just configure Metricbeat on Kubernetes with our default manifest suggested here and explore metricbeat data in discover as showed in the screenshot.

@eedugon eedugon added Metricbeat Metricbeat kubernetes Enable builds in the CI for kubernetes labels Feb 9, 2023
@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Feb 9, 2023
@botelastic
Copy link

botelastic bot commented Feb 9, 2023

This issue doesn't have a Team:<team> label.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kubernetes Enable builds in the CI for kubernetes Metricbeat Metricbeat needs_team Indicates that the issue/PR needs a Team:* label
Projects
None yet
2 participants