-
Notifications
You must be signed in to change notification settings - Fork 442
Description
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)
}))