logstasher
Erlang Logger formatter for logstash
Hex package
In rebar.config, add the logstasher Hex package to the deps:
{deps, [
{logstasher, "~> 1.0.0"}
]}.
Erlang Configuration
In sys.config, enable logstasher_h as a Logger handler and configure the logstasher
application:
[
{kernel, [
{logger, [
{handler, logstash, logstasher_h,
#{
level => info
}
}
]}
]},
{logstasher, [
{transport, udp}, % tcp | udp | console
{host, "localhost"}, % inet:hostname()
{port, 5000} % inet:port_number()
]}
].After this, also add the logstasher application to your .app.src file:
{applications, [
....
logstasher,
....
]},Logstash Configuration
input { udp { codec => json port => 5000 queue_size => 10000 workers => 10 type => default_log_type } } output { stdout {} elasticsearch { protocol => http } }
Send data to logstash
It is possible to send other data to logstash:
logstasher:send_message(<<"Hello world!">>, #{ some => <<"fields">> }).
A timestamp will be added to the message.