[Kibana] - Add filter using specific regex

Hi,
Sorry i'm a begginer in kibana so i might ask something stupid.
I'd would filter a message with a RegEx, but i try to use it Kibana return me a string error:

{
    "query": {
        "regexp":{
            "message": "\[(.*?)\]"
        }
    }
}

If i try this RegEx without Kibana it work.
I found that RegEx might start with / and ends with /
I try it but same error. I think i must use an escape character maybe?

Thanks very much for the support it will help me a lot.

Best regards

It looks like you need to double escape the bracket characters to work with JSON properly. The JSON blob you posted above is not valid JSON, instead place two backslashes before the brackets:

{
    "query": {
        "regexp":{
            "message": "\\[(.*?)\\]"
        }
    }
}

This worked for me when searching via the Console tool in Dev Tools. Definitely recommend using that for testing out custom queries. It will flag which lines have invalid JSON and has auto-complete for Elasticsearch queries.

Dear JoshDover,

Thanks for your kindly answer.
I have tried it but it didn't work sadly.

Where are you trying to use this JSON in Kibana?

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.