fluent / fluentd-kubernetes-daemonset

Fluentd daemonset for Kubernetes and it Docker image
Apache License 2.0
1.26k stars 978 forks source link

how to write the fluentd configmap to match the pods I want? #1384

Closed zzfpython closed 1 year ago

zzfpython commented 2 years ago

my configmap is like this: ` # Concatenate multi-line logs <filter **> @id filter_concat @type concat key message multiline_end_regexp /\n$/ separator ""

# match selector pods
<filter kubernetes.**>
  @id filter_log
  @type grep
  <regexp>
    key $.kubernetes.labels.logging
    pattern ^collect$
  </regexp>
</filter>

# Enriches records with Kubernetes metadata
<filter kubernetes.**>
  @id filter_kubernetes_metadata
  @type kubernetes_metadata
  # skip_container_metadata true
  # skip_labels true
  # skip_master_url true
</filter>`

my-app's deployment yaml is like this: apiVersion: apps/v1 kind: Deployment metadata: name: my-app namespace: test labels: logging: collect spec: replicas: 1 selector: matchLabels: app: my-app release: stabel template: metadata: annotations: linkerd.io/inject: enabled labels: app: my-app release: stabel env: test logging: collect

If I delete ` <filter kubernetes.**> @id filter_log @type grep

key $.kubernetes.labels.logging pattern ^collect$
</filter>`

the elasticsearch can find the index I set. But if the configmap has the setting above there is nothing in the es. So can anybody tell me how to write the configmap? I just want to let the fluentd to collect the logs in the pods I selected.

github-actions[bot] commented 1 year ago

This issue has been automatically marked as stale because it has been open 90 days with no activity. Remove stale label or comment or this issue will be closed in 30 days

github-actions[bot] commented 1 year ago

This issue was automatically closed because of stale in 30 days