From 2c07e50d0741970133afb69e7cfb3a19761c4f12 Mon Sep 17 00:00:00 2001 From: Deepak Chhikara Date: Tue, 28 Nov 2023 10:34:10 +0530 Subject: [PATCH 1/4] [fix]: [SRM-16226]: Adding health source deseralizr --- .../resource.tf | 89 +++++++++++++++++++ .../data_source_monitored_service_test.go | 47 ++++++++++ 2 files changed, 136 insertions(+) diff --git a/examples/resources/harness_platform_monitored_service/resource.tf b/examples/resources/harness_platform_monitored_service/resource.tf index 512053c0f..ff986860c 100644 --- a/examples/resources/harness_platform_monitored_service/resource.tf +++ b/examples/resources/harness_platform_monitored_service/resource.tf @@ -104,6 +104,22 @@ resource "harness_platform_monitored_service" "example1" { liveMonitoringEnabled = "true" continuousVerificationEnabled = "true" sliEnabled = "false" + metricThresholds: [ + { + type: "IgnoreThreshold", + spec: { + action: "Ignore" + }, + criteria: { + type: "Absolute", + spec: { + greaterThan: 100 + } + }, + metricType: "Custom", + metricName: "metric_cpu" + } + ] }, { name = "name2" @@ -225,6 +241,22 @@ resource "harness_platform_monitored_service" "example3" { liveMonitoringEnabled = "true" continuousVerificationEnabled = "false" sliEnabled = "false" + metricThresholds: [ + { + type: "IgnoreThreshold", + spec: { + action: "Ignore" + }, + criteria: { + type: "Absolute", + spec: { + greaterThan: 100 + } + }, + metricType: "Custom", + metricName: "identifier2" + } + ] } ] }) @@ -324,6 +356,21 @@ resource "harness_platform_monitored_service" "example5" { liveMonitoringEnabled = "true" continuousVerificationEnabled = "true" sliEnabled = "false" + metricThresholds: [ + { + type: "IgnoreThreshold", + spec: { + action: "Ignore" + }, + criteria: { + type: "Absolute", + spec: { + greaterThan: 100 + } + }, + metricType: "Custom", + metricName: "metric" + }] }, { name = "name2" @@ -439,6 +486,27 @@ resource "harness_platform_monitored_service" "example7" { isManualQuery = true } ] + metricPacks: [ + { + identifier: "Custom", + metricThresholds: [ + { + type: "IgnoreThreshold", + spec: { + action: "Ignore" + }, + criteria: { + type: "Absolute", + spec: { + greaterThan: 100 + } + }, + metricType: "Custom", + metricName: "Prometheus Metric" + } + ] + } + ] }) } template_ref = "template_ref" @@ -522,6 +590,27 @@ resource "harness_platform_monitored_service" "example8" { } } ] + metricPacks: [ + { + identifier: "Custom", + metricThresholds: [ + { + type: "IgnoreThreshold", + spec: { + action: "Ignore" + }, + criteria: { + type: "Absolute", + spec: { + greaterThan: 100 + } + }, + metricType: "Custom", + metricName: "metric" + } + ] + } + ] }) } template_ref = "template_ref" diff --git a/internal/service/platform/monitored_service/data_source_monitored_service_test.go b/internal/service/platform/monitored_service/data_source_monitored_service_test.go index 0cada65e4..943014ea1 100644 --- a/internal/service/platform/monitored_service/data_source_monitored_service_test.go +++ b/internal/service/platform/monitored_service/data_source_monitored_service_test.go @@ -482,6 +482,21 @@ func testAccSplunkSignalFXDataSourceMonitoredService(id string, name string) str liveMonitoringEnabled = "true" continuousVerificationEnabled = "false" sliEnabled = "false" + metricThresholds: [ + { + type: "IgnoreThreshold", + spec: { + action: "Ignore" + }, + criteria: { + type: "Absolute", + spec: { + greaterThan: 100 + } + }, + metricType: "Custom", + metricName: "identifier2" + }] } ]}) } @@ -561,6 +576,22 @@ func testAccGrafanaLokiLogsDataSourceMonitoredService(id string, name string) st liveMonitoringEnabled = "false" continuousVerificationEnabled = "false" sliEnabled = "false" + metricThresholds: [ + { + type: "IgnoreThreshold", + spec: { + action: "Ignore" + }, + criteria: { + type: "Absolute", + spec: { + greaterThan: 100 + } + }, + metricType: "Custom", + metricName: "identifier2" + } + ] } ]}) } @@ -632,6 +663,22 @@ func testAccAzureMetricsDataSourceMonitoredService(id string, name string) strin liveMonitoringEnabled = "true" continuousVerificationEnabled = "true" sliEnabled = "false" + metricThresholds: [ + { + type: "IgnoreThreshold", + spec: { + action: "Ignore" + }, + criteria: { + type: "Absolute", + spec: { + greaterThan: 100 + } + }, + metricType: "Custom", + metricName: "metric" + } + ] }, { name = "name2" From 5d60c1806925cc5d96af27e4e1e84be4e412540b Mon Sep 17 00:00:00 2001 From: Deepak Chhikara Date: Tue, 28 Nov 2023 11:48:46 +0530 Subject: [PATCH 2/4] [fix]: [SRM-16226]: Adding health source deseralizr --- .../resource.tf | 51 +++++++++++++++++++ .../data_source_monitored_service_test.go | 51 +++++++++++++++++++ 2 files changed, 102 insertions(+) diff --git a/examples/resources/harness_platform_monitored_service/resource.tf b/examples/resources/harness_platform_monitored_service/resource.tf index ff986860c..74a105d3f 100644 --- a/examples/resources/harness_platform_monitored_service/resource.tf +++ b/examples/resources/harness_platform_monitored_service/resource.tf @@ -255,6 +255,23 @@ resource "harness_platform_monitored_service" "example3" { }, metricType: "Custom", metricName: "identifier2" + }, + { + "type": "FailImmediately", + "spec": { + "action": "FailAfterOccurrence", + "spec": { + "count": 2 + } + }, + "criteria": { + "type": "Absolute", + "spec": { + "greaterThan": 100 + } + }, + "metricType": "Custom", + "metricName": "identifier2" } ] } @@ -370,6 +387,23 @@ resource "harness_platform_monitored_service" "example5" { }, metricType: "Custom", metricName: "metric" + }, + { + "type": "FailImmediately", + "spec": { + "action": "FailAfterOccurrence", + "spec": { + "count": 2 + } + }, + "criteria": { + "type": "Absolute", + "spec": { + "greaterThan": 100 + } + }, + "metricType": "Custom", + "metricName": "metric" }] }, { @@ -503,6 +537,23 @@ resource "harness_platform_monitored_service" "example7" { }, metricType: "Custom", metricName: "Prometheus Metric" + }, + { + "type": "FailImmediately", + "spec": { + "action": "FailAfterOccurrence", + "spec": { + "count": 2 + } + }, + "criteria": { + "type": "Absolute", + "spec": { + "greaterThan": 100 + } + }, + "metricType": "Custom", + "metricName": "Prometheus Metric" } ] } diff --git a/internal/service/platform/monitored_service/data_source_monitored_service_test.go b/internal/service/platform/monitored_service/data_source_monitored_service_test.go index 943014ea1..81bdbe462 100644 --- a/internal/service/platform/monitored_service/data_source_monitored_service_test.go +++ b/internal/service/platform/monitored_service/data_source_monitored_service_test.go @@ -496,6 +496,23 @@ func testAccSplunkSignalFXDataSourceMonitoredService(id string, name string) str }, metricType: "Custom", metricName: "identifier2" + }, + { + "type": "FailImmediately", + "spec": { + "action": "FailAfterOccurrence", + "spec": { + "count": 2 + } + }, + "criteria": { + "type": "Absolute", + "spec": { + "greaterThan": 100 + } + }, + "metricType": "Custom", + "metricName": "identifier2" }] } ]}) @@ -677,6 +694,23 @@ func testAccAzureMetricsDataSourceMonitoredService(id string, name string) strin }, metricType: "Custom", metricName: "metric" + }, + { + "type": "FailImmediately", + "spec": { + "action": "FailAfterOccurrence", + "spec": { + "count": 2 + } + }, + "criteria": { + "type": "Absolute", + "spec": { + "greaterThan": 100 + } + }, + "metricType": "Custom", + "metricName": "metric" } ] }, @@ -873,6 +907,23 @@ resource "harness_platform_monitored_service" "test" { }, metricType: "Custom", metricName: "Prometheus Metric" + }, + { + "type": "FailImmediately", + "spec": { + "action": "FailAfterOccurrence", + "spec": { + "count": 2 + } + }, + "criteria": { + "type": "Absolute", + "spec": { + "greaterThan": 100 + } + }, + "metricType": "Custom", + "metricName": "Prometheus Metric" } ] } From 83eda3e8c6db996a1f5cc4caee6845be8f27516e Mon Sep 17 00:00:00 2001 From: Deepak Chhikara Date: Tue, 28 Nov 2023 11:49:44 +0530 Subject: [PATCH 3/4] [fix]: [SRM-16226]: Adding health source deseralizr --- .../resource.tf | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/examples/resources/harness_platform_monitored_service/resource.tf b/examples/resources/harness_platform_monitored_service/resource.tf index 74a105d3f..4902bf778 100644 --- a/examples/resources/harness_platform_monitored_service/resource.tf +++ b/examples/resources/harness_platform_monitored_service/resource.tf @@ -118,6 +118,23 @@ resource "harness_platform_monitored_service" "example1" { }, metricType: "Custom", metricName: "metric_cpu" + }, + { + "type": "FailImmediately", + "spec": { + "action": "FailAfterOccurrence", + "spec": { + "count": 2 + } + }, + "criteria": { + "type": "Absolute", + "spec": { + "greaterThan": 100 + } + }, + "metricType": "Custom", + "metricName": "metric_cpu" } ] }, @@ -658,6 +675,23 @@ resource "harness_platform_monitored_service" "example8" { }, metricType: "Custom", metricName: "metric" + }, + { + "type": "FailImmediately", + "spec": { + "action": "FailAfterOccurrence", + "spec": { + "count": 2 + } + }, + "criteria": { + "type": "Absolute", + "spec": { + "greaterThan": 100 + } + }, + "metricType": "Custom", + "metricName": "metric" } ] } From aa2b34302bd555407ff3ad032791a9ce4d584db4 Mon Sep 17 00:00:00 2001 From: Deepak Chhikara Date: Tue, 28 Nov 2023 11:50:50 +0530 Subject: [PATCH 4/4] [fix]: [SRM-16226]: Adding health source deseralizr --- .../data_source_monitored_service_test.go | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/internal/service/platform/monitored_service/data_source_monitored_service_test.go b/internal/service/platform/monitored_service/data_source_monitored_service_test.go index 81bdbe462..700957523 100644 --- a/internal/service/platform/monitored_service/data_source_monitored_service_test.go +++ b/internal/service/platform/monitored_service/data_source_monitored_service_test.go @@ -980,7 +980,7 @@ resource "harness_platform_monitored_service" "test" { { identifier: "Custom", metricThresholds: [ - { + { type: "IgnoreThreshold", spec: { action: "Ignore" @@ -993,7 +993,24 @@ resource "harness_platform_monitored_service" "test" { }, metricType: "Custom", metricName: "metric" - } + }, + { + "type": "FailImmediately", + "spec": { + "action": "FailAfterOccurrence", + "spec": { + "count": 2 + } + }, + "criteria": { + "type": "Absolute", + "spec": { + "greaterThan": 100 + } + }, + "metricType": "Custom", + "metricName": "metric" + } ] } ]