datadog-agent icon indicating copy to clipboard operation
datadog-agent copied to clipboard

Missing tags on Kubernetes pods logs

Open alsyia opened this issue 6 years ago • 2 comments

Hi!

Getting the status from the agent.

===============
Agent (v7.19.1)
===============

  Status date: 2020-06-03 13:51:47.394758 UTC
  Agent start: 2020-06-03 13:40:08.808290 UTC
  Pid: 1
  Go Version: go1.13.8
  Python Version: 3.8.1
  Build arch: amd64
  Check Runners: 4
  Log Level: INFO

  Paths
  =====
    Config File: /etc/datadog-agent/datadog.yaml
    conf.d: /etc/datadog-agent/conf.d
    checks.d: /etc/datadog-agent/checks.d

  Clocks
  ======
    NTP offset: -640µs
    System UTC time: 2020-06-03 13:51:47.394758 UTC

  Host Info
  =========
    bootTime: 2020-06-02 10:33:12.000000 UTC
    kernelVersion: 4.19.104+
    os: linux
    platform: debian
    platformFamily: debian
    platformVersion: bullseye/sid
    procs: 59
    uptime: 27h7m1s

  Hostnames
  =========
    host_aliases: [REDACTED]
    hostname: REDACTED
    socket-fqdn: datadog-agent-pxvft
    socket-hostname: datadog-agent-pxvft
    host tags: [REDACTED]
    hostname provider: gce
    unused hostname providers:
      configuration/environment: hostname is empty

  Metadata
  ========
    cloud_provider: GCP
    hostname_source: gce

