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

1 Answer 1

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}"
      }
    }
  }
}
Sign up to request clarification or add additional context in comments.

8 Comments

Thanks for correcting the regex...but I am still getting 0 match :(
@Furin you are searching on keyword field?
I tried both with and without, I get the same results: 0 :(
@Furin can you add sample document
Unfortunately I can't
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.