I’m confused about how dimensions work in CloudWatch. If I have a metric called "OrderCount" and I add dimensions for "Region" and "ProductCategory," can I still see the total "OrderCount" across all regions, or do I have to publish a separate metric without any dimensions for that?
3 answers
This is a common trap! In CloudWatch, a metric is uniquely identified by its name AND its full set of dimensions. If you publish a metric with {Region: US-East-1, Category: Electronics}, you cannot simply "query" for the total without those dimensions unless you explicitly published a version of the metric without them. This is known as the "Dimensionality Problem." To get the aggregate view, you either need to publish the data point twice—once with dimensions and once without—or use Metric Math in your dashboard to sum up all the individual dimensional series, which is usually the better approach.
Have you tried using the new CloudWatch Metrics Insights SQL-based querying? It makes aggregating across different dimension values much easier than it used to be.
Be careful not to use high-cardinality data like "UserID" as a dimension. You will end up with thousands of unique metrics, which will make your AWS bill skyrocket instantly.
Laura is spot on. I learned that the hard way when I used OrderID as a dimension. I had 50,000 unique metrics in an hour and a very unhappy manager the next morning!
Brian, that’s a game changer. With Metrics Insights, you can write a "SELECT SUM(OrderCount) FROM MyNamespace GROUP BY Category" query. It eliminates the need to publish multiple versions of the same metric. However, keep in mind that you still can't create an alarm on a grouped query result as easily as you can on a single, specific metric stream.