How Datadog read custom log files in containers kubernetes?

6/15/2020

I have an application running on Kubernetes and this app has log files that I want to stream to datadog log, then set up an alert. Previously, this app run on bare-metal server, I installed datadog agent on that server, and I used custom log collection to retrieve that logs. It worked perfectly well.

Now, I have an obstacle on how to read the log files in the container. I have googled and it said I can use annotations and auto discovery, but I can't see where I am supposed to define the log path.

apiVersion: apps/v1
kind: ReplicaSet
metadata:
  name: cardpayment
spec:
  selector:
    matchLabels:
      app: cardpayment
  template:
    metadata:
      annotations:
        ad.datadoghq.com/cardpayment.logs: >-
          [{
            "source": "java",
            "service": "cardpayment",
            "log_processing_rules": [{
              "type": "exclude_at_match",
              "name": "exclude_datadoghq_users",
              "pattern" : "\\w+@datadoghq.com"
            }]
          }]
      labels:
        app: cardpayment
      name: cardpayment
    spec:
      containers:
        - name: cardpayment
          image: cardpayment:latest

Does anyone have an idea how to resolve this or have a similar case with mine? Thank you in advance.

-- Nicole55
containers
datadog
kubernetes
logging

0 Answers