-
Notifications
You must be signed in to change notification settings - Fork 400
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
Invalid format using metrics #26
Labels
bug
Something isn't working
Comments
Thanks for reporting Marcio - I’ll publish a patched version later today
There’s a typo here for all “X Per Second”
https://github.com/awslabs/aws-lambda-powertools/blob/2aac986038cf9dd1b7ad3f3b7e360aac8ff0a2e4/python/aws_lambda_powertools/helper/models.py#L102
As a workaround until the patch is published, use a string as the metric
unit - **unit=“Count/Second”**
…On Thu, 30 Apr 2020 at 23:38, marcioemiranda ***@***.***> wrote:
Hello Heitor,
I am switching all my EMF logs from ordinary prints to the metric module.
All went fine except for this one. Below is the snippet that threw the
error, the error raised and the equivalent print:
*Error*
Invalid format. Error: data._aws.CloudWatchMetrics[0].Metrics[0].Unit must
match pattern
^(Seconds|Microseconds|Milliseconds|Bytes|Kilobytes|Megabytes|Gigabytes|Terabytes|Bits|Kilobits|Megabits|Gigabits|Terabits|Percent|Count|Bytes\/Second|Kilobytes\/Second|Megabytes\/Second|Gigabytes\/Second|Terabytes\/Second|Bits\/Second|Kilobits\/Second|Megabits\/Second|Gigabits\/Second|Terabits\/Second|Count\/Second|None)$,
Invalid item: data._aws.CloudWatchMetrics[0].Metrics[0].Unit"
*using single_metric*
with single_metric(name="invoke-rate", unit=MetricUnit.CountPerSecond,
value=int(rate)) as metric:
metric.add_namespace(name='Campaign/Orchestrator/WorkerInvokeRate')
metric.add_dimension(name='media', value='SMS')
*ordinary print*
print(json_dumps({
"_aws": {
"CloudWatchMetrics": [
{
"Namespace": "Campaign/Orchestrator/WorkerInvokeRate",
"Dimensions": [["media"]],
"Metrics": [
{
"Name": "rate",
"Unit": "Count/Second"
}
],
}
],
"Timestamp": int(datetime.now().timestamp()*1000)
},
"media": "SMS",
"rate": int(rate)
}))
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<aws-powertools/powertools-lambda#26>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAZPQBF5QN323ULUFARMC33RPH4WHANCNFSM4MWWEAIQ>
.
|
2 tasks
Fixing this now, found another edge case (plain string won't work due to a branch enum logic) |
Just released 0.8.1 with the fix, including additional tests that were missing. Thank you (again) for helping out @marcioemiranda |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello Heitor,
I am switching all my EMF logs from ordinary prints to the metric module.
All went fine except for this one. Below is the snippet that threw the error, the error raised and the equivalent print:
Error
Invalid format. Error: data._aws.CloudWatchMetrics[0].Metrics[0].Unit must match pattern ^(Seconds|Microseconds|Milliseconds|Bytes|Kilobytes|Megabytes|Gigabytes|Terabytes|Bits|Kilobits|Megabits|Gigabits|Terabits|Percent|Count|Bytes\/Second|Kilobytes\/Second|Megabytes\/Second|Gigabytes\/Second|Terabytes\/Second|Bits\/Second|Kilobits\/Second|Megabits\/Second|Gigabits\/Second|Terabits\/Second|Count\/Second|None)$, Invalid item: data._aws.CloudWatchMetrics[0].Metrics[0].Unit"
using single_metric
with single_metric(name="invoke-rate", unit=MetricUnit.CountPerSecond, value=int(rate)) as metric:
metric.add_namespace(name='Campaign/Orchestrator/WorkerInvokeRate')
metric.add_dimension(name='media', value='SMS')
ordinary print
print(json_dumps({
"_aws": {
"CloudWatchMetrics": [
{
"Namespace": "Campaign/Orchestrator/WorkerInvokeRate",
"Dimensions": [["media"]],
"Metrics": [
{
"Name": "rate",
"Unit": "Count/Second"
}
],
}
],
"Timestamp": int(datetime.now().timestamp()*1000)
},
"media": "SMS",
"rate": int(rate)
}))
The text was updated successfully, but these errors were encountered: