Hi folks! Together with @mworrell for @zotonic_core_team we are made new Erlang/OTP library logstasher
This library is provide easy way to format and send logs from Logger to Logstash by TCP
and UDP
. Or you can send output logs directly into console
if you want .
For add this library into your rebar3 project, just update your rebar.config
:
{deps, [
{logstasher, "~> 1.0.0"}
]}.
Configure logstasher
and Logger with using new handler in sys.config
like:
[
{kernel, [
{logger, [
{handler, logstash, logstasher_h,
#{
level => info
}
}
]}
]},
{logstasher, [
{transport, udp}, % tcp | udp | console
{host, "localhost"}, % inet:hostname()
{port, 5000} % inet:port_number()
]}
].
Also donβt forget add the logstasher
application to your .app.src
file:
{applications, [
....
logstasher,
....
]},
The Logstash
configuration can looks like:
input {
udp {
codec => json
port => 5000
queue_size => 10000
workers => 10
type => default_log_type
}
}
output {
stdout {}
elasticsearch {
protocol => http
}
}
And of course this library is available on hex.pm
Enjoy and let us know what you think about this library and what we can improve for you!