=========
Collector
=========

  Running Checks
  ==============
    
    consul (1.13.0)
    ---------------
      Instance ID: consul:6462fa273fe7c0c8 [OK]
      Configuration Source: file:/etc/datadog-agent/conf.d/consul.d/auto_conf.yaml
      Total Runs: 47
      Metric Samples: Last Run: 1, Total: 47
      Events: Last Run: 0, Total: 0
      Service Checks: Last Run: 2, Total: 97
      Average Execution Time : 12ms
      Last Execution Date : 2020-06-03 13:51:44.000000 UTC
      Last Successful Execution Date : 2020-06-03 13:51:44.000000 UTC
      metadata:
        version.major: 1
        version.minor: 6
        version.patch: 0
        version.raw: 1.6.0
        version.scheme: semver


    cpu
    ---
      Instance ID: cpu [OK]
      Configuration Source: file:/etc/datadog-agent/conf.d/cpu.d/conf.yaml.default
      Total Runs: 46
      Metric Samples: Last Run: 6, Total: 270
      Events: Last Run: 0, Total: 0
      Service Checks: Last Run: 0, Total: 0
      Average Execution Time : 0s
      Last Execution Date : 2020-06-03 13:51:36.000000 UTC
      Last Successful Execution Date : 2020-06-03 13:51:36.000000 UTC
      
    
    disk (2.8.0)
    ------------
      Instance ID: disk:e5dffb8bef24336f [OK]
      Configuration Source: file:/etc/datadog-agent/conf.d/disk.d/conf.yaml.default
      Total Runs: 46
      Metric Samples: Last Run: 486, Total: 22,356
      Events: Last Run: 0, Total: 0
      Service Checks: Last Run: 0, Total: 0
      Average Execution Time : 50ms
      Last Execution Date : 2020-06-03 13:51:43.000000 UTC
      Last Successful Execution Date : 2020-06-03 13:51:43.000000 UTC
      
    
    docker
    ------
      Instance ID: docker [OK]
      Configuration Source: file:/etc/datadog-agent/conf.d/docker.d/conf.yaml.default
      Total Runs: 46
      Metric Samples: Last Run: 1,263, Total: 58,098
      Events: Last Run: 0, Total: 1
      Service Checks: Last Run: 1, Total: 46
      Average Execution Time : 136ms
      Last Execution Date : 2020-06-03 13:51:35.000000 UTC
      Last Successful Execution Date : 2020-06-03 13:51:35.000000 UTC
      
    
    file_handle
    -----------
      Instance ID: file_handle [OK]
      Configuration Source: file:/etc/datadog-agent/conf.d/file_handle.d/conf.yaml.default
      Total Runs: 46
      Metric Samples: Last Run: 5, Total: 230
      Events: Last Run: 0, Total: 0
      Service Checks: Last Run: 0, Total: 0
      Average Execution Time : 0s
      Last Execution Date : 2020-06-03 13:51:42.000000 UTC
      Last Successful Execution Date : 2020-06-03 13:51:42.000000 UTC
      
    
    io
    --
      Instance ID: io [OK]
      Configuration Source: file:/etc/datadog-agent/conf.d/io.d/conf.yaml.default
      Total Runs: 46
      Metric Samples: Last Run: 182, Total: 8,246
      Events: Last Run: 0, Total: 0
      Service Checks: Last Run: 0, Total: 0
      Average Execution Time : 0s
      Last Execution Date : 2020-06-03 13:51:34.000000 UTC
      Last Successful Execution Date : 2020-06-03 13:51:34.000000 UTC
      
    
    kubelet (4.0.0)
    ---------------
      Instance ID: kubelet:d884b5186b651429 [OK]
      Configuration Source: file:/etc/datadog-agent/conf.d/kubelet.d/conf.yaml.default
      Total Runs: 46
      Metric Samples: Last Run: 1,169, Total: 53,993
      Events: Last Run: 0, Total: 0
      Service Checks: Last Run: 4, Total: 184
      Average Execution Time : 487ms
      Last Execution Date : 2020-06-03 13:51:41.000000 UTC
      Last Successful Execution Date : 2020-06-03 13:51:41.000000 UTC
      
    
    load
    ----
      Instance ID: load [OK]
      Configuration Source: file:/etc/datadog-agent/conf.d/load.d/conf.yaml.default
      Total Runs: 46
      Metric Samples: Last Run: 6, Total: 276
      Events: Last Run: 0, Total: 0
      Service Checks: Last Run: 0, Total: 0
      Average Execution Time : 0s
      Last Execution Date : 2020-06-03 13:51:33.000000 UTC
      Last Successful Execution Date : 2020-06-03 13:51:33.000000 UTC
      
    
    memory
    ------
      Instance ID: memory [OK]
      Configuration Source: file:/etc/datadog-agent/conf.d/memory.d/conf.yaml.default
      Total Runs: 46
      Metric Samples: Last Run: 17, Total: 782
      Events: Last Run: 0, Total: 0
      Service Checks: Last Run: 0, Total: 0
      Average Execution Time : 0s
      Last Execution Date : 2020-06-03 13:51:40.000000 UTC
      Last Successful Execution Date : 2020-06-03 13:51:40.000000 UTC
      
    
    network (1.15.1)
    ----------------
      Instance ID: network:e0204ad63d43c949 [OK]
      Configuration Source: file:/etc/datadog-agent/conf.d/network.d/conf.yaml.default
      Total Runs: 47
      Metric Samples: Last Run: 31, Total: 1,457
      Events: Last Run: 0, Total: 0
      Service Checks: Last Run: 0, Total: 0
      Average Execution Time : 2ms
      Last Execution Date : 2020-06-03 13:51:47.000000 UTC
      Last Successful Execution Date : 2020-06-03 13:51:47.000000 UTC
      
    
    ntp
    ---
      Instance ID: ntp:d884b5186b651429 [OK]
      Configuration Source: file:/etc/datadog-agent/conf.d/ntp.d/conf.yaml.default
      Total Runs: 1
      Metric Samples: Last Run: 1, Total: 1
      Events: Last Run: 0, Total: 0
      Service Checks: Last Run: 1, Total: 1
      Average Execution Time : 218ms
      Last Execution Date : 2020-06-03 13:40:14.000000 UTC
      Last Successful Execution Date : 2020-06-03 13:40:14.000000 UTC
      
    
    uptime
    ------
      Instance ID: uptime [OK]
      Configuration Source: file:/etc/datadog-agent/conf.d/uptime.d/conf.yaml.default
      Total Runs: 46
      Metric Samples: Last Run: 1, Total: 46
      Events: Last Run: 0, Total: 0
      Service Checks: Last Run: 0, Total: 0
      Average Execution Time : 0s
      Last Execution Date : 2020-06-03 13:51:39.000000 UTC
      Last Successful Execution Date : 2020-06-03 13:51:39.000000 UTC
      
========
JMXFetch
========

  Initialized checks
  ==================
    no checks
    
  Failed checks
  =============
    no checks
    
=========
Forwarder
=========

  Transactions
  ============
    CheckRunsV1: 46
    Connections: 0
    Containers: 0
    Dropped: 0
    DroppedOnInput: 0
    Events: 0
    HostMetadata: 0
    IntakeV1: 6
    Metadata: 0
    Pods: 0
    Processes: 0
    RTContainers: 0
    RTProcesses: 0
    Requeued: 0
    Retried: 0
    RetryQueueSize: 0
    Series: 0
    ServiceChecks: 0
    SketchSeries: 0
    Success: 98
    TimeseriesV1: 46

  API Keys status
  ===============
    API key ending with REDACTED: API Key valid

