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

[datadog_metric_metadata] correct consistency of type #2222

Merged
merged 3 commits into from
Jan 10, 2024

Conversation

fl0Lec
Copy link
Contributor

@fl0Lec fl0Lec commented Dec 22, 2023

Motivation

It appears that metric API has enable the distribution type on metric metadata but the result between the PUT and the GET method is not consistent:

$ export metric_name=name_of_metric_distribution
$ curl -X PUT "https://api.datadoghq.com/api/v1/metrics/${metric_name}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ***" \
-H "DD-APPLICATION-KEY: ***" \
-d @- << EOF
{"type":"gauge"}
EOF
{"description":null,"short_name":null,"type":"gauge","unit":null,"per_unit":null,"statsd_interval":null,"integration":null}
and then the get:
$ curl -X GET "https://api.datadoghq.com/api/v1/metrics/${metric_name}" \
-H "Accept: application/json" \
-H "DD-API-KEY: ***" \
-H "DD-APPLICATION-KEY: ***" \
{"description":null,"short_name":null,"type":"distribution","unit":null,"per_unit":null,"statsd_interval":null,"integration":null}

this make metric type always being marked has a diff:

terraform plan
~ resource "datadog_metric_metadata" "metric_name" {
        id              = "metric_name"
      ~ type            = "distribution" -> "gauge"
        # (5 unchanged attributes hidden)
    }

Scope

Set metric type to gauge in terraform state when type return by API is distribution

Test

Test no diff locally

make build
cd terraformdir
terraform plan
...
No changes. Your infrastructure matches the configuration.

@fl0Lec fl0Lec requested review from a team as code owners December 22, 2023 13:59
@fl0Lec fl0Lec self-assigned this Dec 22, 2023
Motivation
---------
It appears that metric API has enable the distribution type on metric
metadata but the result between the `PUT` and the `GET` method is not
consistent:

```bash
export metric_name=name_of_metric_distribution
curl -X PUT "https://api.datadoghq.com/api/v1/metrics/${metric_name}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ***" \
-H "DD-APPLICATION-KEY: ***" \
-d @- << EOF
{"type":"gauge"}
EOF
{"description":null,"short_name":null,"type":"gauge","unit":null,"per_unit":null,"statsd_interval":null,"integration":null}
and then the get:
$ curl -X GET "https://api.datadoghq.com/api/v1/metrics/${metric_name}" \
-H "Accept: application/json" \
-H "DD-API-KEY: ***" \
-H "DD-APPLICATION-KEY: ***" \
{"description":null,"short_name":null,"type":"distribution","unit":null,"per_unit":null,"statsd_interval":null,"integration":null}
```

this make metric type always being marked has a diff:
```
terraform plan
~ resource "datadog_metric_metadata" "metric_name" {
        id              = "metric_name"
      ~ type            = "distribution" -> "gauge"
        # (5 unchanged attributes hidden)
    }
```

Scope
----
Set metric type to gauge in terraform state when type return by API is
distribution

Test
----
Test no diff locally
```bash
make build
cd terraformdir
terraform plan
...
No changes. Your infrastructure matches the configuration.
```
@fl0Lec fl0Lec force-pushed the fl/metric-metadata-type-consistency branch from 1755dbc to 99b3209 Compare December 22, 2023 14:33
jmfurlott
jmfurlott previously approved these changes Jan 4, 2024
datadog/resource_datadog_metric_metadata.go Show resolved Hide resolved
@fl0Lec fl0Lec requested a review from a team as a code owner January 10, 2024 18:07
nkzou
nkzou previously approved these changes Jan 10, 2024
Copy link
Contributor

@maycmlee maycmlee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of small suggestions and a request!

@@ -36,7 +36,7 @@ resource "datadog_metric_metadata" "request_time" {
- `per_unit` (String) Per unit of the metric such as `second` in `bytes per second`.
- `short_name` (String) A short name of the metric.
- `statsd_interval` (Number) If applicable, statsd flush interval in seconds for the metric.
- `type` (String) Metric type such as `gauge` or `rate`.
- `type` (String) Metric type such as `count`, `gauge`, or `rate`. Updating a metric of type `distribution` is not supported. If you would like to see the `distribution` type returned, please contact Datadog support.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- `type` (String) Metric type such as `count`, `gauge`, or `rate`. Updating a metric of type `distribution` is not supported. If you would like to see the `distribution` type returned, please contact Datadog support.
- `type` (String) Metric type such as `count`, `gauge`, or `rate`. Updating a metric of type `distribution` is not supported. If you would like to see the `distribution` type returned, contact Datadog support.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be helpful to link "Datadog support" to https://docs.datadoghq.com/help/.

Also, since you mention contacting support, could you also add an entry to this doc so Support knows how to handle the request? https://datadoghq.atlassian.net/wiki/spaces/TS/pages/328404964/The+Public+Docs+say+Contact+Support

@nkzou nkzou merged commit 6171264 into master Jan 10, 2024
9 checks passed
@nkzou nkzou deleted the fl/metric-metadata-type-consistency branch January 10, 2024 18:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants