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

data source to retrieve a list of all of custom cloudwatch metrics #3644

Closed
tchia04 opened this issue Mar 6, 2018 · 6 comments
Closed

data source to retrieve a list of all of custom cloudwatch metrics #3644

tchia04 opened this issue Mar 6, 2018 · 6 comments
Labels
new-data-source Introduces a new data source. service/cloudwatch Issues and PRs that pertain to the cloudwatch service. stale Old or inactive issues managed by automation, if no further action taken these will get closed.

Comments

@tchia04
Copy link

tchia04 commented Mar 6, 2018

It would be nice to have a data source for custom cloudwatch metrics. I manually build my own bash shell script to get the list of custom metric by namespace and then use that list to generate the cloudwatch alarms.

@bflad bflad added new-data-source Introduces a new data source. service/cloudwatch Issues and PRs that pertain to the cloudwatch service. labels Mar 7, 2018
@viesti
Copy link

viesti commented Apr 11, 2019

Same need here, I was looking for rewriting old Ansible script that looks up disk usage metric for all nodes in Redshift cluster and creates alarms for the metrics. A data source that would allow querying Cloudwatch metrics would fit here nicely.

@viesti
Copy link

viesti commented Apr 15, 2019

I was able to overcome this via external data source, by querying metrics via aws cli and outputting a | delimited string, to overcome the lack of support of arrays in the JSON returned by external data source:

data "external" "redshift-nodes-with-disk-usage-metric" {
  program = [
    "aws",
    "cloudwatch",
    "list-metrics",
    "--namespace", "AWS/Redshift",
    "--metric-name", "PercentageDiskSpaceUsed",
    "--dimensions", "Name=ClusterIdentifier,Value=${aws_redshift_cluster.my-cluster.id}",
    "--query", "Metrics[].Dimensions[?Name=='NodeID'].Value[] | {Nodes: join('|', @)}",
    "--out", "json"]
}

The JMESPath looks a bit hairy in this case, but anyway, a external data source might be workable solution.

@wardviaene
Copy link
Contributor

I spent some time working on a datasource for aws cloudwatch metrics, but it seems to be difficult to write an acceptance test for it. There are no cloudwatch metrics in an AWS account, unless you do a cloudwatch PutMetricData, which is not implemented in any terraform datasource/resource. The WIP code can be found here: master...wardviaene:f-aws_cloudwatch_metrics

@wardviaene
Copy link
Contributor

Submitted a PR: #14253

@github-actions
Copy link

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!

@github-actions github-actions bot added the stale Old or inactive issues managed by automation, if no further action taken these will get closed. label Jul 11, 2022
@github-actions
Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
new-data-source Introduces a new data source. service/cloudwatch Issues and PRs that pertain to the cloudwatch service. stale Old or inactive issues managed by automation, if no further action taken these will get closed.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants