I tried a simple add_field with value as a static string and that substitution is also not working with logstash 5.2 or 5.3 for the logstash conf shown below
Logstash.conf
input {
kafka {
bootstrap_servers => ["10.1.1.1:9092"]
type => "kafka"
topics => ["csoslogs.infra", "ipmi.customer001", "ipmi.customer002"]
codec => "json"
decorate_events => true
}
}
filter {
if [type] == "syslog" {
mutate {
add_field => { "elasticindex" => "%{host}" }
}
}
if [type] == "kafka" {
mutate {
add_field => { "elasticindex" => "10.6.6.1" }
}
}
output {
stdout { codec => rubydebug }
}
output {
elasticsearch {
hosts => ["104.42.236.238:9200"]
user => "es_admin"
password => "Cloudsimple123!"
index => "%{elasticindex}.%{+YYYY.MM.dd}"
}
}
JSON seen in kibana :
{
"_index": "%{elasticindex}.2017.04.14",
"_type": "log",
"_id": "AVtrBCiSH217HTENKISm",
"_score": null,
"_source": {
"@timestamp": "2017-04-14T05:51:24.476Z",
"offset": 71259,
"kafka": {
"consumer_group": "logstash",
"partition": 0,
"offset": 5910,
"topic": "csoslogs.infra",
"key": null
},
"beat": {
"hostname": "3495c2daccca",
"name": "FileBeat",
"version": "5.2.0"
},
"input_type": "log",
"@version": "1",
"source": "/Users/vramakrishnan/work/cplane/testoutput/coordinator.test.INFO",
"fields": {
"podip": "10.6.6.1",
"provider": "provider1",
"service": "coordinator",
"resourcetype": "csos",
"customer": "infra"
},
"message": "I0414 05:51:18.736575 27476 consul_helper.go:286] 0: created consul session 79c34ca4-a1f6-326b-9d5d-43eb62626f3c, so agent client-0 is initialized",
"type": "log"
},
"fields": {
"@timestamp": [
1492149084476
]
},
"sort": [
1492149084476
]
}