-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into PC-13045-splunk-single-query
- Loading branch information
Showing
10 changed files
with
256 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package v1alpha | ||
|
||
//go:generate ../../bin/go-enum --values | ||
|
||
// AlertMethodType represents the specific type of alert method. | ||
// | ||
/* ENUM( | ||
Webhook = 1 | ||
PagerDuty | ||
Slack | ||
Discord | ||
Opsgenie | ||
ServiceNow | ||
Jira | ||
Teams | ||
)*/ | ||
type AlertMethodType int |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package alertmethod | ||
|
||
import ( | ||
"reflect" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/nobl9/nobl9-go/manifest/v1alpha" | ||
) | ||
|
||
func TestAlertMethod_Spec_GetType(t *testing.T) { | ||
for _, method := range v1alpha.AlertMethodTypeValues() { | ||
t.Run(method.String(), func(t *testing.T) { | ||
spec := Spec{} | ||
methodTypeStr := method.String() | ||
setZeroValue(t, &spec, methodTypeStr) | ||
typ, err := spec.GetType() | ||
require.NoError(t, err) | ||
assert.Equal(t, typ.String(), method.String()) | ||
}) | ||
} | ||
} | ||
|
||
// setZeroValue sets a zero value of a pointer field in a struct using reflection. | ||
func setZeroValue(t *testing.T, obj interface{}, fieldName string) { | ||
t.Helper() | ||
objValue := reflect.ValueOf(obj).Elem() | ||
fieldValue := objValue.FieldByName(fieldName) | ||
if !fieldValue.IsValid() || !fieldValue.CanSet() { | ||
t.Fatalf("cannot set value for field: %s", fieldName) | ||
} | ||
fieldValue.Set(reflect.New(fieldValue.Type().Elem())) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
apiVersion: n9/v1alpha | ||
kind: SLO | ||
metadata: | ||
name: cloudwatch-json | ||
project: cloudwatch | ||
spec: | ||
budgetingMethod: Occurrences | ||
description: "" | ||
indicator: | ||
metricSource: | ||
kind: Agent | ||
name: cloudwatch | ||
project: cloudwatch | ||
objectives: | ||
- displayName: "" | ||
op: lte | ||
rawMetric: | ||
query: | ||
cloudWatch: | ||
json: "[{\"Id\": \"e1\",\"Expression\": \"MAX(FILL(METRICS(), 0))\",\"Period\": 60},{\"Id\": \"m1\",\"MetricStat\": {\"Metric\": {\"Namespace\": \"AWS/ApplicationELB\",\"MetricName\": \"TargetResponseTime\",\"Dimensions\": [{\"Name\": \"LoadBalancer\",\"Value\": \"app/123/123\"},{\"Name\": \"TargetGroup\",\"Value\": \"targetgroup/123/123\"}]},\"Period\": 60,\"Stat\": \"Average\"},\"ReturnData\": false}]" | ||
region: eu-central-1 | ||
target: 0.8 | ||
value: 0.9 | ||
name: objective-1 | ||
service: cloudwatch-service | ||
timeWindows: | ||
- count: 1 | ||
isRolling: true | ||
unit: Hour |