hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.81k stars 9.15k forks source link

How do I set metric dimensions using Terraform? #27130

Open km-aero opened 2 years ago

km-aero commented 2 years ago

Description

I am attempting to add dimensions to a metric using Terraform but from the Terraform documentation it looks like it is not a feature. The AWS API reference for Dimension shows that it can be done using the AWS SDK but my question is can I add/create metric dimensions with a string key and string value using Terraform and without using metric transformations?

Sorry for asking the question here but it will be easier to ask here and then raise an enhancement issue quoting this issue if required.

References

AWS API reference for Dimension

Would you like to implement a fix?

No response

github-actions[bot] commented 2 years ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue

bschaatsbergen commented 2 years ago

Hi @km-aero, thanks for raising this issue.

May I ask, are you looking to implement metrics on a CloudWatch Alarm Metric or on a CloudWatch Log Metric Filter?

Both of these resources support dimensions.

It would be very helpful if you could share some code snippets and describe your desired outcome.

km-aero commented 2 years ago

Hi, thank you for your reply. I currently have log metric filters but I've noticed that I cannot pass a string to the dimension values unless I supply it to the service's logs first.

With a bit of research I found that using the Java SDK, it is possible to create a metric with up to 30 dimensions which can have a string passed as its value. I was hoping I wouldn't have to create the metric directly from my service using the SDK and would hopefully be able to create a metric using terraform as I wanted to keep all AWS config together.

It may be that I'm confused and the ability to create metrics should not be done by terraform but this question is to clarify whether I'm right in thinking terraform should have a way to add string values to a metric. Whether that means creating a new resource for metric creation or adding support for dimension string values in the creation of metric log filters.

On Mon, 10 Oct 2022, 23:24 Bruno Schaatsbergen, @.***> wrote:

Hi @km-aero https://github.com/km-aero, thanks for raising this issue. I'm happy to help you. May I ask, are you looking to implement metrics on a CloudWatch Alarm Metric https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudwatch_metric_alarm or on a CloudWatch Log Metric Filter https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudwatch_log_metric_filter ?

Both of these resources support dimensions.

— Reply to this email directly, view it on GitHub https://github.com/hashicorp/terraform-provider-aws/issues/27130#issuecomment-1273870836, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOS4LI25HTMEXDW56YGV7DLWCSJSVANCNFSM6AAAAAAQ63CZSU . You are receiving this because you were mentioned.Message ID: @.***>

github-actions[bot] commented 2 days ago

Marking this issue as stale due to inactivity. This helps our maintainers find and focus on the active issues. If this issue receives no comments in the next 30 days it will automatically be closed. Maintainers can also remove the stale label.

If this issue was automatically closed and you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thank you!