サーバーの IP アドレスの配列を作成して、Logstash 構成ファイルの編集と読み取りを少し簡単にすることができるかどうかを知りたいと思いました。CentOS ボックスには「linux」、ASA には「networking」のタグを付けています。現在、構成のフィルター部分は次のようになっています。
filter {
if [host] == “10.x.x.1” or [host] == “10.x.x.2” or … or [host] “10.x.x.30” {
mutate {
add_tag => “linux”
}
}
if [host] == “10.x.x.200” or [host] == “10.x.x.201” or … or [host] “10.x.x.250” {
mutate {
add_tag => “networking”
}
}
これは機能しますが、各カテゴリに 30 以上のノードがあるため、行が非常に長くなります。代わりに(疑似コードで)次のようなことを考えていました:
array [linux_hosts] = [“10.x.x.1”,
“10.x.x.2”,
“10.x.x.3”]
if [host] in [linux_hosts] {
mutate {
add_tag => “linux”
}
}
このようなことは可能ですか?これを行うより良い方法はありますか?