Skip to content
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

Add label to dimensions #4

Open
rflume opened this issue Jun 4, 2019 · 0 comments
Open

Add label to dimensions #4

rflume opened this issue Jun 4, 2019 · 0 comments

Comments

@rflume
Copy link

rflume commented Jun 4, 2019

Hi,
as CloudWatch supports labeling an instance in the widget (e.g. 'Production' rather than the instance ID) I thought it would be awesome to be able to add a label to the dimensions list of the module as well.

The JSON with an instance/metric label looks as follows:

{
    "widgets": [
        {
            "type": "metric",
            ...
            "properties": {
                "metrics": [
                    [
                        "System/Linux",
                        "MemoryUtilization",
                        "InstanceId",
                        "i-098b4673130e90378",
                        {
                            "label": "Production"
                        }
                    ]
                ],
                "view": "timeSeries",
                ...
            }
        }
    ]
}

I thought about adding the label object as follows:

dimensions = [
    "InstanceId, i-12345, {\"label\": \"test1\"}",
    "InstanceId, i-67890, {\"label\": \"test2\"}"
]  

This would generate the template correctly in the output:

cpu_utilization_metrics = [["AWS/EC2","CPUUtilization","InstanceId","i-04e11cef7ecb23847","{\"label\": \"test1\"}"], ["AWS/EC2","CPUUtilization","InstanceId","i-0131fab3c1a26f959","{\"label\": \"test2\"}"]]

But applying the template to a dashboard resource I get the following error:

Error: Error running plan: 1 error occurred:
	* aws_cloudwatch_dashboard.dashboard: "dashboard_body" contains an invalid JSON: invalid character '/' looking for beginning of value

Do you think there's another way of achieving this?
Maybe by passing a listofmaps as a seperate variable to the module and combine the dimensions with a map somehow?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant