GithubHelp home page GithubHelp logo

logstash-output-riemann's Introduction

Logstash Plugin

Travis Build Status

This is a plugin for Logstash.

It is fully free and fully open source. The license is Apache 2.0, meaning you are pretty much free to use it however you want in whatever way.

Documentation

Logstash provides infrastructure to automatically generate documentation for this plugin. We use the asciidoc format to write documentation so any comments in the source code will be first converted into asciidoc and then into html. All plugin documentation are placed under one central location.

Need Help?

Need help? Try #logstash on freenode IRC or the https://discuss.elastic.co/c/logstash discussion forum.

Developing

1. Plugin Developement and Testing

Code

  • To get started, you'll need JRuby with the Bundler gem installed.

  • Create a new plugin or clone and existing from the GitHub logstash-plugins organization. We also provide example plugins.

  • Install dependencies

bundle install

Test

  • Update your dependencies
bundle install
  • Run tests
bundle exec rspec

2. Running your unpublished Plugin in Logstash

2.1 Run in a local Logstash clone

  • Edit Logstash Gemfile and add the local plugin path, for example:
gem "logstash-filter-awesome", :path => "/your/local/logstash-filter-awesome"
  • Install plugin
# Logstash 2.3 and higher
bin/logstash-plugin install --no-verify

# Prior to Logstash 2.3
bin/plugin install --no-verify
  • Run Logstash with your plugin
bin/logstash -e 'filter {awesome {}}'

At this point any modifications to the plugin code will be applied to this local Logstash setup. After modifying the plugin, simply rerun Logstash.

2.2 Run in an installed Logstash

You can use the same 2.1 method to run your plugin in an installed Logstash by editing its Gemfile and pointing the :path to your local plugin development directory or you can build the gem and install it using:

  • Build your plugin gem
gem build logstash-filter-awesome.gemspec
  • Install the plugin from the Logstash home
# Logstash 2.3 and higher
bin/logstash-plugin install --no-verify

# Prior to Logstash 2.3
bin/plugin install --no-verify
  • Start Logstash and proceed to test the plugin

Contributing

All contributions are welcome: ideas, patches, documentation, bug reports, complaints, and even something you drew up on a napkin.

Programming is not a required skill. Whatever you've seen about open source and maintainers or community members saying "send patches or die" - you will not see that here.

It is more important to the community that you are able to contribute.

For more information about contributing, see the CONTRIBUTING file.

logstash-output-riemann's People

Contributors

colinsurprenant avatar electrical avatar jakelandis avatar jarpy avatar jhitze avatar jordansissel avatar jsvd avatar karenzone avatar kurtado avatar nukemberg avatar ph avatar robbavey avatar yaauie avatar ycombinator avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

logstash-output-riemann's Issues

Publish 2.0.3 to rubygems

It would be very helpful to have version 2.0.3 of this plugin available on Rubygems so we don't need to do anything complicated to pull in the latest released version.

NoMethodError

