DataDog / datadog-agent

Main repository for Datadog Agent
https://docs.datadoghq.com/
Apache License 2.0
2.87k stars 1.21k forks source link

[Logging] multiple journald configuration blocks with same input path fails silently #4405

Open jstaffans opened 4 years ago

jstaffans commented 4 years ago

I have two separate configuration blocks for journald logs, because I want to give them separate service tags:

  app1:
    init_config:
    logs:
      - type: journald
        include_units:
          - app1.service
        service: app1
        sourcecategory: internal
        source: go

  app2:
    init_config:
    logs:
      - type: journald
        include_units:
          - app2.service
        service: app2
        sourcecategory: internal
        source: go

Note that we are now falling back to "default" here.

In this scenario, logs from app2 are never collected. datadog-agent status shows:

app2
  ----------
    Type: journald
    IncludeUnits: app2.service
    Status: Pending

As a workaround, I can specify path: /var/log/journal for app2. So it seems that the problem is that you can't have two journald input configurations with the same input path configuration (be it a user-defined path, or default).

datadog-agent version

Agent 6.14.1 - Commit: fa227f0 - Serialization version: 4.12.0 - Go version: go1.12.9
goakley commented 4 years ago

We are seeing the same issue. Is the intention of the journald log driver to only have a single config? If so, that is not mentioned anywhere in the docs and should be called out.

bobvanderlinden commented 4 years ago

We also ran into this issue. Took quite a while to figure out that only the first entry is being picked up. This is especially annoying as we cannot change the source, service and sourcecategory per unit when constrained to using include_units for. a single journald config.

bbayles commented 3 years ago

FYI, you can create a symlink to /var/log/journal and point the path variable at it to make this work for an arbitrary number of services.

ekzhang commented 6 months ago

For anyone coming to this in the future: I was able to resolve this issue in Datadog agent 7.41.0+ (released Dec 2022, see changelog) by following the instructions to add a unique config_id to each journald block:

https://docs.datadoghq.com/integrations/journald/?tab=host#tailing-the-same-journal-multiple-times

logs:
    - type: journald
      config_id: my-app1
      source: my-app1
      service: my-app1
      include_units:
          - my-app1.service

    - type: journald
      config_id: my-app2
      source: my-app2
      service: my-app2
      include_units:
          - my-app2.service