Skip to content

separator not working for pretty json #122

@llermaly

Description

@llermaly

Problem

I'm trying to parse pretty print JSON logs. Each file will contain an exact json object.

It works if I set the flush interval option, but I wonder why separator "" doesnt work.

Example log:

{
       "foo":"bar"
}
<source>
  @type tail
  tag vte.errorlogffa
  path /tmp/tm-logs/*
  read_from_head true
  <parse>
    @type none
  </parse>
</source>

<filter vte.errorlogffa>
  @type concat
  key message
  multiline_start_regexp /^{/
  multiline_end_regexp /^}/
  #flush_interval 5s
  separator ""
</filter>

<filter vte.errorlogffa>
  @type parser
  format json
  key_name message
</filter>

<match vte.errorlogffa>
  @type elasticsearch
  host elasticsearch
  port 9200
  index_name tm-errorlog-000001
  reconnect_on_error true
  <buffer>
    flush_thread_count 2
    flush_interval 1s
  </buffer>
</match>

This code throws:

2023-09-21 22:20:34 2023-09-22 03:20:34 +0000 [warn]: #0 dump an error event: error_class=Fluent::Plugin::Parser::ParserError error="pattern not matched with data '{  \"date\" ...

What I'm doing wrong?

Thanks
...

Steps to replicate

Provide example config and message

Expected Behavior

...

Your environment

  • OS version
  • paste result of fluentd --version or td-agent --version
  • plugin version
    • paste boot log of fluentd or td-agent
    • paste result of fluent-gem list, td-agent-gem list or your Gemfile.lock

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions