<p>CloudWatch <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/MonitoringLogData.html" rel="noreferrer">Metric Filters</a> are the recommended way to create custom metrics from Lambda functions. Sending the metrics directly from the lambda function to the CloudWatch api is the main alternative, but it has several disadvantages including, not least, the cost (at scale). It does seem like a cleaner and cheaper approach to log the metics out to CloudWatch Logs and then have a Metric filter extract the metric from the logs.</p>

<p>The main disadvantage this approach seems to have is the lack of support for Dimensions.</p>

<p>Let's say I have a metric I want to record from my executing lambda function called <code>CountIDidSomething</code>, and since this is count the value is always 1.</p>

<p>If I was to use the <a href="https://docs.aws.amazon.com/cli/latest/reference/cloudwatch/put-metric-data.html" rel="noreferrer">CloudWatch api</a> to send this metric then I would be able to include dimensions to label it with the name of the lambda function for example.</p>

<p>However, if I use the Metric Filter approach I can't add dimensions. The only alternative I have is to put the name of the lambda function in the name of the metric, but I end up with a large number of custom metrics being created, all representing the same metric but with different names. This seems to go against the purpose of metrics as generic labels for values coming from different sources. where dimensions are used to slice and dice them.</p>

<p>I wanted to see if anyone knew of a better approach to either of these two, or whether I will just have to make do with what I've got.</p>

CC BY-SA 4.0
2020-03-30T15:18:32.207Z
I don't understand why this was closed. I have the same question [and unfortunately it doesn't seem to be possible, which greatly limits the usefulness of CloudWatch Metric Filters :(]
JMM
CC BY-SA 4.0
2020-05-21T17:08:10.227Z
I had the same question. Is the answer to the question in the title is simply "no"?
Iain Samuel McLean Elder
CC BY-SA 3.0
2018-01-05T15:59:17.213Z
I have an approach but I don't much like it. I was hoping someone might know of a better one.
Andy McCluggage
<amazon-web-services><amazon-cloudwatch><metrics>
Is it possible to create AWS CloudWatch Metric Filters with dimensions?
Andy McCluggage
# Is it possible to create AWS CloudWatch Metric Filters with dimensions?

(Asked by: username_0 on 2018-01-02)

CloudWatch [Metric Filters](https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/MonitoringLogData.html) are the recommended way to create custom metrics from Lambda functions. Sending the metrics directly from the lambda function to the CloudWatch api is the main alternative, but it has several disadvantages including, not least, the cost (at scale). It does seem like a cleaner and cheaper approach to log the metics out to CloudWatch Logs and then have a Metric filter extract the metric from the logs.

The main disadvantage this approach seems to have is the lack of support for Dimensions.

Let's say I have a metric I want to record from my executing lambda function called `CountIDidSomething`, and since this is count the value is always 1.

If I was to use the [CloudWatch api](https://docs.aws.amazon.com/cli/latest/reference/cloudwatch/put-metric-data.html) to send this metric then I would be able to include dimensions to label it with the name of the lambda function for example.

However, if I use the Metric Filter approach I can't add dimensions. The only alternative I have is to put the name of the lambda function in the name of the metric, but I end up with a large number of custom metrics being created, all representing the same metric but with different names. This seems to go against the purpose of metrics as generic labels for values coming from different sources. where dimensions are used to slice and dice them.

I wanted to see if anyone knew of a better approach to either of these two, or whether I will just have to make do with what I've got.

**Tags:** amazon-web-services, amazon-cloudwatch, metrics

> **Comments:**
> **username_0**: I have an approach but I don't much like it. I was hoping someone might know of a better one.  
> **username_1**: I don't understand why this was closed. I have the same question [and unfortunately it doesn't seem to be possible, which greatly limits the usefulness of CloudWatch Metric Filters :(]  
> **username_2**: I had the same question. Is the answer to the question in the title is simply "no"?  

---

## 0 answers