NoMethodError: undefined method `each' for #LogStash::Event:0x6255eda6
map_fields at /home/hmaxwell/conversion-hekad-config/logstash/logstash/vendor/bundle/jruby/1.9/gems/logstash-output-riemann-0.1.1/lib/logstash/outputs/riemann.rb:111
receive at /home/hmaxwell/conversion-hekad-config/logstash/logstash/vendor/bundle/jruby/1.9/gems/logstash-output-riemann-0.1.1/lib/logstash/outputs/riemann.rb:145
handle at /home/hmaxwell/conversion-hekad-config/logstash/logstash/lib/logstash/outputs/base.rb:86
initialize at (eval):28
call at org/jruby/RubyProc.java:271
output at /home/hmaxwell/conversion-hekad-config/logstash/logstash/lib/logstash/pipeline.rb:272
outputworker at /home/hmaxwell/conversion-hekad-config/logstash/logstash/lib/logstash/pipeline.rb:231
start_outputs at /home/hmaxwell/conversion-hekad-config/logstash/logstash/lib/logstash/pipeline.rb:160

Error- couldn't find any output plugin named riemann

I have installed logstash-output-riemann plugin normally in my logstash. I followed the same installation process which I did to install other plugins(gem). I have checked the gem folder of my logstash , I can see the logstash-output-riemann folder with corresponding files. I am facing this issue in my Linux box, it was working fine in windows machine.

My config will looks like below:
input {
courier {
port => 10544
transport=>"tcp"

}

}

filter{
...
...
}
output{
if [type] == "error" {
riemann{
host=>localhost
riemann_event => {
"service"=> "system_log"
"description"=> "%{name.systemName}"
"metric" => "%{metric}"
"ttl" => "%{ttl}"
}
}
}

I am getting below error,

Couldn't find any output plugin named 'riemann'. Are you sure this is correct? Trying to load the riemann output plugin resulted in this error: no such file to load -- logstash/outputs/riemann

Java Arraylists do not play well with beefcake

Logstash seems to be sending [tags] as a Java ArrayList. Beefcake tries to do a 'compact' on it, assuming it's a Ruby Array, and throws an unknown method exception.

/opt/logstash/vendor/bundle/jruby/1.9/gems/beefcake-1.1.0/lib/beefcake.rb:114:in `encode!',
 /opt/logstash/vendor/bundle/jruby/1.9/gems/beefcake-1.1.0/lib/beefcake.rb:103:in `encode',
 org/jruby/RubyArray.java:1613:in `each',
 /opt/logstash/vendor/bundle/jruby/1.9/gems/beefcake-1.1.0/lib/beefcake.rb:96:in `encode',
 /opt/logstash/vendor/bundle/jruby/1.9/gems/beefcake-1.1.0/lib/beefcake.rb:118:in `encode!',
 org/jruby/RubyArray.java:1613:in `each',
 /opt/logstash/vendor/bundle/jruby/1.9/gems/beefcake-1.1.0/lib/beefcake.rb:114:in `encode!',
 /opt/logstash/vendor/bundle/jruby/1.9/gems/beefcake-1.1.0/lib/beefcake.rb:103:in `encode',
 org/jruby/RubyArray.java:1613:in `each',
 /opt/logstash/vendor/bundle/jruby/1.9/gems/beefcake-1.1.0/lib/beefcake.rb:96:in `encode',
 /opt/logstash/vendor/bundle/jruby/1.9/gems/riemann-client-0.2.1/lib/riemann/message.rb:13:in `encode_with_length',
 /opt/logstash/vendor/bundle/jruby/1.9/gems/riemann-client-0.2.1/lib/riemann/client/tcp.rb:51:in `send_recv',
 /opt/logstash/vendor/bundle/jruby/1.9/gems/riemann-client-0.2.1/lib/riemann/client/tcp.rb:65:in `with_connection',
 org/jruby/ext/thread/Mutex.java:149:in `synchronize',
 /opt/logstash/vendor/bundle/jruby/1.9/gems/riemann-client-0.2.1/lib/riemann/client/tcp.rb:62:in `with_connection',
 /opt/logstash/vendor/bundle/jruby/1.9/gems/riemann-client-0.2.1/lib/riemann/client/tcp.rb:50:in `send_recv',
 /opt/logstash/vendor/bundle/jruby/1.9/gems/riemann-client-0.2.1/lib/riemann/client.rb:47:in `<<',
 /opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-output-riemann-0.2.0/lib/logstash/outputs/riemann.rb:161:in `send_to_riemann',
 /opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-output-riemann-0.2.0/lib/logstash/outputs/riemann.rb:130:in `receive',
 /opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-core-1.5.3-java/lib/logstash/outputs/base.rb:88:in `handle',
 (eval):798:in `output_func',
 /opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-core-1.5.3-java/lib/logstash/pipeline.rb:244:in `outputworker',
 /opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-core-1.5.3-java/lib/logstash/pipeline.rb:166:in `start_outputs'

[request] release and publish 3.0.0

Would be great if the plugin could be released so it would work with 5.x out of the box. Or is there a blocker?

riemann-client dependency update to 0.2.6 would also be appreciated.

Options to "riemann_event" do not overwrite mapped fields

The documentation states that when using map_fields => true in combination with the riemann_event option, "any duplicate keys receive their value from riemann_event instead of the logstash event itself." This is not currently the case.

Repro

Run Riemann with the following configuration:

(logging/init {:console true})
(instrumentation {:enabled? false})
(tcp-server  {:host "0.0.0.0"})
(streams prn)

Create the following Logstash configuration:

input {
  stdin {
    codec => json_lines
  }
}

output {
  riemann {
    map_fields => true
    riemann_event => {
      service => "service from logstash configuration"
    }
  }
}

Inject an event like this:

echo '{"service": "service from incoming event"}' | sudo logstash -f repro.conf

Riemann will print the following event, with service set to the value from the original event, not the one from the Logstash configuration.

