I was concerned tags wasn't the right data structure to use. Let me explain a bit more in depth what I'm trying to accomplish.
We want to automate logstash configuration creation (via a python script)
We have an API server that we can query using the python script to return a list of company names, these company names will be used for searches in the message data.
Here is an example of something we have currently, as you can imagine we do not want to make 200 if statements manually.
input {
exec {
command => "cd /root/san/svc; python latency"
interval => 300
tags => "SANSVC"
}
}
filter {
if "SANSVC" in [tags] {
split { field => ["message"]
}
kv {
add_tag => ["SANSVC"]
}
date {
locale => "en"
match => ["DATE", "YYYY-MM-dd;HH:mm:ss"]
timezone => "Europe/Brussels"
target => "@timestamp"
add_field => { "debug" => "timestampMatched"}
}
mutate {
convert => ["ID", "integer"]
convert => ["READOPS", "float"]
convert => ["WRITEOPS", "float"]
convert => ["WRITELATENCY", "float"]
convert => ["READLATENCY", "float"]
replace => { "host" => "%{SVCHOST}" }
remove_field => [ "SVCHOST", "DATE" ]
}
grok {
match => [ "message", ".*(?i)(unik).*"]
add_tag => ["unik"]
tag_on_failure => []
}
grok {
match => [ "message", ".*(?i)(micro)(matic)?.*"]
add_tag => ["micro"]
tag_on_failure => []
}
}
}#End big if
output {
if "SANSVC" in [tags] {
elasticsearch {
hosts => '10.35.1.38'
index => "san-svc-%{+YYYY.MM.dd}"
}
}
if "unik" in [tags]{
elasticsearch {
hosts => '10.35.1.38'
index => "unik-svc-%{+YYYY.MM}"
}
}
if "micro" in [tags]{
elasticsearch {
hosts => '10.35.1.38'
index => "micro-svc-%{+YYYY.MM}"
}
}
}
Hopefully this provides a better explanation, I'm happy to clarify further.
Are you suggesting we add a field based on the tag name?