Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable the configuration of the line delimiter for the json output #8

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

rabam
Copy link

@rabam rabam commented Jun 26, 2015

Hi,

I tried to ship messages to a graylog gelf server over the TCP GELF input. Unfortunately it didn't work because Graylog did not accept the messages logstash was sending, both with NUL delimiters and \n delimiters. Might be a bug in graylog-inputs, not sure.
So I tried to patch the logstash codec and it worked like a charm.
You can now do something like this to use \0 as delimiter:

tcp {
    codec => json_lines {
            line_delimiter => 0
        }
    }
}

I'm not a ruby star so there might be many better ways to do it.
Can you please take a look at it and eventually merge it or provide a similar functionality.
Thank you!

Max

@lennartkoopmann
Copy link

Logstash does not support GELF via TCP AFAIK. Did you try to build TCP GELF manually using logstash JSON encoding and sending via TCP?

@rabam
Copy link
Author

rabam commented Jun 28, 2015

This is exaclty what I did and it works with the patch I provided in the pull request.
By taking the pull request or a similar implementation you can send messages to your graylog server like this:

filter {
  mutate {
    add_field => {
      "version" => "1.1"
      "short_message" => "%{message}"
    }
  }
  ruby {
      code => "event['timestamp'] = '%10.3f' % event['@timestamp'].to_f"
    }


}
output {
  tcp {
    host => "127.0.0.1"
    port => 12201
    codec => json_lines {
               line_delimiter => 0
             }
  }
}

Graylog needs the NUL delimiter. I thought the codec would be a goos place to place it.

@lennartkoopmann
Copy link

Interesting. You basically built GELF TCP support using built-in logstash functionality. Smart!

@rabam
Copy link
Author

rabam commented Jul 9, 2015

Is it possible to integrate the change? I signed the CLA.
Thanks
Max

1 similar comment
@rabam
Copy link
Author

rabam commented Jul 27, 2015

Is it possible to integrate the change? I signed the CLA.
Thanks
Max

@jordansissel
Copy link
Contributor

I like the idea! I'm not sure about the implementation. Can GELF over TCP be compressed? If so, then this patch will not help us move towards compressed-gelf-over-tcp behavior. Though, if gelf-tcp doesn't support compression, then maybe this is ok to modify in the json_lines codec.

Additionally, having the line_delimiter setting be a number feels a bit weird. I understand it's hard to type a null character, but this also prevents folks from using, say, \r\n as the delimiter (is that desirable?).

I'm not requiring any of the above changes, but want to at least discuss them a bit before we move forward if that's ok :)

@jordansissel
Copy link
Contributor

Once we get through that small discussion, It'd be oh so lovely to have some tests to help us keep this behavior functioning in the future :)

@elasticsearch-release
Copy link

Jenkins standing by to test this. If you aren't a maintainer, you can ignore this comment. Someone with commit access, please review this and clear it for Jenkins to run; then say 'jenkins, test it'.

@Hermain
Copy link

Hermain commented Jan 8, 2018

I want to use logstash to receive gelf logs from docker over TCP. Having support for NUL delimiter in json and jsonLines codec would be nice for that

@colinsurprenant
Copy link
Contributor

Very late response I know - I am ok with the addition of a delimiter option but it should be the same as with the line codec see https://github.com/logstash-plugins/logstash-codec-line/blob/802904335a6c1a88dfb968fa42afe51f05e322ae/lib/logstash/codecs/line.rb#L25-L26 and a null delimiter could be specified as "\0".

@rabam are you still around and would you like to make that change?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants