-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is it possible to use regular expression in filter ? #719
Comments
Yes. You need to use https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html#_regular_expressions. Basically, surround it in / ... / Also, the I think this is what you want:
|
hi Qmando,
but it's get any alert when have match document , |
What is the EXACT value you are trying to match? |
hi Qmando,
my filter as below
but when I run the rule ,got the error output
|
I don't think you need the backslashes () because / doesn't need to be escaped. Also note (https://www.elastic.co/guide/en/elasticsearch/reference/2.1/query-dsl-regexp-query.html) that regular expressions are anchored, so they must match the whole string. I'm not sure if you want to match GE0 or TE0, but you probably want
You can probably simplify it to "Line protocol on Interface TE.*?changed state to Down" |
hi Qmando, I have follow as you said,
but still cannot alert when match match the rule ? |
Yes. use .raw, like I said. You also got rid of the space before "changed" |
Hi Qmando,
I want to alert when match the pattern
but 16785422 and 430 is random produce, so I set * to my rule and my filter as below,
but still cannot alert when match match the rule ? |
Elasticsearch regexp is anchored, meaning you have to use ".cerent84State.:40". Leading wildcard is slow but it should match. |
Hi Qmand, the dot . in my pattern is original message
follow as you said ,it's still cannot match with my rule
and i try to use wildcard as below ,still cannot match
what's wrong with my code ? |
|
hi @Qmando ,
the filed mapping as below,
but as you said still cannot math the rule as below,
and I tried the filter
,still cannot match what's wrong with my code please ? |
Again, you need to start with |
hi @Qmando , I have try
and
and finally ,
but ,all of these cannot match Any help should be appreciated please! |
Have you considered if |
Hi. I have similar issue so I thought I will just add here. I try to alert on following: rule configuration: filter:
realert: If I alert on term only I can see hits but together with regex: - 0 hits |
I found following: The solution looks to be:
Sorry but the formatting is not right. filter and - query_string should be lined |
Example yaml for regex matching documents with message key having error anywhere in text
|
@abhishekjiitr What about using complex queries like this one below:
I am getting the same error 'found unknown escape character'. Edit: Each of reserved characters should be escaped. So the last line should look like this:
|
@alankis is this query working fine after the edit? I think you need to add
|
@abhishekjiitr Not exactly. Now I am getting hits, even when the process exists. I have rewritten my query slightly:
Now my query is getting hit even when the process exists. I am using your example, I am getting the following error:
I am trying to match the following 'cmdline' in my ES:
|
@abhishekjiitr If I am correct, I should also escape '.' (dot character) with a leading backslash? Eg. This is at least true from the ES documentation. I am using the following query in Kibana discover pane and it is returning the expected value:
|
@Qmando i have issue with using regex in query_string filter
I used multiple ways which are My alert condition is to alert if the field has any data with an apostrophe('). Kindly help in this regard |
Is |
hi all,
I try to using regular expression in my rule as below, it's will alert when id is 1.1 and msg contain type.24:6
but it's cannot alert ,Is it possible to use regular expression in filter ?
Thanks by advance
The text was updated successfully, but these errors were encountered: