From 182661a47793313e5d3c4ec2d62f30f5d8cbb0f8 Mon Sep 17 00:00:00 2001 From: t-sato Date: Thu, 26 Nov 2020 18:04:22 +0900 Subject: [PATCH 1/6] go fmt --- client.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client.go b/client.go index 39558ef..af276c4 100644 --- a/client.go +++ b/client.go @@ -99,7 +99,7 @@ func (client *Client) Validate() (bool, error) { return false, err } req.Header.Set("DD-API-KEY", client.apiKey) - if (client.appKey != "") { + if client.appKey != "" { req.Header.Set("DD-APPLICATION-KEY", client.appKey) } From b8d9e94e2d5269e5df4682945b2c67647243263e Mon Sep 17 00:00:00 2001 From: t-sato Date: Thu, 26 Nov 2020 18:09:52 +0900 Subject: [PATCH 2/6] Change service level objective history response --- datadog-accessors.go | 31 ++++++++++++ service_level_objectives.go | 21 ++++---- service_level_objectives_test.go | 48 +++++++++++++++++-- .../get_history_monitor_response.json | 39 ++++++++++++++- 4 files changed, 127 insertions(+), 12 deletions(-) diff --git a/datadog-accessors.go b/datadog-accessors.go index a845434..68a6b74 100644 --- a/datadog-accessors.go +++ b/datadog-accessors.go @@ -19358,6 +19358,37 @@ func (s *ServiceLevelObjectiveHistoryResponseData) SetOverall(v ServiceLevelObje s.Overall = &v } +// GetSlo returns the Slo field if non-nil, zero value otherwise. +func (s *ServiceLevelObjectiveHistoryResponseData) GetSlo() ServiceLevelObjective { + if s == nil || s.Slo == nil { + return ServiceLevelObjective{} + } + return *s.Slo +} + +// GetSloOk returns a tuple with the Slo field if it's non-nil, zero value otherwise +// and a boolean to check if the value has been set. +func (s *ServiceLevelObjectiveHistoryResponseData) GetSloOk() (ServiceLevelObjective, bool) { + if s == nil || s.Slo == nil { + return ServiceLevelObjective{}, false + } + return *s.Slo, true +} + +// HasSlo returns a boolean if a field has been set. +func (s *ServiceLevelObjectiveHistoryResponseData) HasSlo() bool { + if s != nil && s.Slo != nil { + return true + } + + return false +} + +// SetSlo allocates a new s.Slo and returns the pointer to it. +func (s *ServiceLevelObjectiveHistoryResponseData) SetSlo(v ServiceLevelObjective) { + s.Slo = &v +} + // GetDenominator returns the Denominator field if non-nil, zero value otherwise. func (s *ServiceLevelObjectiveMetricQuery) GetDenominator() string { if s == nil || s.Denominator == nil { diff --git a/service_level_objectives.go b/service_level_objectives.go index 0301e40..b954522 100644 --- a/service_level_objectives.go +++ b/service_level_objectives.go @@ -525,12 +525,15 @@ type ServiceLevelObjectiveHistoryMetricSeries struct { // ServiceLevelObjectiveHistoryMonitorSeries defines the SLO history data response for `monitor` type SLOs type ServiceLevelObjectiveHistoryMonitorSeries struct { - SliValue float32 `json:"sli_value"` - SpanPrecision json.Number `json:"span_precision"` - Name string `json:"name"` - Precision map[string]json.Number `json:"precision"` - Preview bool `json:"preview"` - History []ServiceLevelObjectiveHistorySeriesPoint `json:"history"` + SliValue float32 `json:"sli_value"` + SpanPrecision json.Number `json:"span_precision"` + Name string `json:"name"` + Precision map[string]json.Number `json:"precision"` + Preview bool `json:"preview"` + History []ServiceLevelObjectiveHistorySeriesPoint `json:"history"` + MonitorType string `json:"monitor_type"` + MonitorModified int64 `json:"monitor_modified"` + Errors []string `json:"errors"` } // ServiceLevelObjectiveHistoryOverall defines the overall SLO history data response @@ -547,7 +550,7 @@ type ServiceLevelObjectiveHistoryOverall struct { } // ServiceLevelObjectiveHistoryResponseData contains the SLO history data response. -// for `monitor` based SLOs use the `Groups` property for historical data along with the `Overall.History` +// for `monitor` based SLOs use the `Monitors` property for historical data along with the `Overall.History` // for `metric` based SLOs use the `Metrics` property for historical data. This contains `batch_query` like response // data type ServiceLevelObjectiveHistoryResponseData struct { @@ -556,12 +559,14 @@ type ServiceLevelObjectiveHistoryResponseData struct { FromTs int64 `json:"from_ts"` Thresholds map[string]ServiceLevelObjectiveThreshold `json:"thresholds"` Overall *ServiceLevelObjectiveHistoryOverall `json:"overall"` + Slo *ServiceLevelObjective `json:"slo"` + Type string `json:"type"` // metric based SLO Metrics *ServiceLevelObjectiveHistoryMetricSeries `json:"series"` // monitor based SLO - Groups []*ServiceLevelObjectiveHistoryMonitorSeries `json:"groups"` + Monitors []*ServiceLevelObjectiveHistoryMonitorSeries `json:"monitors"` } // ServiceLevelObjectiveHistoryResponse is the canonical response for SLO history data. diff --git a/service_level_objectives_test.go b/service_level_objectives_test.go index 34ce864..29e4335 100644 --- a/service_level_objectives_test.go +++ b/service_level_objectives_test.go @@ -351,9 +351,51 @@ func TestServiceLevelObjectiveIntegration(t *testing.T) { assert.NoError(t2, err) assert.Nil(t2, resp.Error) assert.Equal(t2, float32(6.765872955322266), resp.Data.Overall.SliValue) - assert.Len(t2, resp.Data.Groups, 1) - assert.Equal(t2, float32(6.765872955322266), resp.Data.Groups[0].SliValue) - assert.Equal(t2, "some:tag", resp.Data.Groups[0].Name) + + typeID := 0 + createdAt := 1563283800 + modifiedAt := 1563283800 + slo := &ServiceLevelObjective{ + ID: sptr("12345678901234567890123456789012"), + Name: sptr("Test SLO"), + Description: sptr("test slo description"), + Tags: []string{"product:foo"}, + Thresholds: []*ServiceLevelObjectiveThreshold{ + { + TimeFrame: String("7d"), + Target: Float64(99), + TargetDisplay: String("99.0"), + Warning: Float64(99.5), + WarningDisplay: String("99.5"), + }, + { + TimeFrame: String("30d"), + Target: Float64(98), + TargetDisplay: String("98.0"), + Warning: Float64(99), + WarningDisplay: String("99.0"), + }, + }, + Type: sptr("monitor"), + TypeID: &typeID, + MonitorIDs: []int{1}, + MonitorTags: []string{"service:bar", "team:a"}, + Creator: &Creator{ + Handle: sptr("jane.doe@example.com"), + Email: sptr("jane.doe@example.com"), + Name: sptr("Jane Doe"), + }, + CreatedAt: &createdAt, + ModifiedAt: &modifiedAt, + } + assert.Equal(t2, slo, resp.Data.Slo) + assert.Equal(t2, "monitor", resp.Data.Type) + + assert.Len(t2, resp.Data.Monitors, 1) + assert.Equal(t2, float32(6.765872955322266), resp.Data.Monitors[0].SliValue) + assert.Equal(t2, "some:tag", resp.Data.Monitors[0].Name) + assert.Equal(t2, "query alert", resp.Data.Monitors[0].MonitorType) + assert.Equal(t2, int64(1563283800), resp.Data.Monitors[0].MonitorModified) }) } diff --git a/tests/fixtures/service_level_objectives/get_history_monitor_response.json b/tests/fixtures/service_level_objectives/get_history_monitor_response.json index 8b9a997..615a67c 100644 --- a/tests/fixtures/service_level_objectives/get_history_monitor_response.json +++ b/tests/fixtures/service_level_objectives/get_history_monitor_response.json @@ -585,7 +585,41 @@ ] }, "from_ts": 1571162100, - "groups": [ + "slo": { + "id": "12345678901234567890123456789012", + "name": "Test SLO", + "tags": ["product:foo"], + "monitor_tags": ["service:bar", "team:a"], + "type": "monitor", + "type_id": 0, + "description": "test slo description", + "monitor_ids": [1], + "thresholds": [ + { + "timeframe": "7d", + "target": 99.0, + "target_display": "99.0", + "warning": 99.5, + "warning_display": "99.5" + }, + { + "timeframe": "30d", + "target": 98, + "target_display": "98.0", + "warning": 99, + "warning_display": "99.0" + } + ], + "creator": { + "handle": "jane.doe@example.com", + "email": "jane.doe@example.com", + "name": "Jane Doe" + }, + "created_at": 1563283800, + "modified_at": 1563283800 + }, + "type": "monitor", + "monitors": [ { "sli_value": 6.765872955322266, "span_precision": 2, @@ -594,6 +628,9 @@ "7d": 2 }, "preview": true, + "monitor_type": "query alert", + "errors": null, + "monitor_modified": 1563283800, "history": [ [ 1571139968, From c38794aa7ed68e819b8cd4a745660bc24b5f42bc Mon Sep 17 00:00:00 2001 From: t-sato Date: Sat, 28 Nov 2020 03:00:24 +0900 Subject: [PATCH 3/6] Revert data.groups --- service_level_objectives.go | 3 +- service_level_objectives_test.go | 4 + .../get_history_monitor_response.json | 577 ++++++++++++++++++ 3 files changed, 583 insertions(+), 1 deletion(-) diff --git a/service_level_objectives.go b/service_level_objectives.go index b954522..7e80bf1 100644 --- a/service_level_objectives.go +++ b/service_level_objectives.go @@ -550,7 +550,7 @@ type ServiceLevelObjectiveHistoryOverall struct { } // ServiceLevelObjectiveHistoryResponseData contains the SLO history data response. -// for `monitor` based SLOs use the `Monitors` property for historical data along with the `Overall.History` +// for `monitor` based SLOs use the `Groups` property for historical data along with the `Overall.History` // for `metric` based SLOs use the `Metrics` property for historical data. This contains `batch_query` like response // data type ServiceLevelObjectiveHistoryResponseData struct { @@ -566,6 +566,7 @@ type ServiceLevelObjectiveHistoryResponseData struct { Metrics *ServiceLevelObjectiveHistoryMetricSeries `json:"series"` // monitor based SLO + Groups []*ServiceLevelObjectiveHistoryMonitorSeries `json:"groups"` Monitors []*ServiceLevelObjectiveHistoryMonitorSeries `json:"monitors"` } diff --git a/service_level_objectives_test.go b/service_level_objectives_test.go index 29e4335..268851e 100644 --- a/service_level_objectives_test.go +++ b/service_level_objectives_test.go @@ -391,6 +391,10 @@ func TestServiceLevelObjectiveIntegration(t *testing.T) { assert.Equal(t2, slo, resp.Data.Slo) assert.Equal(t2, "monitor", resp.Data.Type) + assert.Len(t2, resp.Data.Groups, 1) + assert.Equal(t2, float32(6.765872955322266), resp.Data.Groups[0].SliValue) + assert.Equal(t2, "some:tag", resp.Data.Groups[0].Name) + assert.Len(t2, resp.Data.Monitors, 1) assert.Equal(t2, float32(6.765872955322266), resp.Data.Monitors[0].SliValue) assert.Equal(t2, "some:tag", resp.Data.Monitors[0].Name) diff --git a/tests/fixtures/service_level_objectives/get_history_monitor_response.json b/tests/fixtures/service_level_objectives/get_history_monitor_response.json index 615a67c..af902cd 100644 --- a/tests/fixtures/service_level_objectives/get_history_monitor_response.json +++ b/tests/fixtures/service_level_objectives/get_history_monitor_response.json @@ -585,6 +585,583 @@ ] }, "from_ts": 1571162100, + "groups": [ + { + "sli_value": 6.765872955322266, + "span_precision": 2, + "name": "some:tag", + "precision": { + "7d": 2 + }, + "preview": true, + "history": [ + [ + 1571139968, + 1 + ], + [ + 1571185988, + 0 + ], + [ + 1571187248, + 1 + ], + [ + 1571200628, + 0 + ], + [ + 1571201408, + 1 + ], + [ + 1571242748, + 0 + ], + [ + 1571242868, + 1 + ], + [ + 1571315828, + 0 + ], + [ + 1571316548, + 1 + ], + [ + 1571330108, + 0 + ], + [ + 1571331008, + 1 + ], + [ + 1571344388, + 0 + ], + [ + 1571345408, + 1 + ], + [ + 1571358968, + 0 + ], + [ + 1571359748, + 1 + ], + [ + 1571369588, + 0 + ], + [ + 1571369708, + 1 + ], + [ + 1571370788, + 0 + ], + [ + 1571370908, + 1 + ], + [ + 1571371688, + 0 + ], + [ + 1571371988, + 1 + ], + [ + 1571376188, + 0 + ], + [ + 1571378408, + 1 + ], + [ + 1571382428, + 0 + ], + [ + 1571382548, + 1 + ], + [ + 1571383868, + 0 + ], + [ + 1571384228, + 1 + ], + [ + 1571385848, + 0 + ], + [ + 1571386508, + 1 + ], + [ + 1571387768, + 0 + ], + [ + 1571388488, + 1 + ], + [ + 1571389328, + 0 + ], + [ + 1571389988, + 1 + ], + [ + 1571390468, + 0 + ], + [ + 1571390528, + 1 + ], + [ + 1571392508, + 0 + ], + [ + 1571393348, + 1 + ], + [ + 1571393528, + 0 + ], + [ + 1571393828, + 1 + ], + [ + 1571394608, + 0 + ], + [ + 1571395868, + 1 + ], + [ + 1571396408, + 0 + ], + [ + 1571396648, + 1 + ], + [ + 1571398028, + 0 + ], + [ + 1571400848, + 1 + ], + [ + 1571402348, + 0 + ], + [ + 1571402588, + 1 + ], + [ + 1571416688, + 0 + ], + [ + 1571417228, + 1 + ], + [ + 1571445368, + 0 + ], + [ + 1571446208, + 1 + ], + [ + 1571457908, + 0 + ], + [ + 1571458448, + 1 + ], + [ + 1571465588, + 0 + ], + [ + 1571465768, + 1 + ], + [ + 1571468828, + 0 + ], + [ + 1571468948, + 1 + ], + [ + 1571470088, + 0 + ], + [ + 1571470628, + 1 + ], + [ + 1571472128, + 0 + ], + [ + 1571472848, + 1 + ], + [ + 1571473988, + 0 + ], + [ + 1571474408, + 1 + ], + [ + 1571477528, + 0 + ], + [ + 1571477768, + 1 + ], + [ + 1571479748, + 0 + ], + [ + 1571480048, + 1 + ], + [ + 1571481008, + 0 + ], + [ + 1571481188, + 1 + ], + [ + 1571481968, + 0 + ], + [ + 1571482448, + 1 + ], + [ + 1571483048, + 0 + ], + [ + 1571483588, + 1 + ], + [ + 1571485208, + 0 + ], + [ + 1571485748, + 1 + ], + [ + 1571486288, + 0 + ], + [ + 1571487128, + 1 + ], + [ + 1571487548, + 0 + ], + [ + 1571487908, + 1 + ], + [ + 1571490848, + 0 + ], + [ + 1571491028, + 1 + ], + [ + 1571502848, + 0 + ], + [ + 1571502908, + 1 + ], + [ + 1571544188, + 0 + ], + [ + 1571544788, + 1 + ], + [ + 1571546228, + 0 + ], + [ + 1571546408, + 1 + ], + [ + 1571550728, + 0 + ], + [ + 1571552048, + 1 + ], + [ + 1571555108, + 0 + ], + [ + 1571555288, + 1 + ], + [ + 1571558588, + 0 + ], + [ + 1571559248, + 1 + ], + [ + 1571560388, + 0 + ], + [ + 1571561468, + 1 + ], + [ + 1571562668, + 0 + ], + [ + 1571562908, + 1 + ], + [ + 1571563928, + 0 + ], + [ + 1571564048, + 1 + ], + [ + 1571565248, + 0 + ], + [ + 1571566328, + 1 + ], + [ + 1571568188, + 0 + ], + [ + 1571569388, + 1 + ], + [ + 1571570348, + 0 + ], + [ + 1571571068, + 1 + ], + [ + 1571572628, + 0 + ], + [ + 1571573588, + 1 + ], + [ + 1571573888, + 0 + ], + [ + 1571574068, + 1 + ], + [ + 1571574788, + 0 + ], + [ + 1571575808, + 1 + ], + [ + 1571576948, + 0 + ], + [ + 1571577428, + 1 + ], + [ + 1571589428, + 0 + ], + [ + 1571589608, + 1 + ], + [ + 1571603768, + 0 + ], + [ + 1571604668, + 1 + ], + [ + 1571617988, + 0 + ], + [ + 1571619008, + 1 + ], + [ + 1571631068, + 0 + ], + [ + 1571631308, + 1 + ], + [ + 1571632448, + 0 + ], + [ + 1571632928, + 1 + ], + [ + 1571635148, + 0 + ], + [ + 1571635268, + 1 + ], + [ + 1571637068, + 0 + ], + [ + 1571638508, + 1 + ], + [ + 1571649188, + 0 + ], + [ + 1571649248, + 1 + ], + [ + 1571653328, + 0 + ], + [ + 1571653448, + 1 + ], + [ + 1571655728, + 0 + ], + [ + 1571655788, + 1 + ], + [ + 1571657948, + 0 + ], + [ + 1571659028, + 1 + ], + [ + 1571660228, + 0 + ], + [ + 1571660468, + 1 + ], + [ + 1571661128, + 0 + ], + [ + 1571661488, + 1 + ], + [ + 1571663408, + 0 + ], + [ + 1571663768, + 1 + ] + ] + } + ], "slo": { "id": "12345678901234567890123456789012", "name": "Test SLO", From 49bebe9a34811ee338ed7c0f6e0901f7031e2a37 Mon Sep 17 00:00:00 2001 From: t-sato Date: Wed, 2 Dec 2020 03:04:18 +0900 Subject: [PATCH 4/6] Add ID to ServiceLevelObjectiveHistoryMonitorSeries --- service_level_objectives.go | 1 + service_level_objectives_test.go | 1 + .../service_level_objectives/get_history_monitor_response.json | 1 + 3 files changed, 3 insertions(+) diff --git a/service_level_objectives.go b/service_level_objectives.go index 7e80bf1..b81d4ca 100644 --- a/service_level_objectives.go +++ b/service_level_objectives.go @@ -531,6 +531,7 @@ type ServiceLevelObjectiveHistoryMonitorSeries struct { Precision map[string]json.Number `json:"precision"` Preview bool `json:"preview"` History []ServiceLevelObjectiveHistorySeriesPoint `json:"history"` + ID int64 `json:"id"` MonitorType string `json:"monitor_type"` MonitorModified int64 `json:"monitor_modified"` Errors []string `json:"errors"` diff --git a/service_level_objectives_test.go b/service_level_objectives_test.go index 268851e..8adedf4 100644 --- a/service_level_objectives_test.go +++ b/service_level_objectives_test.go @@ -396,6 +396,7 @@ func TestServiceLevelObjectiveIntegration(t *testing.T) { assert.Equal(t2, "some:tag", resp.Data.Groups[0].Name) assert.Len(t2, resp.Data.Monitors, 1) + assert.Equal(t2, int64(12345678), resp.Data.Monitors[0].ID) assert.Equal(t2, float32(6.765872955322266), resp.Data.Monitors[0].SliValue) assert.Equal(t2, "some:tag", resp.Data.Monitors[0].Name) assert.Equal(t2, "query alert", resp.Data.Monitors[0].MonitorType) diff --git a/tests/fixtures/service_level_objectives/get_history_monitor_response.json b/tests/fixtures/service_level_objectives/get_history_monitor_response.json index af902cd..de64a1e 100644 --- a/tests/fixtures/service_level_objectives/get_history_monitor_response.json +++ b/tests/fixtures/service_level_objectives/get_history_monitor_response.json @@ -1200,6 +1200,7 @@ { "sli_value": 6.765872955322266, "span_precision": 2, + "id": 12345678, "name": "some:tag", "precision": { "7d": 2 From 8e3c38705eca030c755397aecd27bffd4b233a61 Mon Sep 17 00:00:00 2001 From: t-sato Date: Thu, 3 Dec 2020 02:12:56 +0900 Subject: [PATCH 5/6] Add Precision type in ServiceLevelObjectiveHistoryMonitorSeries --- service_level_objectives.go | 2 +- service_level_objectives_test.go | 4 ++++ .../get_history_monitor_response.json | 8 ++------ 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/service_level_objectives.go b/service_level_objectives.go index b81d4ca..6607448 100644 --- a/service_level_objectives.go +++ b/service_level_objectives.go @@ -528,7 +528,7 @@ type ServiceLevelObjectiveHistoryMonitorSeries struct { SliValue float32 `json:"sli_value"` SpanPrecision json.Number `json:"span_precision"` Name string `json:"name"` - Precision map[string]json.Number `json:"precision"` + Precision json.Number `json:"precision"` Preview bool `json:"preview"` History []ServiceLevelObjectiveHistorySeriesPoint `json:"history"` ID int64 `json:"id"` diff --git a/service_level_objectives_test.go b/service_level_objectives_test.go index 8adedf4..b95a857 100644 --- a/service_level_objectives_test.go +++ b/service_level_objectives_test.go @@ -394,6 +394,8 @@ func TestServiceLevelObjectiveIntegration(t *testing.T) { assert.Len(t2, resp.Data.Groups, 1) assert.Equal(t2, float32(6.765872955322266), resp.Data.Groups[0].SliValue) assert.Equal(t2, "some:tag", resp.Data.Groups[0].Name) + group_precision, _ := resp.Data.Groups[0].Precision.Int64() + assert.Equal(t2, int64(1), group_precision) assert.Len(t2, resp.Data.Monitors, 1) assert.Equal(t2, int64(12345678), resp.Data.Monitors[0].ID) @@ -401,6 +403,8 @@ func TestServiceLevelObjectiveIntegration(t *testing.T) { assert.Equal(t2, "some:tag", resp.Data.Monitors[0].Name) assert.Equal(t2, "query alert", resp.Data.Monitors[0].MonitorType) assert.Equal(t2, int64(1563283800), resp.Data.Monitors[0].MonitorModified) + monitor_precision, _ := resp.Data.Monitors[0].Precision.Int64() + assert.Equal(t2, int64(1), monitor_precision) }) } diff --git a/tests/fixtures/service_level_objectives/get_history_monitor_response.json b/tests/fixtures/service_level_objectives/get_history_monitor_response.json index de64a1e..e86fb8a 100644 --- a/tests/fixtures/service_level_objectives/get_history_monitor_response.json +++ b/tests/fixtures/service_level_objectives/get_history_monitor_response.json @@ -590,9 +590,7 @@ "sli_value": 6.765872955322266, "span_precision": 2, "name": "some:tag", - "precision": { - "7d": 2 - }, + "precision": 1, "preview": true, "history": [ [ @@ -1202,9 +1200,7 @@ "span_precision": 2, "id": 12345678, "name": "some:tag", - "precision": { - "7d": 2 - }, + "precision": 1, "preview": true, "monitor_type": "query alert", "errors": null, From 0070fb21695419366ae5adbb56bd6bf6c6e3b438 Mon Sep 17 00:00:00 2001 From: t-sato Date: Thu, 24 Dec 2020 17:20:28 +0900 Subject: [PATCH 6/6] Add ServiceLevelObjectiveHistoryMonitorSeriesError --- service_level_objectives.go | 26 ++++++++++++------- service_level_objectives_test.go | 2 ++ .../get_history_monitor_response.json | 7 ++++- 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/service_level_objectives.go b/service_level_objectives.go index 6607448..3fad1ac 100644 --- a/service_level_objectives.go +++ b/service_level_objectives.go @@ -525,16 +525,22 @@ type ServiceLevelObjectiveHistoryMetricSeries struct { // ServiceLevelObjectiveHistoryMonitorSeries defines the SLO history data response for `monitor` type SLOs type ServiceLevelObjectiveHistoryMonitorSeries struct { - SliValue float32 `json:"sli_value"` - SpanPrecision json.Number `json:"span_precision"` - Name string `json:"name"` - Precision json.Number `json:"precision"` - Preview bool `json:"preview"` - History []ServiceLevelObjectiveHistorySeriesPoint `json:"history"` - ID int64 `json:"id"` - MonitorType string `json:"monitor_type"` - MonitorModified int64 `json:"monitor_modified"` - Errors []string `json:"errors"` + SliValue float32 `json:"sli_value"` + SpanPrecision json.Number `json:"span_precision"` + Name string `json:"name"` + Precision json.Number `json:"precision"` + Preview bool `json:"preview"` + History []ServiceLevelObjectiveHistorySeriesPoint `json:"history"` + ID int64 `json:"id"` + MonitorType string `json:"monitor_type"` + MonitorModified int64 `json:"monitor_modified"` + Errors []ServiceLevelObjectiveHistoryMonitorSeriesError `json:"errors"` +} + +// ServiceLevelObjectiveHistoryMonitorSeriesError is the error specific to monitors. +type ServiceLevelObjectiveHistoryMonitorSeriesError struct { + ErrorType string `json:"error_type"` + ErrorMessage string `json:"error_message"` } // ServiceLevelObjectiveHistoryOverall defines the overall SLO history data response diff --git a/service_level_objectives_test.go b/service_level_objectives_test.go index b95a857..49743bf 100644 --- a/service_level_objectives_test.go +++ b/service_level_objectives_test.go @@ -405,6 +405,8 @@ func TestServiceLevelObjectiveIntegration(t *testing.T) { assert.Equal(t2, int64(1563283800), resp.Data.Monitors[0].MonitorModified) monitor_precision, _ := resp.Data.Monitors[0].Precision.Int64() assert.Equal(t2, int64(1), monitor_precision) + assert.Equal(t2, "ERROR_TYPE", resp.Data.Monitors[0].Errors[0].ErrorType) + assert.Equal(t2, "error message", resp.Data.Monitors[0].Errors[0].ErrorMessage) }) } diff --git a/tests/fixtures/service_level_objectives/get_history_monitor_response.json b/tests/fixtures/service_level_objectives/get_history_monitor_response.json index e86fb8a..4e6faf8 100644 --- a/tests/fixtures/service_level_objectives/get_history_monitor_response.json +++ b/tests/fixtures/service_level_objectives/get_history_monitor_response.json @@ -1203,7 +1203,12 @@ "precision": 1, "preview": true, "monitor_type": "query alert", - "errors": null, + "errors": [ + { + "error_type": "ERROR_TYPE", + "error_message": "error message" + } + ], "monitor_modified": 1563283800, "history": [ [