Import logs using filebeat for a java app running on kubernetes

Hello

I am reading the documentation of now to format and read logs on a Java app that is running in kubernetes here. In this documentation said to enable hint based discovery and add the annotation that are using the logs using ECS loggers. Where exactly I need to add those annotatations since I have added in my Deployments under metadata and did not do anything and then moved them under the templates/metadata and I get the following error when I try to apply the changes: error: error validating "file.yaml": error validating data: ValidationError(Deployment.spec.template.metadata.labels.annotations): invalid type for io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta.labels: got "map", expected "string"; if you choose to ignore these errors, turn validation off with --validate=false

The template section look like this:

...
  template:
    metadata:
      labels:
        app: front
        tier: frontend
        type: webapp
        annotations:
          co.elastic.logs/json.keys_under_root: true
          co.elastic.logs/json.overwrite_keys: true
          co.elastic.logs/json.add_error_key: true
          co.elastic.logs/json.expand_keys: true
    spec:
      securityContext:
        runAsUser: 100
        runAsGroup: 101
        fsGroup: 100    
      containers:
        - name: front
          image: image:tag
          env:
          - name: POD_NAME
            valueFrom:
              fieldRef:
                fieldPath: metadata.name
          - name: NAMESPACE
            valueFrom:
              fieldRef:
                fieldPath: metadata.namespace
...

Thanks for you help in advance.

Figured it out. The annotations has to be on the same level with labels and the true in quotes since it has to be string.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.