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

Added cee formatter. #47

Merged
merged 1 commit into from
Aug 16, 2015
Merged

Added cee formatter. #47

merged 1 commit into from
Aug 16, 2015

Conversation

fireboy1919
Copy link
Contributor

This creates a CEE style formatter which can be used with syslog-ng, and other devices that take logs in CEE format.

I'm using it in conjunction with a service from here: https://apps.sematext.com

With this configuration:

LogStashLogger.configure do | logconfig| 
  logconfig.customize_event do | event|
    event["logsene-app-token"]= ENV['logsene_app_token']
  end
end
config.logger = LogStashLogger.new(type: :tcp, host: 'logsene-receiver-syslog.sematext.com', port: 514)
config.logger.formatter = LogStashLogger::CeeFormatter.new 

It works great.

@dwbutler
Copy link
Owner

Thanks for the contribution!

I'm not opposed to having more formats. However, since this is the LogStashLogger gem, this new format seems to fall out of the scope of "sending log messages to LogStash."

This gem does provide the capability to handle log messages as objects, and to send log messages over various channels. Perhaps the generic bits could be extracted out somehow? Made more pluggable/compose-able, perhaps by extracting out to multiple gems?

Or does it make sense to accept that this gem may be used to send log messages to systems other than LogStash?

@dwbutler
Copy link
Owner

@fireboy1919 Sorry for the long delay. I decided I am going to merge this, and add support for alternative formatters other than the current JSON formatter.

I decided I'm not particularly concerned with whether the official LogStash product accepts all of the output formats produced by this gem. In any case, you can easily transform CEE into JSON by removing the prefix.

dwbutler added a commit that referenced this pull request Aug 16, 2015
@dwbutler dwbutler merged commit 761d6c4 into dwbutler:master Aug 16, 2015
@dwbutler
Copy link
Owner

@fireboy1919 I will need to adapt your formatter to output strict CEE format. Syslog support is planned and will be coming shortly. Once I'm done, it should be possible to use Syslog as a logger type, with CEE as a formatter. (I hope)

@dwbutler
Copy link
Owner

On second thought, I can see you're sending over TCP rather than a local syslog. I'm going to create two separate formatters: Cee, and CeeSyslog.

@dwbutler
Copy link
Owner

CEE support has now been released in version 0.12.0. You can use the following configuration:

config.logger = LogStashLogger.new(
  type: :tcp,
  host: 'logsene-receiver-syslog.sematext.com',
  port: 514,
  formatter: :cee_syslog
)

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.

2 participants