Ich habe folgendes Protokoll aus NGINX:Elastic Suchbegriffs Vorlage für NGINX benutzerdefiniertes Protokoll
111.111.111.111, 11.11.11.11 - 11.11.11.11 [06/Mai/2016: 08: 26: 10 +0000] " POST/some-Service/GetSomething HTTP/1.1" 499 0 "-" "Jakarta Commons-Httpclient/3,1" "7979798797979799" 59,370 - "{\ x0A \ x22correlationId \ x22 \ x22TestCorr1 \ x22 \ x0A}"
Logstash wird so aussehen:
input { stdin {} }
output { stdout { codec => "rubydebug" } }
filter {
grok {
match => { "message" => "%{COMBINEDAPACHELOG} %{QS:partner_id} %{NUMBER:req_time} %{GREEDYDATA:extra_fields}" }
add_field => [ "received_at", "%{@timestamp}" ]
add_field => [ "received_from", "%{host}" ]
}
mutate {
gsub => ["extra_fields", "\"","",
"extra_fields", "\\x0A","",
"extra_fields", "\\x22",'\"',
"extra_fields", "(\\)",""
]
}
json {
source => "extra_fields"
target => "extra_fields_json"
}
mutate {
add_field => {
"correlationId" => "%{[extra_fields_json][correlationId]}"
}
}
}
Das Problem ist REQ_TIME String, also muß ich mit der folgenden Vorlage zu schweben konvertieren:
{
"template" : "filebeat*",
"settings" : {
"index.refresh_interval" : "5s"
},
"mappings" : {
"properties" : {
"@timestamp": { "type": "date" },
"partner_id": { "type": "string", "index": "not_analyzed" },
"@version": { "type": "string", "index": "not_analyzed" },
"req_time" : { "type" : "float", "index" : "not_analyzed" },
"res_time" : { "type" : "string", "index" : "not_analyzed" },
"purchaseTime" : { "type" : "date", "index" : "not_analyzed" },
"received_at" : { "type" : "date", "index" : "not_analyzed" },
"itemPrice" : { "type" : "double", "index" : "not_analyzed" },
"total" : { "type" : "integer", "index" : "not_analyzed" },
"bytes" : { "type" : "double", "index" : "not_analyzed" }
}
}
}
}
Verifiziert mit: curl -XGET 'http://localhost:9200/filebeat-2016.06.30/_mapping/field/req_time'
Ich erhalte:
{"filebeat-2016.06.30": {"Zuordnungen": {"nginxlog": {"req_time": {"vollständiger_name": "req_time", "Zuordnung": {"req_time": {"type" : "string"}}}}}}}
so funktioniert meine Vorlage definitiv nicht. Jeder kann helfen?
Sind Sie sicher, dass Ihre Zuordnung in der Vorlage korrekt ist? weil Sie den Typ innerhalb des ersten _properties_ -Objekts angeben sollten. Es wird ein Fehler erzeugt, so dass das Mapping nicht angewendet wird. –