0

I am trying to parse an error message in ES7. The message contains IPs and Numbers. I tried with regex and with simple search inserting the first part of the IP. Both are not working.

This my simple match_phrase query. The query works fine until "IP", but, as soon as I extend the query to the first number in IP I get 0 matches:

"match_phrase": {
            "mylog.messages": {"query": "The device with IP 127."}}

My regex query gives me a 400 error:

"regexp": {"mylog.messages": {"value":"The device with IP /[0-9]{1-3}\.[0-9]{1-3}\.[0-9]{1-3}\.[0-9]{1-3}/"}}

Any advice on how to match IPs in error messages are welcome. Thanks

Furin
  • 532
  • 10
  • 31

1 Answers1

0

Ip address will not work with match pharse. You will need custom analyzer to make it work with match pharse

I have corrected your regex. You can get more info on supported regex syntax from here

{
  "query": {
    "regexp": {
      "messages.keyword": {
        "value": "The device with IP [0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}"
      }
    }
  }
}
jaspreet chahal
  • 8,817
  • 2
  • 11
  • 29