==========
Endpoints
==========
  https://app.datadoghq.com - API Key ending with:
      - REDACTED

==========
Logs Agent
==========
    Sending compressed logs in HTTPS to agent-http-intake.logs.datadoghq.com on port 443
    BytesSent: 2.827935e+06
    EncodedBytesSent: 600448
    LogsProcessed: 2517
    LogsSent: 2507

  datadog
  -------
    Type: docker
    Status: OK
    Inputs: 36da04517e510b057d3e3696f8ac9244eb6526f14d959d79f89d007f823e02f2 4657276511e4425725a1d2564a9b22212ca183a40789ecbf0bdb776f6a94f4bc 409e66a8f0ed46257c2e366b7164ffb7565f08fe56e36e065eaf66bb8ec72718 9e8c791051c024a2cc215ba7154b480a5bd7b2f755d07963787c3a61461135ba cbcc042f3e7ca0d715a4732767dc64074ad34175213c8c583988350ced9ee2a0 6d2bbb860c5ea025e44c73c5b6ef428a06a7a80cbab6cf11ed910800fa3970c6 0cd3f9fbba6b3bed4848048f5d91098bb3ad67caabb13a8b669cc76ddc38fbc7 34ee0023b0b4e7e3182ebaa712919f42347ec6bddc38ff6346e096c2e7127c7f 0aff4d998812aea54a7e4daf6629b80c1510127e0d6fff22696a1c8508936a59 9f748f92e22b280777c98ceab18c6c9b4a5fa4f9f4baafef7247bfa225a2a95a 81ff4325bcc261ec485a9c77e9594acb83016edd5f4cc7c04618bf7bea33e180 9c34722b3f54565fd73e04ff1352e8bc4776ac497bc619a959ee6c2b39967f8b fad0316f406ab88ac3c96382fa15a2a86fbb40013a7d9715d3ce0cc20938b416 7870358ec3889c3b968d727ea9e2516fb0d9eda2cabc4878c9b9b1397e1b5433 9dab4cda0c085e53ed1d1e357d5258a4d679f5e4630af4de0947627eff2b522f c22199d606681af5472fc3cb45ef38604cb6686ef572ef81e322b7e7007dfde2 7a9a55201b742257d7e3678b97c1ea4ff994b5c077edfe0afc7c1d0c0036a03a ae434ecdcedc77d9dd7158ffc29399af9a8f0fb156ba93264f24e315dcc1c726 67d20b79728c00d3aa0854a7759629733662bc78776ba6da18e766a85410555a f4e653eac6a47707f8a9ff9f0ae00b07380939077ad7f5d118453890c2b137a2 2b66eddf3490b782686845f358f4549b27ea7e1d134b2d6a3eb4bec8d566cc89 31ff34f770acbb77a301ceda32208a409818d830c73d971e9ddb7e9b9a60d22c 39d6ac90c6645c1eeb49a1b9f3f3efd7c45f5049f2e02d840ff2900516c66c61 512dcbfd04630cfe00fcc5a75476c7c22870277452b1a5ac543c647849c386cc e562c0d5c10adf05071a3b821279551a83f1ea2ee612a198f83d06ffa466dc1f 0479ce1d2db09b1a7d56eb5b579e3a8dd9f418a85416fa9242955f3953ef4281 881f29824b6185edb98fb5b3e0868c2d0be179d202f09207522002475da2cfb7 87c4594109adbaebc91433ae797e78f30c88cd5060a17d108bd030736639ad46 5d6018263c106699000dc6cce7deac4d613853b93cdf8b798e04a3379093df0c 5af6eb6b4b773aeba5849b68743633e4ae0caf7e374b43c9656e389f942d9398 3ca421fcbe37051945f885b9f38666061d1b9a78374b1b1bd89f527943e391b5 868adabe334ae79c8be32b6a3d2cfea23378c8c23ac9bb73373e9fd8fea6e504 a364d7a7097a3f481ceb12e7d2bb4b2d87e1ab0a83416bdcfc978e2eec4123f2 

  docker
  ------
    Type: docker
    Status: OK
    Inputs: aa1423be7d33af38e2ebce11326dda362fc0733d008e9c9efb29d5a43711f910 
    Type: docker
    Status: OK
    Inputs: e01c9d541bc15e2ffb8e7aba8bbe225894ce00a57d5e50f81b8707b3ba29e112 
    Type: docker
    Status: OK
    Inputs: 9be35d646d9f8712cb1f9f0e5c47d12cd8a80db0487bb3f1c35f818561c26662 
    Type: docker
    Status: OK
    Inputs: 5f0116bdac7e6ce4df6c5842a8872b4b0f461d0ece9a775ab69bbdeb63e9b2b0 
    Type: docker
    Status: OK
    Inputs: 7fa35472ede3a33bc53a177d615b4d3e8f0e4e74576f9eaf4ea4d5bacaa2433e 
    Type: docker
    Status: OK
    Inputs: c948edff8e62dc4573764073887c0c1a5a4ce648655faada2961536695539219 


