grafanaamazon-cloudwatch

How can I use regex for filtering CloudWatch metrics with Grafana?


I am using Grafana ver: 8.4.5 and configured CloudWatch as datasource for Grafana. I am using the Grafana explore console for free querying and trying to filter the AWS/SNS topic names that contains the word 'errors' I am using this syntax:

{SELECT SUM(NumberOfMessagesPublished) FROM "AWS/SNS" WHERE TopicName = '/*error*/'

But the returned value is an error:

'metric request error: "ValidationError: Error in expression 'querya40c2687332045be81b72e2637446bf7': Invalid syntax\n\tstatus code: 400, request id: 159bd510-bfde-449a-b637-e39a6094dd10"'

Is is even possible to use Regex for monitoring few topics at the same query? if so, can someone please assist with the syntax?

thanks in advance


Solution

  • It looks like you are trying to use CloudWatch Metrics Insights query, so see doc first: https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/cloudwatch-metrics-insights-querylanguage.html

    The WHERE clause supports the following operators:
       = Label value must match the specified string.
       != Label value must not match the specified string.
       AND Both conditions that are specified must be true to match. You can use multiple AND keywords to specify two or more conditions.
    

    So unfortunately, regexp matching is not supported in a way you are expecting.