Dimensions are not combined and can only be viewed separately on AWS
Closed this issue · 2 comments
bfelbo commented
- Amazon Web Services Cloud Watch Metrics library version: 1.0.0
- Python version: 3.6
- Operating System: MacOS
Description
I was trying to replace my existing CloudWatch code (see below) with a version using this library. The metrics are sent up fine, but the dimensions are not being combined as they should. Sending up Purpose
and Stage
using my existing code created a combinatorial view on CloudWatch, whereas using this library only creates the individual views Purpose
and Stage
. See the screenshot below. The metrics in Purpose, Stage
are no longer updated after switching to this library.
What I Did
Old Code
cloudwatch = boto3.client(
service_name="cloudwatch",
region_name=env["AWS_DEPLOYED_REGION"],
api_version="2010-08-01"
)
cloudwatch.put_metric_data(
Namespace="myNameSpace",
MetricData=[
{
"MetricName": name,
"Dimensions": [
{"Name": "Stage", "Value": env["STAGE"]},
{"Name": "Purpose", "Value": env["PURPOSE"]},
],
"Values": value,
"StorageResolution": 60,
"Unit": unit,
},
],
)
New Code
import awsme
cloudwatch = awsme.create_cloud_watch(
namespace="myNameSpace",
dimensions={"Stage": env["STAGE"], "Purpose": env["PURPOSE"]},
region_name=env["AWS_DEPLOYED_REGION"],
api_version="2010-08-01",
asynchronous=True,
buffered=True,
)
cloudwatch.log(name, value=value, unit=unit, storage_resolution=60)
bfelbo commented
Nevermind, I fixed it on my end. Sorry for the inconvenience!
peterdemin commented
I think you're referencing to this method: https://github.com/peterdemin/awsme/blob/master/src/awsme/metric.py#L32