Enniu_51
(Sayakiss)
October 15, 2015, 5:40am
1
As I said here,
My logstash config:
filter {
grok {
match => {"stack_trace" => "%{JAVACLASS:exception_class}: \[%{DATA:error_level}\]\[%{BASE10NUM:error_code}\]-%{GREEDYDATA:error_message}"}
}
grok {
match => {"message" => "%{DATA:geo_message}: carrier=%{DATA:carrier}, province=%{DATA:province}, city=%{DATA:city}, location=%{BASE10NUM:latitude},%{BASE10NUM:longitude}"}
add_tag => ["geo_parse_succeed"]
}
if "geo_parse_succeed" in [tags] {
mutate {
add_field => {"geoip.location" =>…
And now I change my config to:
if "geo_parse_succeed" in [tags] {
mutate {
add_field => {"geoip.location.lon" => "%{longitude}"}
add_field => {"geoip.location.lat" => "%{latitude}"}
convert => [ "geoip.location.lon", "float" ]
convert => [ "geoip.location.lat", "float" ]
convert => [ "longitude", "float" ]
convert => [ "latitude", "float" ]
}
}
But I find:
"_source": {
"latitude": 45.7656666,
"longitude": 126.6160584,
"geoip.location.lon": "126.6160584",
"geoip.location.lat": "45.7656666"
}
It seems convert doesn't work for field like a.b
. So, what should I do if I want to convert a.b
to float
?
As documented , subfield references have the form [a][b]
.
Enniu_51
(Sayakiss)
October 15, 2015, 5:51am
3
Really Thanks, but one more question:
Any difference between: add_field => {"geoip.location.lon" => "%{longitude}"}
and add_field => {"[geoip][location][lon]" => "%{longitude}"}
?
Yes. a.b.c
is a field named "a.b.c" while [a][b][c]
means an hiearchy of fields starting with "a" having a subfield "b" having a subfield "c".
Enniu_51
(Sayakiss)
October 15, 2015, 6:22am
5
Really thanks! I changed my config to
mutate {
add_field => {"[geoip][location][lon]" => "%{longitude}"}
add_field => {"[geoip][location][lat]" => "%{latitude}"}
convert => [ "[geoip][location][lon]", "float" ]
convert => [ "[geoip][location][lat]", "float" ]
}
And it works.
But I still wonder why add_field a.b.c
then convert a.b.c
doesn't work?
As you said add_field a.b.c
means add a field named a.b.c
, and we convert the field which named a.b.c
to float. I think it should be right.
But I still wonder why add_field a.b.c then convert a.b.c doesn't work?
Let's keep that discussion in the other thread:
I also tried:
convert => [ "geoip.location", "float" ]
it doesn't works, either.