zorkian / go-datadog-api

A Go implementation of the Datadog API.
BSD 3-Clause "New" or "Revised" License
183 stars 156 forks source link

Change service level objective history response structs #330

Open t-sato opened 3 years ago

t-sato commented 3 years ago

Changed the response struct of SLO's history API.

The SLO's history API response seems to be different from the documentation and actual response. Documentation: https://docs.datadoghq.com/api/v1/service-level-objectives/#get-an-slos-history: Maybe the documentation is also old.

API Response is this. ``` { "errors": null, "data": { "to_ts": 1604242800, "type_id": 0, "thresholds": { "7d": { "warning": 99.99, "warning_display": "99.99", "target": 99.9, "target_display": "99.9", "timeframe": "7d" }, "30d": { "warning": 99.99, "warning_display": "99.99", "target": 99.9, "target_display": "99.9", "timeframe": "30d" } }, "overall": { "span_precision": 1, "precision": { "7d": 2, "30d": 2, "custom": 1 }, "sli_value": 100, "errors": null, "preview": false, "history": [ [ 1604156400, 0 ] ] }, "from_ts": 1604156400, "slo": { "description": "xxxxxxx", "monitor_tags": [ "service:service", "area:area", "env:env" ], "creator": { "handle": "xxxxx", "name": "xxxxx", "email": "xxxxx" }, "thresholds": [ { "warning": 99.99, "warning_display": "99.99", "target": 99.9, "target_display": "99.9", "timeframe": "7d" }, { "warning": 99.99, "warning_display": "99.99", "target": 99.9, "target_display": "99.9", "timeframe": "30d" } ], "type_id": 0, "id": "xxxxxxx", "monitor_ids": [ xxxxxxx, xxxxxxx ], "name": "xxxxxx", "created_at": 1603702727, "tags": [ "service:service", ], "modified_at": 1603783363, "type": "monitor" }, "type": "monitor", "monitors": [ { "precision": 1, "monitor_modified": 1603783363, "span_precision": 1, "id": xxxxxxx, "errors": null, "name": "xxxxxxx", "sli_value": 100, "preview": false, "monitor_type": "query alert", "history": [ [ 1604156400, 0 ] ] } ] } } ```

above API response is monitor base SLO.

I know there was an update recently. https://app.datadoghq.com/release_notes#create-and-manage-datadog-slos-via-api

so I changed the following.

This PR changed monitor-based SLO only.