# Kubernetes/Filebeat - How to Handle JSON Logging for some containers

**URL:** <https://discuss.elastic.co/t/kubernetes-filebeat-how-to-handle-json-logging-for-some-containers/212888>\
**Category:** Beats\
**Tags:** filebeat\
**Created:** [December 23, 2019, 7:11pm UTC](https://discuss.elastic.co/t/kubernetes-filebeat-how-to-handle-json-logging-for-some-containers/212888 "2019-12-23T19:11:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Justin\_Seiser](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/justin_seiser/32/45092_2.png) [@Justin\_Seiser](https://discuss.elastic.co/u/Justin_Seiser)\
**Post date:** [December 23, 2019, 7:11pm UTC](https://discuss.elastic.co/t/kubernetes-filebeat-how-to-handle-json-logging-for-some-containers/212888/1 "2019-12-23T19:11:12Z")

</div>

Hello,

I understand the basic premise, I need to configure auto discover, and then configure different filters within that, to specify how to handle the logs. I have not been able to find a working example.

We have multiple deployments, deployments that log to JSON, have 'logging: json' set as a label, and an annotation. So that should be an easy way to identify, that I need to handle these logs as JSON.

Our current filebeat.yaml

```
setup.dashboards.enabled: true
logging.metrics:
  enabled: false
filebeat.autodiscover:
  providers:
    - type: kubernetes
      host: ${NODE_NAME}
      hints.enabled: true
      hints.default_config:
        type: container
        paths:
          - /var/log/containers/*${data.kubernetes.container.id}.log
        exclude_lines: ["^\\s+[\\-`('.|_]"]
  processors:
    - add_kubernetes_metadata:
    - add_cloud_metadata:

```

Example Log App 1:

`{"time":1577127646.304000000,"level":"INFO","logger":"net.idauto.arms.gmm.import2.GroupImportEngine","thread":"main","message":"Starting the Group Import Engine..."}`

Example Log App 2:  
`{"level":"info","msg":"found role","pod.iam.role":"arn:aws:iam::xxxxxx:role/rolename","pod.ip":"172.21.66.172","time":"2019-12-23T18:58:21Z"}`

Complicated by the fact we run linkerd, so every pod, has a sidecar container, that does not log json

Example Sidecar log:

> INFO [0.002965s] linkerd2\_proxy::app::main using identity service at Name(NameAddr { name: "linkerd-identity.linkerd.svc.cluster.local", port: 8080 })

It would be such a help to our workflow, if we could figure out, how to properly parse/send JSON to our elasticcloud deployment

For the pods that have containers, that do output JSON, we would/could also know the container name ahead of time, if that would help differentiate it from the linkerd-proxy container.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [January 20, 2020, 7:11pm UTC](https://discuss.elastic.co/t/kubernetes-filebeat-how-to-handle-json-logging-for-some-containers/212888/2 "2020-01-20T19:11:19Z")

</div>

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