Being a OO developer and focusing on code maintainability and quality, I want to know is there way I can make my logstash config a bit nicer. For instance below is my config file and I hate to see those if statements. Also would be great if I can uses key-value dictionary for these if statements, use constants etc.
filter
{
if [machine]=="machineNameA"
{
mutate{
add_field => ["ServerName","dev-alias-01"]
}
}
if [machine]=="machineNameB"
{
mutate{
add_field => ["ServerName","dev-alias-02"]
}
}
if [machine]=="machineNameC"
{
mutate{
add_field => ["ServerName","QA-alias-01"]
}
}
if [machine]=="machineNameD"
{
mutate{
add_field => ["ServerName","QA-alias-02"]
}
}
if [machine]=="machineNameE"
{
mutate{
add_field => ["ServerName","UAT-alias-01"]
}
}
if [machine]=="machineNameF"
{
mutate{
add_field => ["ServerName","UAT-alias-02]
}
}
}
Then you'd only need to maintain the external yaml file if it needs to be changed.
Edit: You can also use an inline kv pair inside the translate filter, but that a) looks bloated the higher the kv amount, and b) is not as easily maintainable as you'd need to alter the configuration itself and not plainly refresh an external file.
Hi any more ideas for this. I am facing 2 issues here
Logstash gives error plugin "filter" not available.
When I try to download that using-plugin install logstash-filter-translate, I get error "connection refused". I think this is happening because my server is behind a proxy. There is no simple process for me to bypass all this or get this installed.
When I try to download that using-plugin install logstash-filter-translate, I get error "connection refused". I think this is happening because my server is behind a proxy. There is no simple process for me to bypass all this or get this installed.
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.