go-datadog-api icon indicating copy to clipboard operation
go-datadog-api copied to clipboard

Change service level objective history response structs

Open t-sato opened this issue 5 years ago • 0 comments

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.

  • Change data.groups to data.monitors
  • Add new shemas
    • data.slo
      • it's maybe ServiceLevelObjective
  • Add the missing schemas
    • data.type
    • data.monitors[].monitor_type
    • data.monitors[].monitor_modified
    • data.monitors[].errors

This PR changed monitor-based SLO only.

t-sato avatar Nov 26 '20 09:11 t-sato