# How to parse CRI logs

**URL:** <https://discuss.elastic.co/t/how-to-parse-cri-logs/309814>\
**Category:** Beats\
**Tags:** filebeat\
**Created:** [July 17, 2022, 10:35am UTC](https://discuss.elastic.co/t/how-to-parse-cri-logs/309814 "2022-07-17T10:35:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![redoran](https://avatars.discourse-cdn.com/v4/letter/r/cab0a1/32.png) [@redoran](https://discuss.elastic.co/u/redoran)\
**Post date:** [July 17, 2022, 10:35am UTC](https://discuss.elastic.co/t/how-to-parse-cri-logs/309814/1 "2022-07-17T10:35:33Z")

</div>

Hello, (sry for my english) I'm trying to parse CRI logs.  
Logs not in JSON format are not parsed.

An example of logs that are parsed correctly  
`2022-07-15T14:50:51.994932036Z stdout F {"@timestamp":"timestamp","@version":2,"message":"any message","logger_name":"any string","thread_name":"thread name","level":"DEBUG","level_value":10000,"traceId":"id","spanId":"id"}`

An example of logs that are not parsed correctly  
`2022-07-15T13:07:50.109703392Z stdout F "any string"`

Config filebeat:

```auto
kubernetes.yml: |-
    - type: container
      id : "*"
      stream: stdout
      format: cri
      cri.parse_flags: true #(I have logs over 16kb)
      enabled: true
      symlinks: true
      ignore_older: 24h
      paths:
        - "/var/log/containers/*.log"
      processors:
        - add_kubernetes_metadata:
            in_cluster: true
            default_matchers.enabled: false
            matchers:
            - logs_path:
                logs_path: /var/log/containers/
        - dissect:
            tokenizer: "%{parsed}"
            field: "message"
            target_prefix: ""
            overwrite_keys: true
            ignore_missing: true
        - drop_fields:
            fields: ["message"]
        - rename:
            fields:
              - from: "parsed"
                to: "message"
            ignore_missing: true
            fail_on_error: false
        - decode_json_fields:
            fields: ['message']
            target: json
            max_depth: 1
            overwrite_keys: true

```

Please tell me what am I doing wrong. Thx

---

<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:** [August 14, 2022, 12:36pm UTC](https://discuss.elastic.co/t/how-to-parse-cri-logs/309814/2 "2022-08-14T12:36:34Z")

</div>

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