# Filebeat - Kubernetes - logs in plaintest instead JSON

**URL:** <https://discuss.elastic.co/t/filebeat-kubernetes-logs-in-plaintest-instead-json/194608>\
**Category:** Beats\
**Tags:** filebeat\
**Created:** [August 9, 2019, 12:16pm UTC](https://discuss.elastic.co/t/filebeat-kubernetes-logs-in-plaintest-instead-json/194608 "2019-08-09T12:16:40Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kanthasamyraja](https://avatars.discourse-cdn.com/v4/letter/k/ed655f/32.png) [@Kanthasamyraja](https://discuss.elastic.co/u/Kanthasamyraja)\
**Post date:** [August 9, 2019, 12:16pm UTC](https://discuss.elastic.co/t/filebeat-kubernetes-logs-in-plaintest-instead-json/194608/1 "2019-08-09T12:16:41Z")

</div>

Hi,

I am using 7.1.1 version elastic stack setup. Filebeat running on kubernetes cluster as pod and sending logs to ELK.

I could see all pod logs are in JSON when opening in vi editor.

example

> sudo vi /datavg/docker/containers/7c012dae82f0d9bb8a36b84e861eeaa9f6601fd3e642c7a2e0b34fab0722dc65/7c012dae82f0d9bb8a36b84e861eeaa9f6601fd3e642c7a2e0b34fab0722dc65-json.log

But Kibana shows logs in plaintext.

Filebeat yml file

`\> data:

> kubernetes.yml: |-  
> - type: docker  
> containers.ids:  
> - "\*"  
> processors:  
> - add\_kubernetes\_metadata:  
> in\_cluster: true  
> fields:  
> cluster-name: pes  
> `

Thanks

---

<div class="post-metadata">

**Author:** ![Kanthasamyraja](https://avatars.discourse-cdn.com/v4/letter/k/ed655f/32.png) [@Kanthasamyraja](https://discuss.elastic.co/u/Kanthasamyraja)\
**Post date:** [August 9, 2019, 12:31pm UTC](https://discuss.elastic.co/t/filebeat-kubernetes-logs-in-plaintest-instead-json/194608/2 "2019-08-09T12:31:56Z")

</div>

Tried by adding

```
  json.keys_under_root: true
  json.add_error_key: true

```

but not working

---

<div class="post-metadata">

**Author:** ![kvch](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kvch/32/72058_2.png) [@kvch](https://discuss.elastic.co/u/kvch)\
**Post date:** [August 9, 2019, 3:00pm UTC](https://discuss.elastic.co/t/filebeat-kubernetes-logs-in-plaintest-instead-json/194608/3 "2019-08-09T15:00:47Z")

</div>

Could you please share you configuration and format it using `</>`?

---

<div class="post-metadata">

**Author:** ![Kanthasamyraja](https://avatars.discourse-cdn.com/v4/letter/k/ed655f/32.png) [@Kanthasamyraja](https://discuss.elastic.co/u/Kanthasamyraja)\
**Post date:** [August 10, 2019, 11:51am UTC](https://discuss.elastic.co/t/filebeat-kubernetes-logs-in-plaintest-instead-json/194608/4 "2019-08-10T11:51:01Z")

</div>

Hi

```
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: filebeat-config
  namespace: kube-system
  labels:
    k8s-app: filebeat
data:
  filebeat.yml: |-
    filebeat.registry.file_permissions: 0600
    filebeat.registry.path: /datavg/filebeat/registry
    filebeat.config:
      inputs:
        # Mounted `filebeat-inputs` configmap:
        path: ${path.config}/inputs.d/*.yml
        # Reload inputs configs as they change:
        reload.enabled: false
      modules:
        path: ${path.config}/modules.d/*.yml
        # Reload module configs as they change:
        reload.enabled: false
    # To enable hints based autodiscover, remove `filebeat.config.inputs` configuration and uncomment this:
    # Note the annotations allowed on a pod for customizing filebeat behavior:
    # https://www.elastic.co/guide/en/beats/filebeat/master/configuration-autodiscover-hints.html
    #filebeat.autodiscover:
    # providers:
    # - type: kubernetes
    # hints.enabled: true
    processors:
      - add_cloud_metadata:
    output.logstash:
      hosts: ['${LOGSTASH_HOST}:${LOGSTASH_PORT:5044}']
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: filebeat-inputs
  namespace: kube-system
  labels:
    k8s-app: filebeat
data:
  kubernetes.yml: |-
    - type: docker
      containers.ids:
      - "*"
      processors:
        - add_kubernetes_metadata:
            in_cluster: true
      fields:
        cluster-name: pet
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: logstash-host
  namespace: kube-system
  labels:
    k8s-app: filebeat
data:
  logstash-host: "XXXXXXXXXXXXXXXXXXX"
  #logstash-host: "logstash.default"
  logstash-port: "5044"
---
apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
  name: filebeat
  namespace: kube-system
  labels:
    k8s-app: filebeat
spec:
  template:
    metadata:
      labels:
        k8s-app: filebeat
    spec:
      tolerations:
      - key: node-role.kubernetes.io/master
        effect: NoSchedule
      serviceAccountName: filebeat
      terminationGracePeriodSeconds: 30
      imagePullSecrets:
      - name: dockerregcredkub
      containers:
      - name: filebeat
        image: XXXXXXXXXXXXX/filebeat:7.1.1
        args: [
          "-c", "/etc/filebeat.yml",
          "-e",
        ]
        env:
        - name: LOGSTASH_HOST
          valueFrom:
            configMapKeyRef:
              name: logstash-host
              key: logstash-host
        - name: LOGSTASH_PORT
          valueFrom:
            configMapKeyRef:
              name: logstash-host
              key: logstash-port
        securityContext:
          runAsUser: 0
          # If using Red Hat OpenShift uncomment this:
          #privileged: true
        resources:
          limits:
            memory: 200Mi
          requests:
            cpu: 100m
            memory: 100Mi
        volumeMounts:
        - name: config
          mountPath: /etc/filebeat.yml
          readOnly: true
          subPath: filebeat.yml
        - name: inputs
          mountPath: /usr/share/filebeat/inputs.d
          readOnly: true
        - name: data
          mountPath: /usr/share/filebeat/data
        - name: varlibdockercontainers
          mountPath: /var/lib/docker/containers
          readOnly: true
        - name: datavgdockercontainers
          mountPath: /datavg/docker/containers/
          readOnly: true
        - name: datavgdockerfilebeat
          mountPath: /datavg/filebeat/
          readOnly: false
      volumes:
      - name: config
        configMap:
          defaultMode: 0600
          name: filebeat-config
      - name: varlibdockercontainers
        hostPath:
          path: /datavg/docker/containers/
      - name: datavgdockercontainers
        hostPath:
          path: /datavg/docker/containers/
      - name: datavgdockerfilebeat
        hostPath:
          path: /datavg/filebeat/
      - name: inputs
        configMap:
          defaultMode: 0600
          name: filebeat-inputs
      # data folder stores a registry of read status for all files, so we don't send everything again on a Filebeat pod restart
      - name: data
        hostPath:
          path: /var/lib/filebeat-data
          type: DirectoryOrCreate
      imagePullSecrets:
      - name: dockerregcred
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
  name: filebeat
subjects:
- kind: ServiceAccount
  name: filebeat
  namespace: kube-system
roleRef:
  kind: ClusterRole
  name: filebeat
  apiGroup: rbac.authorization.k8s.io
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRole
metadata:
  name: filebeat
  labels:
    k8s-app: filebeat
rules:
- apiGroups: [""] # "" indicates the core API group
  resources:
  - namespaces
  - pods
  verbs:
  - get
  - watch
  - list
---
apiVersion: v1
kind: ServiceAccount
metadata:
  name: filebeat
  namespace: kube-system
  labels:
    k8s-app: filebeat
---

```

Thanks for checking this.

(I have removed json from yml.)

---

<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:** [September 7, 2019, 12:00pm UTC](https://discuss.elastic.co/t/filebeat-kubernetes-logs-in-plaintest-instead-json/194608/5 "2019-09-07T12:00:33Z")

</div>

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