Datadog-如何使用作业定义yaml文件收集Kubernetes作业日志

i2byvkas  于 2023-04-05  发布在  Kubernetes
关注(0)|答案(1)|浏览(149)

我有一个Kubernetes作业定义yaml,我试图通过创建一个单独的服务来将pod日志放入Datadog中,以便更容易过滤数据狗。是否可以在这个作业定义yaml中添加datadog注解,或者必须在pod级别完成?
这是我尝试过的代码块,但它对我不起作用:

apiVersion: batch/v1
kind: Job
metadata:
  name: my-job
  annotations:
    ad.datadoghq.com/kubernetes.logs: '[{"source": "stdout", "service": "my-job"}]'
spec:
  template:
    spec:
      containers:
        - name: my-container
          image: my-image
          command: ["echo", "Hello, world!"]
      restartPolicy: Never

我还将DD_LOGS_ENABLED、DD_LOGS_CONFIG_CONTAINER_COLLECT_ALL、DD_PROXY_HOST等datadog变量作为env变量添加到该文件中

krcsximq

krcsximq1#

注解中的值需要与容器名称匹配。https://docs.datadoghq.com/containers/kubernetes/log/?tab=daemonset#autodiscovery

apiVersion: batch/v1
kind: Job
metadata:
  name: my-job
  annotations:
    ad.datadoghq.com/my-container.logs: '[{"source": "stdout", "service": "my-job"}]'
spec:
  template:
    spec:
      containers:
        - name: my-container
          image: my-image
          command: ["echo", "Hello, world!"]
      restartPolicy: Never

相关问题