============
System Probe
============
  System Probe is not running:

    Errors
    ======
    error setting up remote system probe util, socket path does not exist: stat /opt/datadog-agent/run/sysprobe.sock: no such file or directory

=========
Aggregator
=========
  Checks Metric Sample: 146,819
  Dogstatsd Metric Sample: 7,842
  Event: 2
  Events Flushed: 2
  Number Of Flushes: 46
  Series Flushed: 125,399
  Service Check: 837
  Service Checks Flushed: 871

=========
DogStatsD
=========
  Event Packets: 0
  Event Parse Errors: 0
  Metric Packets: 7,841
  Metric Parse Errors: 0
  Service Check Packets: 0
  Service Check Parse Errors: 0
  Udp Bytes: 763,449
  Udp Packet Reading Errors: 0
  Udp Packets: 7,842
  Uds Bytes: 0
  Uds Origin Detection Errors: 0
  Uds Packet Reading Errors: 0
  Uds Packets: 0

=====================
Datadog Cluster Agent
=====================

  - Datadog Cluster Agent endpoint detected: https://10.56.2.110:5005
  Successfully connected to the Datadog Cluster Agent.
  - Running: 1.5.2+commit.60ee741

Describe what happened:

Sometimes, the first log lines of a newly created pod managed by a deployment are missing those tags:

  • kube_namespace
  • kube_container_name
  • kube_deployment
  • kube_replica_set
  • pod_name
  • pod_phase
  • display_container_name

The logs emitted after that are correctly tagged.

Studying a pod in particular and setting the agent log level to DEBUG, I could see this in the Agent output: [Date] | CORE | DEBUG | (pkg/autodiscovery/autoconfig.go:125 in checkTagFreshness) | Tags changed for service container_id://[container_id of the pod/container under study], rescheduling associated checks if any

Logs emitted by the pod under study after this log entry from the agent were correctly tagged.

As far as I understand, this log is emitted from here and the check is triggered from here. I see there is a 15s timer between each check, is it possible that the first one gets the tags wrong, but the one after fixes that? (timings look consistent with what we've been observing)

Describe what you expected:

All logs being correctly tagged.

Steps to reproduce the issue:

Frankly, no idea. This does not happen often, ~once for a few hundred pods.

Additional environment details (Operating System, Cloud provider, etc):

It's a GKE cluster.

Is this behaviour expected? Do you think it could be a configuration issue on our side?

Thanks! :)

alsyia avatar Jun 03 '20 14:06 alsyia

Hey @alsyia ,

Sorry that you are encountering this issue on your logs. First of, did you try to setup Kubernetes logs instead getting docker logs? Docs is here: https://docs.datadoghq.com/agent/kubernetes/log/?tab=daemonset#pagetitle This will better work for short lived containers as we will read directly log files produced by Kubernetes, and not stream logs from the docker socket.

For your tag issue, we have seen that in the past and this is most likely due to our internal tagger (embedded in the agent) that does not have the related container/pod tags yet when logs are sent. To make the log agent wait a bit longer for the tagger to be ready, you can use this env var: DD_LOGS_CONFIG_TAGGER_WARMUP_DURATION to set an amount of seconds to wait. Default is 0.

If this does not yield any good results, please open a support ticket by emailing: [email protected] to troubleshoot this further with our support team.

Thank you,

Simon

Simwar avatar Jun 08 '20 15:06 Simwar

Hey,

Thanks for your answer! DD_LOGS_CONFIG_TAGGER_WARMUP_DURATION did the trick for now. There are still some logs incorrectly tagged but a lot less, we probably need to tweak the value. We also added Kubernetes logs setup in our roadmap.

Thanks again! :)

alsyia avatar Jun 12 '20 09:06 alsyia