Identify AccountID on alert when using CloudWatch Cross Account

Hi everyone!
I’ve setup CloudWatch cross Account monitoring on an AWS account. On the same account I’ve hosted an ECS service with a Grafana image inside with a CloudWatch datasource. Dashboards work perfect and I’m able to see metrics from different accounts. My issue is alerting.

What I want to achieve is to send the AWS Account ID or label and the AWS region on an alert. An example of my desired alert would be the following:

[FIRING:1] TestAlert Grafana critical

Firing

Value: [no value] Labels:

alertname = TestAlert
instance = Grafana
severity = critical

Annotations:

description = descriptions
summary = summary
accountID = 12346789 # <------
AWS Region = eu-west1# <------

Is there a way to achieve this?

Thanks in advance!

Define/hardcode them as custom labels/annotations on the alert level.

There’s no way to add this dynamically?
My issue is that I want to provision alerts as dynamic as possible because some accounts are created and deleted often to do tests and then they’re cleaned up. And also I have more than 30 clients that use multiple regions.
Thanks for your time!

Yes, it can be “dynamic” if you are able to return it from CloudWatch query - can you do that?

Yes! I’m able to get regions and account IDs from a query when configuring a dashboard variable:


Your question is about alert, not about dashboard. Alert! = dashboard.
So can you get account id and region from the CloudWatch alert query?