10

In Azure Log Analytics I'm trying to use Kusto to query requests with a where condition that uses a regex. The query I'm trying is

requests
| where customDimensions.["API Name"] matches regex "\w*-v\d*"

but this returns a syntax error. The example given in the documentation here is limited but implies that this syntax should work. A simpler version of the above does work

requests
| where customDimensions.["API Name"] matches regex ".*-v.*"

What is the correct syntax for where <predicate> matches regex in Kusto?

1 Answer 1

15

If the regex contains backslashes then it must be passed as a verbatim string as explained here. The following syntax worked

requests
| where customDimensions.["API Name"] matches regex @'\w*-v\d*'
2
  • How do you invert the matching?
    – Speeddymon
    Oct 24 at 22:07
  • There's nothing in the matches regex operator that would do that so you'd need to use something like a negative lookahead in your regex Oct 28 at 17:25

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.