#riemann.codec.Event{:host "colt", :service "service from incoming event", :state nil, :description nil, :metric nil, :tags nil, :time 1578191579, :ttl nil}

I suspect that this bug was introduced in 7ffb0c5.

I have a fix for this (and another issue). PR to come soon.

ISO 8601 time fields from Bunyan crash when passed to Riemann client through output filter

Hi,

We've got log events coming in from Bunyan which defines a field named time as an ISO 8601 string. This causes the Riemann output filter to throw an exception when trying to send the event to Riemann when map_fields is set to true since the Ruby Riemann client assumes the time field is a 64 bit integer. We have multiple outputs and can't rename the time field for them so using the rename filter is not an option. How can I rename the time field in a log entry only for the Riemann output or alternatively force the default behaviour of converting @timestamp for the time field (i.e., map every field but the time field)?

Taking ttl from mapped fields fails with a type error

Using map_fields => true to set the ttl of a Riemann event is not possible. The value is (at some point) cast to a string, and never cast back to the float type that Riemann expects, resulting in this error:

[ERROR] 2020-01-05 14:02:49.882 [[main]>worker3] riemann - Unhandled exception {:error=>#<TypeError: wrong argument type String (expected Float)>}

Repro

Run Riemann with this configuration:

(tcp-server  {:host "0.0.0.0"})

Create the following Logstash configuration:

input {
  stdin {}
}

filter {
  mutate {
    add_field => {
      "ttl" => 60
    }  
  }
}

output {
  riemann {
    map_fields => true
  }
}

Inject an event like:

echo '{}' | sudo logstash -f repro.conf

Sender field not being honored

When I specify:

riemann {
       host => "riemanna.example.com"
       sender => "%{syslog_hostname}"
       map_fields => true
 . . .
}

The :host field on my riemann event is from the Logstash event's host field and not the syslog_hostname field.

reconnection after a riemann restart can take a long time (minutes)

It was observed that after a riemann restart, Logstash would not log errors or produce data to riemann for up to 16 minutes (observed by a user). After some time a host unreachable exception is raised and the connection is re-established.

Thread dump during that pause can show the plugin stuck on writing to the socket:

Thread dump here

"[riemann]>worker0" #41 daemon prio=5 os_prio=0 cpu=42895.26ms elapsed=3200.92s tid=0x00007f56b404b000 nid=0x40 runnable  [0x00007f56f5eb8000]
   java.lang.Thread.State: RUNNABLE
	at sun.nio.ch.FileDispatcherImpl.write0([email protected]/Native Method)
	at sun.nio.ch.SocketDispatcher.write([email protected]/SocketDispatcher.java:47)
	at sun.nio.ch.IOUtil.writeFromNativeBuffer([email protected]/IOUtil.java:113)
	at sun.nio.ch.IOUtil.write([email protected]/IOUtil.java:79)
	at sun.nio.ch.IOUtil.write([email protected]/IOUtil.java:50)
	at sun.nio.ch.SocketChannelImpl.write([email protected]/SocketChannelImpl.java:463)
	at org.jruby.util.io.PosixShim.write(PosixShim.java:106)
	at org.jruby.util.io.OpenFile$3.run(OpenFile.java:1347)
	at org.jruby.util.io.OpenFile$3.run(OpenFile.java:1338)
	at org.jruby.RubyThread.executeTask(RubyThread.java:1586)
	at org.jruby.RubyThread.executeTask(RubyThread.java:1572)
	at org.jruby.util.io.OpenFile.writeInternal(OpenFile.java:2268)
	at org.jruby.util.io.OpenFile.binwrite(OpenFile.java:2209)
	at org.jruby.util.io.OpenFile.fwrite(OpenFile.java:2076)
	at org.jruby.RubyIO.write(RubyIO.java:1476)
	at org.jruby.RubyIO.write(RubyIO.java:1432)
	at org.jruby.RubyIO$INVOKER$i$write.call(RubyIO$INVOKER$i$write.gen)
	at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:172)
	at org.jruby.RubyIO.op_append(RubyIO.java:1491)
	at java.lang.invoke.LambdaForm$DMH/0x00000008406b5c40.invokeVirtual([email protected]/LambdaForm$DMH)
	at java.lang.invoke.LambdaForm$MH/0x00000008406d3440.invoke([email protected]/LambdaForm$MH)
	at java.lang.invoke.DelegatingMethodHandle$Holder.delegate([email protected]/DelegatingMethodHandle$Holder)
	at java.lang.invoke.LambdaForm$MH/0x0000000840689440.guard([email protected]/LambdaForm$MH)
	at java.lang.invoke.DelegatingMethodHandle$Holder.delegate([email protected]/DelegatingMethodHandle$Holder)
	at java.lang.invoke.LambdaForm$MH/0x0000000840689440.guard([email protected]/LambdaForm$MH)
	at java.lang.invoke.Invokers$Holder.linkToCallSite([email protected]/Invokers$Holder)
	at usr.share.logstash.vendor.bundle.jruby.$2_dot_5_dot_0.gems.riemann_minus_client_minus_0_dot_2_dot_1.lib.riemann.client.tcp.RUBY$block$send_recv$1(/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/riemann-client-0.2.1/lib/riemann/client/tcp.rb:51)
	at java.lang.invoke.DirectMethodHandle$Holder.invokeStatic([email protected]/DirectMethodHandle$Holder)
	at java.lang.invoke.LambdaForm$MH/0x0000000841370440.invoke([email protected]/LambdaForm$MH)
	at java.lang.invoke.Invokers$Holder.invokeExact_MT([email protected]/Invokers$Holder)
	at org.jruby.runtime.CompiledIRBlockBody.yieldDirect(CompiledIRBlockBody.java:146)
	at org.jruby.runtime.BlockBody.yield(BlockBody.java:114)
	at org.jruby.runtime.Block.yield(Block.java:170)
	at org.jruby.ir.runtime.IRRuntimeHelpers.yield(IRRuntimeHelpers.java:499)
	at org.jruby.ir.targets.YieldSite.yield(YieldSite.java:105)
	at java.lang.invoke.LambdaForm$DMH/0x00000008406de840.invokeVirtual([email protected]/LambdaForm$DMH)
	at java.lang.invoke.LambdaForm$MH/0x0000000840700840.invoke([email protected]/LambdaForm$MH)
	at java.lang.invoke.Invokers$Holder.linkToCallSite([email protected]/Invokers$Holder)
	at usr.share.logstash.vendor.bundle.jruby.$2_dot_5_dot_0.gems.riemann_minus_client_minus_0_dot_2_dot_1.lib.riemann.client.tcp.RUBY$block$with_connection$1(/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/riemann-client-0.2.1/lib/riemann/client/tcp.rb:65)
	at java.lang.invoke.DirectMethodHandle$Holder.invokeStatic([email protected]/DirectMethodHandle$Holder)
	at java.lang.invoke.LambdaForm$MH/0x0000000841370040.invoke([email protected]/LambdaForm$MH)
	at java.lang.invoke.Invokers$Holder.invokeExact_MT([email protected]/Invokers$Holder)
	at org.jruby.runtime.CompiledIRBlockBody.yieldDirect(CompiledIRBlockBody.java:146)
	at org.jruby.runtime.IRBlockBody.yieldSpecific(IRBlockBody.java:85)
	at org.jruby.runtime.Block.yieldSpecific(Block.java:139)
	at org.jruby.ext.thread.Mutex.synchronize(Mutex.java:164)
	at java.lang.invoke.LambdaForm$DMH/0x00000008406b5c40.invokeVirtual([email protected]/LambdaForm$DMH)
	at java.lang.invoke.LambdaForm$MH/0x00000008406d3440.invoke([email protected]/LambdaForm$MH)
	at java.lang.invoke.LambdaForm$MH/0x00000008406da440.guardWithCatch([email protected]/LambdaForm$MH)
	at java.lang.invoke.LambdaForm$MH/0x00000008406db040.invoke([email protected]/LambdaForm$MH)
	at java.lang.invoke.DelegatingMethodHandle$Holder.delegate([email protected]/DelegatingMethodHandle$Holder)
	at java.lang.invoke.LambdaForm$MH/0x0000000840689440.guard([email protected]/LambdaForm$MH)
	at java.lang.invoke.DelegatingMethodHandle$Holder.delegate([email protected]/DelegatingMethodHandle$Holder)
	at java.lang.invoke.LambdaForm$MH/0x0000000840689440.guard([email protected]/LambdaForm$MH)
	at java.lang.invoke.Invokers$Holder.linkToCallSite([email protected]/Invokers$Holder)
	at usr.share.logstash.vendor.bundle.jruby.$2_dot_5_dot_0.gems.riemann_minus_client_minus_0_dot_2_dot_1.lib.riemann.client.tcp.RUBY$method$with_connection$0(/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/riemann-client-0.2.1/lib/riemann/client/tcp.rb:62)
	at java.lang.invoke.DirectMethodHandle$Holder.invokeStatic([email protected]/DirectMethodHandle$Holder)
	at java.lang.invoke.LambdaForm$MH/0x00000008408b4440.invoke([email protected]/LambdaForm$MH)
	at java.lang.invoke.LambdaForm$MH/0x00000008406da440.guardWithCatch([email protected]/LambdaForm$MH)
	at java.lang.invoke.LambdaForm$MH/0x00000008406db040.invoke([email protected]/LambdaForm$MH)
	at java.lang.invoke.DelegatingMethodHandle$Holder.delegate([email protected]/DelegatingMethodHandle$Holder)
	at java.lang.invoke.LambdaForm$MH/0x0000000840689440.guard([email protected]/LambdaForm$MH)
	at java.lang.invoke.DelegatingMethodHandle$Holder.delegate([email protected]/DelegatingMethodHandle$Holder)
	at java.lang.invoke.LambdaForm$MH/0x0000000840689440.guard([email protected]/LambdaForm$MH)
	at java.lang.invoke.Invokers$Holder.linkToCallSite([email protected]/Invokers$Holder)
	at usr.share.logstash.vendor.bundle.jruby.$2_dot_5_dot_0.gems.riemann_minus_client_minus_0_dot_2_dot_1.lib.riemann.client.tcp.RUBY$method$send_recv$0(/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/riemann-client-0.2.1/lib/riemann/client/tcp.rb:50)

