-
Notifications
You must be signed in to change notification settings - Fork 421
Multiple values for a single metric not working #165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
hey @Dunedan - This is not a bug but a known behaviour of Embedded Metric Format (EMF) feature we use for creating metrics async. It only supports one value per unique key name - If you add multiple values it'll override with the last one. For that and other purposes, we created the I thought of having another API for that would keep multiple values for the same metric, and then flush them at the end as a workaround to EMF specification - But not entirely sure on the value and UX yet. If you think this is a good idea, please feel free to write up a RFC to discuss more about it :) |
Are you sure that this is a limitation of EMF? The EMF specification suggests otherwise:
Also #!/usr/bin/env python3
import os
os.environ["AWS_LAMBDA_FUNCTION_NAME"] = "dummy"
from aws_embedded_metrics import metric_scope
@metric_scope
def handler(metrics):
metrics.put_dimensions({"Foo": "Bar"})
metrics.put_metric("TestMetric", 1, "Count")
metrics.put_metric("TestMetric", 1, "Count")
handler()
|
Aha! Thanks Daniel - I’ll revisit this on Friday
…On Wed, 16 Sep 2020 at 18:03, Daniel Roschka ***@***.***> wrote:
Are you sure that this is a limitation of EMF?
The EMF specification
<https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Embedded_Metric_Format_Specification.html>
suggests otherwise:
Metric targets MUST be either a numeric value or an array of numeric
values.
Also aws-embedded-metrics-python
<https://github.com/awslabs/aws-embedded-metrics-python> implements it as
I would expect it and I believe such records are properly handled by
CloudWatch Metrics.
#!/usr/bin/env python3
import os
os.environ["AWS_LAMBDA_FUNCTION_NAME"] = "dummy"
from aws_embedded_metrics import metric_scope
@metric_scope
def handler(metrics):
metrics.put_dimensions({"Foo": "Bar"})
metrics.put_metric("TestMetric", 1, "Count")
metrics.put_metric("TestMetric", 1, "Count")
handler()
{
"LogGroup": "dummy",
"ServiceName": "dummy",
"ServiceType": "AWS::Lambda::Function",
"Foo": "Bar",
"executionEnvironment": "",
"memorySize": "",
"functionVersion": "",
"logStreamId": "",
"_aws": {
"Timestamp": 1600271848937,
"CloudWatchMetrics": [
{
"Dimensions": [
[
"LogGroup",
"ServiceName",
"ServiceType",
"Foo"
]
],
"Metrics": [
{
"Name": "TestMetric",
"Unit": "Count"
}
],
"Namespace": "aws-embedded-metrics"
}
]
},
"TestMetric": [
1,
1
]
}
—
You are receiving this because you were assigned.
Reply to this email directly, view it on GitHub
<#165 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAZPQBA7KRV3QI6V2ZOG263SGDOWZANCNFSM4ROSJPDQ>
.
|
@Dunedan just confirmed with the CloudWatch team - This was added recently, it wasn't in the original implementation. Added the feature request label, and we'll implement this to be available in the next release 1.6.0 this month. Thanks for flagging it, much much appreciated |
hey @Dunedan - @cakepietoast just finished implementing it, and as I mentioned before, it'll be available in the next release. Thanks for flagging this and letting us know about the EMF update, much appreciated! |
This can be closed now :) |
Fixed in 1.6.0 |
I'm trying to log multiple values for a single metric using powertool's
Metrics
class.However when doing so I only get the last added value flushed.
Here is a minimal example which triggers the problem:
The code above produces the following output (formatted for better readability):
What I'd expect instead would be the following:
I'm not sure if this is a bug or if I'm missing something from the documentation, but to me it currently looks that logging multiple values for a single metric isn't possible without flushing manually between adding them.
The text was updated successfully, but these errors were encountered: