This is not working. If I comment out type in my input and output it works fine. Why is type not working. Am I missing something. I use a very similar config in other logstash files and it works just fine.
type is kind of a special field in beats and logstash. If type is already set in input event, It won't be overwritten by the configurated 'type' variable in logstash config file. See code comment documenting behavior
In case of topbeat the values of type are 'proc', 'system' and 'filesystem'. The beat its name is stored in [@metadata][beat].
Instead of 'type' you can use the 'add_field' config option to add another field with custom name to the generated event (store in [@metadata][my_name] if you don't want to store the custom field in redis). But I'd recommend not doing so, as 'type' or custom field will add same field to every event, independent of actual event type or source making it inflexible for later additions (e.g. adding another beat to the system).
Maybe something like this better fits your use-case (untested):
input {
beats {
port => 5044
}
}
output {
if [@metadata] and [@metadata][beat] {
redis {
host => "192.168.99.4"
data_type => "list"
key => "%{[@metadata][beat]}"
}
}
}
Now every single beat you connect to logstash will produce it's own key in redis.
it works but not with the if statement included but the key name is literally "%{[@metadata][beat]}". It doesn't appear that "%{[@metadata][beat]}" is being picked up as a variable.
EDIT:
It appears that when I take out the if statement topbeat is still not functioning as expected. I am seeing the key in redis but other data is in there from another source not topbeat. So I think I have a more fundamental issue of logstash maybe not reading topbeat. I do see the port open using netstat and I see topbeat running using ps aux.
Figured it out. User error (BIG TIME). I fat fingered my host in the config file.
Thanks for the help
Side question. If I spin up multiple servers with topbeat running and use your above config, how will I be able to differentiate between them in elasticsearch?
Ever beat sends currently under the field "shipper" the hostname or the name set in the configuration. This should make it possible to differentiate between the beats. This field will change in the next release. For more details see here: https://github.com/elastic/libbeat/issues/281
Is there a reason the add_field syntax is not working? If I add it in a filter statement with the mutate plugin it works fine but according to the beats docs I should be able to use the add_field syntax in the input section.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.