Is it possible to filter by tags when using search expression in cloudwatch?

0

I've recently learned about search expressions in cloudwatch which are a great way of automating the update of dashboards but I've only been able to get all the resources in the account with a desired metric, is there a way to filter the search expression to only show resources with a specific tag e.g. "environment = dev"?

Here's a sample search metric source code I'd like to filter:

{ "expression": "SEARCH('{AWS/Lambda,FunctionName} lambda invocations', 'Average', 300)", "id": "e3", "period": 300, "yAxis": "right", "region": "us-east-1" }

In summary I'm trying to create a dashboard that shows lambda invocations for all functions containing the "environment = dev" tag and gets updated with new lambdas when they're created.

I know about Metrics Explorer but that doesn't update the graphs automatically when new resources are created AFAIK.

1 Answer
0
Accepted Answer

Filtering by tags directly within a CloudWatch search expression for metrics isn't directly supported in the syntax you've provided. The SEARCH function in CloudWatch allows you to search across metrics based on namespace, metric name, and dimensions such as FunctionName in the case of AWS Lambda, but it does not natively support filtering by resource tags in the search expression itself.

Another approach is to use AWS resource groups to organize resources based on tags, and then use the CloudWatch integration with these groups to focus on the metrics for these grouped resources. However, this doesn’t directly change the search expression but could help in narrowing down the metrics you're interested in through the AWS Management Console or through automated scripts that leverage AWS SDKs.

profile picture
EXPERT
answered 2 months ago
  • Thanks for the quick answer! This is a huge oversight on AWS part IMO. Having a way to automatically update dashboards without resorting to a user created updating function should be a focus, search expressions should be more proeminently displayed for that and not integrating it with user tags is a big missed opportunity.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions