logstash-plugins / logstash-filter-grok

Grok plugin to parse unstructured (log) data into something structured.
https://www.elastic.co/guide/en/logstash/current/plugins-filters-grok.html
Apache License 2.0
124 stars 98 forks source link

Numeric semantic conversion in grok appear to work on longs as well #71

Open ppf2 opened 8 years ago

ppf2 commented 8 years ago

The following documentation snippet may be outdated/misleading.

https://www.elastic.co/guide/en/logstash/current/plugins-filters-grok.html

Optionally you can add a data type conversion to your grok pattern. By default all semantics are saved as strings. If you wish to convert a semantic’s data type, for example change a string to an integer then suffix it with the target data type. For example %{NUMBER:num:int} which converts the num semantic from a string to an integer. Currently the only supported conversions are int and float.

Turns out it actually works on values larger than int32 max (2147483647).

For example, the following works on a string 9223372036854775801. And via dynamic mapping will create the field as a long in Elasticsearch.

  grok {
    match => { "message" => "%{NUMBER:big_number:int}" }
  }