undefined method `compact' when tags field is an array

There seems to be an issue with the way riemann plugin handles tags.

Given I have the following data forwarded from logstash to riemann output:

{
  "@version": 1,
  "@timestamp": "2015-09-16T13:18:01.995Z",
  "host": "mylocalhost",
  "logger": "python-logstash-logger",
  "type": "logstash",
  "riemann_metric": {
    "metric": 1.1,
    "state": 1,
    "service": "myservice",
    "ttl": 230
  },
  "tags": [],
  "path": "make-logs.py",
  "message": "python-logstash: test",
  "levelname": "INFO"
}

Riemann output is going to receive this data and then silently fail - there is no information about whats happening and why.
If however I use the following data - the only difference is tags:

{
  "tags": "foobar",
  "@timestamp": "2015-09-16T13:18:01.995Z",
  "@version": 1,
  "type": "logstash",
  "host": "mylocalhost",
  "riemann_metric": {
    "metric": 1.1,
    "state": "ok",
    "service": "myservice",
    "ttl": 230
  },
  "path": "make-logs.py",
  "logger": "python-logstash-logger",
  "message": "python-logstash: test extra fields",
  "levelname": "INFO"
}

Everything works like a charm.

My investigation of the ruby gem showed that when I use an array, send_to_riemann is going to throw the following exception:
undefined method compact' for <Java::JavaUtil::ArrayList:1 []>:Java::JavaUtil::ArrayList`

