I'm using the Logstash SNMP input to poll a list of servers with a list of OIDs. We are deploying Logstash in Docker using Ansible, and we try to maintain the code using environment variables passed through to the Logstash configurations.
From the documentation I can build a host array and OID array. Is there any way to build this as an environment variable and pass it into Logstash?
input {
snmp {
get => ["1.3.6.1.2.1.1.1.0", "1.3.6.1.2.1.1.3.0", "1.3.6.1.2.1.1.5.0"]
hosts => [{host => "udp:127.0.0.1/161" community => "public"}, {host => "udp:192.168.0.1/161" community => "private"}]
}
}
If you are using Ansible playbook for Logstash configuration, you could assign variables in your playbook file with the host and OID values and then do variable substitution using Jinja (which Logstash supports). See here
Yes, that is how I'm doing it to substitute single variables, but you are saying that I could substitute a more complex string as a variable and logstash will recognise it as an array type?
For example this is all working:
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.