riemann output crashes logstash

(This issue was originally filed by @kosfar at elastic/logstash#2303)


Hello,
i tried to use something like this (LS version 1.4.2):
output {
...some other config here...

if [proc_name] == "kernel" and [syslog_severity] != "informational" {
riemann {
map_fields => true
riemann_event => {
"service" => "Kernel traces"
"state" => "%{syslog_severity}"
}
}
}

...some other config here...
}

but when an event that matches reaches the riemann output, logstash crashes with the following error message:
NoMethodError: undefined method `each' for #LogStash::Event:0x55f721a9
map_fields at /opt/logstash/lib/logstash/outputs/riemann.rb:109
receive at /opt/logstash/lib/logstash/outputs/riemann.rb:143
handle at /opt/logstash/lib/logstash/outputs/base.rb:86
initialize at (eval):1698
call at org/jruby/RubyProc.java:271
output at /opt/logstash/lib/logstash/pipeline.rb:266
outputworker at /opt/logstash/lib/logstash/pipeline.rb:225
start_outputs at /opt/logstash/lib/logstash/pipeline.rb:152

We use map_fields => true so that we can further split streams per host in riemann.

Any hints?

Export times with microsecond resolution

Riemann has supported microsecond resolution since 0.2.13

Added support of time in microsecond resolution in the Riemann
protocol (See time_micros in the Riemann client. If you maintain a Riemann client should update them to support microseconds.

It would be great if this plugin could make use of that.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.