diff --git a/api/v1/checks.go b/api/v1/checks.go index d73c7adf1..e2e34079e 100644 --- a/api/v1/checks.go +++ b/api/v1/checks.go @@ -1096,11 +1096,11 @@ func (c ExecCheck) GetEndpoint() string { return *c.Script } -func (c ExecCheck) GetTestFunction() Template { +func (c ExecCheck) GetTestTemplate() Template { if c.Test.Expression == "" { c.Test.Expression = "results.ExitCode == 0" } - return c.Test + return c.Test.Template } type AwsConfigCheck struct { diff --git a/api/v1/common.go b/api/v1/common.go index 82e303b36..224e6d4f1 100644 --- a/api/v1/common.go +++ b/api/v1/common.go @@ -216,6 +216,14 @@ type Template struct { Javascript string `yaml:"javascript,omitempty" json:"javascript,omitempty"` } +type TestThreshold struct { + Info string `yaml:"info,omitempty" json:"info,omitempty"` + Low string `yaml:"low,omitempty" json:"low,omitempty"` + Medium string `yaml:"medium,omitempty" json:"medium,omitempty"` + High string `yaml:"high,omitempty" json:"high,omitempty"` + Critical string `yaml:"critical,omitempty" json:"critical,omitempty"` +} + func (t Template) IsEmpty() bool { return t.Template == "" && t.JSONPath == "" && t.Expression == "" && t.Javascript == "" } @@ -227,7 +235,8 @@ type DisplayTemplate interface { // +k8s:deepcopy-gen=false type TestFunction interface { - GetTestFunction() Template + GetTestTemplate() Template + GetTestThreshold() *TestThreshold } // +k8s:deepcopy-gen=false @@ -235,14 +244,23 @@ type Transformer interface { GetTransformer() Template } +type TestTemplate struct { + Template `yaml:",inline" json:",inline"` + *TestThreshold `yaml:"threshold,omitempty" json:"threshold,omitempty"` +} + type Templatable struct { - Test Template `yaml:"test,omitempty" json:"test,omitempty"` - Display Template `yaml:"display,omitempty" json:"display,omitempty"` - Transform Template `yaml:"transform,omitempty" json:"transform,omitempty"` + Test TestTemplate `yaml:"test,omitempty" json:"test,omitempty"` + Display Template `yaml:"display,omitempty" json:"display,omitempty"` + Transform Template `yaml:"transform,omitempty" json:"transform,omitempty"` +} + +func (t Templatable) GetTestTemplate() Template { + return t.Test.Template } -func (t Templatable) GetTestFunction() Template { - return t.Test +func (t Templatable) GetTestThreshold() *TestThreshold { + return t.Test.TestThreshold } func (t Templatable) GetDisplayTemplate() Template { diff --git a/api/v1/zz_generated.deepcopy.go b/api/v1/zz_generated.deepcopy.go index 92c41197d..66035efd6 100644 --- a/api/v1/zz_generated.deepcopy.go +++ b/api/v1/zz_generated.deepcopy.go @@ -65,7 +65,7 @@ func (in *AlertManager) DeepCopy() *AlertManager { func (in *AlertManagerCheck) DeepCopyInto(out *AlertManagerCheck) { *out = *in in.Description.DeepCopyInto(&out.Description) - out.Templatable = in.Templatable + in.Templatable.DeepCopyInto(&out.Templatable) if in.Auth != nil { in, out := &in.Auth, &out.Auth *out = new(Authentication) @@ -137,7 +137,7 @@ func (in *AwsConfig) DeepCopy() *AwsConfig { func (in *AwsConfigCheck) DeepCopyInto(out *AwsConfigCheck) { *out = *in in.Description.DeepCopyInto(&out.Description) - out.Templatable = in.Templatable + in.Templatable.DeepCopyInto(&out.Templatable) if in.AWSConnection != nil { in, out := &in.AWSConnection, &out.AWSConnection *out = new(AWSConnection) @@ -180,7 +180,7 @@ func (in *AwsConfigRule) DeepCopy() *AwsConfigRule { func (in *AwsConfigRuleCheck) DeepCopyInto(out *AwsConfigRuleCheck) { *out = *in in.Description.DeepCopyInto(&out.Description) - out.Templatable = in.Templatable + in.Templatable.DeepCopyInto(&out.Templatable) if in.IgnoreRules != nil { in, out := &in.IgnoreRules, &out.IgnoreRules *out = make([]string, len(*in)) @@ -217,7 +217,7 @@ func (in *AwsConfigRuleCheck) DeepCopy() *AwsConfigRuleCheck { func (in *AzureDevopsCheck) DeepCopyInto(out *AzureDevopsCheck) { *out = *in in.Description.DeepCopyInto(&out.Description) - out.Templatable = in.Templatable + in.Templatable.DeepCopyInto(&out.Templatable) in.PersonalAccessToken.DeepCopyInto(&out.PersonalAccessToken) if in.Variables != nil { in, out := &in.Variables, &out.Variables @@ -744,7 +744,7 @@ func (in *CloudWatchCheck) DeepCopyInto(out *CloudWatchCheck) { *out = *in in.Description.DeepCopyInto(&out.Description) in.AWSConnection.DeepCopyInto(&out.AWSConnection) - out.Templatable = in.Templatable + in.Templatable.DeepCopyInto(&out.Templatable) in.Filter.DeepCopyInto(&out.Filter) } @@ -1148,7 +1148,7 @@ func (in *ConfigDB) DeepCopy() *ConfigDB { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ConfigDBCheck) DeepCopyInto(out *ConfigDBCheck) { *out = *in - out.Templatable = in.Templatable + in.Templatable.DeepCopyInto(&out.Templatable) in.Description.DeepCopyInto(&out.Description) } @@ -1321,7 +1321,7 @@ func (in *DatabaseBackup) DeepCopy() *DatabaseBackup { func (in *DatabaseBackupCheck) DeepCopyInto(out *DatabaseBackupCheck) { *out = *in in.Description.DeepCopyInto(&out.Description) - out.Templatable = in.Templatable + in.Templatable.DeepCopyInto(&out.Templatable) if in.GCP != nil { in, out := &in.GCP, &out.GCP *out = new(GCPDatabase) @@ -1455,7 +1455,7 @@ func (in *DockerPushCheck) DeepCopy() *DockerPushCheck { func (in *DynatraceCheck) DeepCopyInto(out *DynatraceCheck) { *out = *in in.Description.DeepCopyInto(&out.Description) - out.Templatable = in.Templatable + in.Templatable.DeepCopyInto(&out.Templatable) in.APIKey.DeepCopyInto(&out.APIKey) } @@ -1527,7 +1527,7 @@ func (in *Elasticsearch) DeepCopy() *Elasticsearch { func (in *ElasticsearchCheck) DeepCopyInto(out *ElasticsearchCheck) { *out = *in in.Description.DeepCopyInto(&out.Description) - out.Templatable = in.Templatable + in.Templatable.DeepCopyInto(&out.Templatable) if in.Auth != nil { in, out := &in.Auth, &out.Auth *out = new(Authentication) @@ -1565,7 +1565,7 @@ func (in *Exec) DeepCopy() *Exec { func (in *ExecCheck) DeepCopyInto(out *ExecCheck) { *out = *in in.Description.DeepCopyInto(&out.Description) - out.Templatable = in.Templatable + in.Templatable.DeepCopyInto(&out.Templatable) if in.Script != nil { in, out := &in.Script, &out.Script *out = new(string) @@ -1603,7 +1603,7 @@ func (in *Folder) DeepCopy() *Folder { func (in *FolderCheck) DeepCopyInto(out *FolderCheck) { *out = *in in.Description.DeepCopyInto(&out.Description) - out.Templatable = in.Templatable + in.Templatable.DeepCopyInto(&out.Templatable) out.Filter = in.Filter in.FolderTest.DeepCopyInto(&out.FolderTest) if in.AWSConnection != nil { @@ -1791,7 +1791,7 @@ func (in *Git) DeepCopy() *Git { func (in *GitHubCheck) DeepCopyInto(out *GitHubCheck) { *out = *in in.Description.DeepCopyInto(&out.Description) - out.Templatable = in.Templatable + in.Templatable.DeepCopyInto(&out.Templatable) in.GithubToken.DeepCopyInto(&out.GithubToken) } @@ -1825,7 +1825,7 @@ func (in *HTTP) DeepCopy() *HTTP { func (in *HTTPCheck) DeepCopyInto(out *HTTPCheck) { *out = *in in.Description.DeepCopyInto(&out.Description) - out.Templatable = in.Templatable + in.Templatable.DeepCopyInto(&out.Templatable) if in.ResponseCodes != nil { in, out := &in.ResponseCodes, &out.ResponseCodes *out = make([]int, len(*in)) @@ -2007,7 +2007,7 @@ func (in *Junit) DeepCopy() *Junit { func (in *JunitCheck) DeepCopyInto(out *JunitCheck) { *out = *in in.Description.DeepCopyInto(&out.Description) - out.Templatable = in.Templatable + in.Templatable.DeepCopyInto(&out.Templatable) if in.Spec != nil { in, out := &in.Spec, &out.Spec *out = make(json.RawMessage, len(*in)) @@ -2045,7 +2045,7 @@ func (in *Kubernetes) DeepCopy() *Kubernetes { func (in *KubernetesCheck) DeepCopyInto(out *KubernetesCheck) { *out = *in in.Description.DeepCopyInto(&out.Description) - out.Templatable = in.Templatable + in.Templatable.DeepCopyInto(&out.Templatable) out.Namespace = in.Namespace out.Resource = in.Resource if in.Ignore != nil { @@ -2296,7 +2296,7 @@ func (in *NamespaceSelector) DeepCopy() *NamespaceSelector { func (in *OpenSearchCheck) DeepCopyInto(out *OpenSearchCheck) { *out = *in in.Description.DeepCopyInto(&out.Description) - out.Templatable = in.Templatable + in.Templatable.DeepCopyInto(&out.Templatable) in.Auth.DeepCopyInto(&out.Auth) } @@ -2399,7 +2399,7 @@ func (in *Prometheus) DeepCopy() *Prometheus { func (in *PrometheusCheck) DeepCopyInto(out *PrometheusCheck) { *out = *in in.Description.DeepCopyInto(&out.Description) - out.Templatable = in.Templatable + in.Templatable.DeepCopyInto(&out.Templatable) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PrometheusCheck. @@ -2683,7 +2683,7 @@ func (in *SMBConnection) DeepCopy() *SMBConnection { func (in *SQLCheck) DeepCopyInto(out *SQLCheck) { *out = *in in.Description.DeepCopyInto(&out.Description) - out.Templatable = in.Templatable + in.Templatable.DeepCopyInto(&out.Templatable) in.Connection.DeepCopyInto(&out.Connection) } @@ -2818,7 +2818,7 @@ func (in *TCPCheck) DeepCopy() *TCPCheck { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Templatable) DeepCopyInto(out *Templatable) { *out = *in - out.Test = in.Test + in.Test.DeepCopyInto(&out.Test) out.Display = in.Display out.Transform = in.Transform } @@ -2864,6 +2864,42 @@ func (in *Test) DeepCopy() *Test { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *TestTemplate) DeepCopyInto(out *TestTemplate) { + *out = *in + out.Template = in.Template + if in.TestThreshold != nil { + in, out := &in.TestThreshold, &out.TestThreshold + *out = new(TestThreshold) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TestTemplate. +func (in *TestTemplate) DeepCopy() *TestTemplate { + if in == nil { + return nil + } + out := new(TestTemplate) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *TestThreshold) DeepCopyInto(out *TestThreshold) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TestThreshold. +func (in *TestThreshold) DeepCopy() *TestThreshold { + if in == nil { + return nil + } + out := new(TestThreshold) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Text) DeepCopyInto(out *Text) { *out = *in diff --git a/checks/runchecks.go b/checks/runchecks.go index d5146979c..6c6cca748 100644 --- a/checks/runchecks.go +++ b/checks/runchecks.go @@ -9,6 +9,7 @@ import ( "github.com/flanksource/canary-checker/pkg" "github.com/flanksource/canary-checker/pkg/db" "github.com/flanksource/commons/logger" + "github.com/flanksource/duty/models" ) func RunChecks(ctx *context.Context) []*pkg.CheckResult { @@ -104,10 +105,14 @@ func processTemplates(ctx *context.Context, r *pkg.CheckResult) *pkg.CheckResult switch v := r.Check.(type) { case v1.TestFunction: - tpl := v.GetTestFunction() + data := map[string]any{"duration": r.Duration} + r.Severity = measureTestSeverity(ctx.New(data), v.GetTestThreshold()) + + tpl := v.GetTestTemplate() if tpl.IsEmpty() { break } + message, err := template(ctx.New(r.Data), tpl) if err != nil { r.ErrorMessage(err) @@ -122,3 +127,31 @@ func processTemplates(ctx *context.Context, r *pkg.CheckResult) *pkg.CheckResult return r } + +func measureTestSeverity(ctx *context.Context, threshold *v1.TestThreshold) models.Severity { + if threshold == nil { + return models.SeverityInfo + } + + thresholds := []struct { + severity models.Severity + expr string + }{ + {models.SeverityCritical, threshold.Critical}, + {models.SeverityHigh, threshold.High}, + {models.SeverityMedium, threshold.Medium}, + {models.SeverityLow, threshold.Low}, + {models.SeverityInfo, threshold.Info}, + } + + for _, t := range thresholds { + if res, err := template(ctx, v1.Template{Expression: t.expr}); err != nil { + logger.Errorf("failed to run expression for severity: %s", t.severity) + continue + } else if res == "true" { + return t.severity + } + } + + return models.SeverityInfo +} diff --git a/checks/runchecks_test.go b/checks/runchecks_test.go new file mode 100644 index 000000000..c8229cdd3 --- /dev/null +++ b/checks/runchecks_test.go @@ -0,0 +1,133 @@ +package checks + +import ( + "reflect" + "testing" + + "github.com/flanksource/canary-checker/api/context" + v1 "github.com/flanksource/canary-checker/api/v1" + "github.com/flanksource/duty/models" +) + +func Test_measureTestSeverity(t *testing.T) { + type args struct { + duration int + threshold *v1.TestThreshold + } + tests := []struct { + name string + args args + want models.Severity + }{ + { + name: "simple - critical", + args: args{ + duration: 2000, + threshold: &v1.TestThreshold{ + Critical: "duration > 1500", + }, + }, + want: models.SeverityCritical, + }, + { + name: "simple - high", + args: args{ + duration: 1200, + threshold: &v1.TestThreshold{ + Critical: "duration > 1500", + High: "duration > 1000", + }, + }, + want: models.SeverityHigh, + }, + { + name: "simple - medium", + args: args{ + duration: 760, + threshold: &v1.TestThreshold{ + Critical: "duration > 1500", + High: "duration > 1000", + Medium: "duration > 750", + Low: "duration > 500", + }, + }, + want: models.SeverityMedium, + }, + { + name: "simple - low", + args: args{ + duration: 600, + threshold: &v1.TestThreshold{ + Critical: "duration > 1500", + High: "duration > 1000", + Low: "duration > 500", + }, + }, + want: models.SeverityLow, + }, + { + name: "complex expression", + args: args{ + duration: 2100, + threshold: &v1.TestThreshold{ + Critical: "duration > 1500 && duration < 2000", + High: "duration > 1000 && duration < 1500", + Low: "duration > 500 && duration < 1000", + }, + }, + want: models.SeverityInfo, + }, + { + name: "no threshold defined", + args: args{ + duration: 600, + }, + want: models.SeverityInfo, + }, + { + name: "no severity match", + args: args{ + duration: 400, + threshold: &v1.TestThreshold{ + Critical: "duration > 1500", + High: "duration > 1000", + Low: "duration > 500", + }, + }, + want: models.SeverityInfo, + }, + { + name: "invalid expression", + args: args{ + duration: 400, + threshold: &v1.TestThreshold{ + Critical: "duration >>> 1500", + High: "duration > 1000", + Low: "duration > 500", + }, + }, + want: models.SeverityInfo, + }, + { + name: "use of undefined var", + args: args{ + duration: 400, + threshold: &v1.TestThreshold{ + Critical: "Duration > 1500", + High: "Duration > 1000", + Low: "Duration > 500", + }, + }, + want: models.SeverityInfo, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + data := map[string]any{"duration": tt.args.duration} + ctx := context.Context{} + if got := measureTestSeverity(ctx.New(data), tt.args.threshold); !reflect.DeepEqual(got, tt.want) { + t.Errorf("measureTestSeverity() = %v, want %v", got, tt.want) + } + }) + } +} diff --git a/config/deploy/crd.yaml b/config/deploy/crd.yaml index 3c97dc1ba..c569df8ad 100644 --- a/config/deploy/crd.yaml +++ b/config/deploy/crd.yaml @@ -173,6 +173,19 @@ spec: type: string template: type: string + threshold: + properties: + critical: + type: string + high: + type: string + info: + type: string + low: + type: string + medium: + type: string + type: object type: object transform: properties: @@ -306,6 +319,19 @@ spec: type: string template: type: string + threshold: + properties: + critical: + type: string + high: + type: string + info: + type: string + low: + type: string + medium: + type: string + type: object type: object transform: properties: @@ -451,6 +477,19 @@ spec: type: string template: type: string + threshold: + properties: + critical: + type: string + high: + type: string + info: + type: string + low: + type: string + medium: + type: string + type: object type: object transform: properties: @@ -545,6 +584,19 @@ spec: type: string template: type: string + threshold: + properties: + critical: + type: string + high: + type: string + info: + type: string + low: + type: string + medium: + type: string + type: object type: object thresholdMillis: description: ThresholdMillis the maximum duration of a Run. (Optional) @@ -695,6 +747,19 @@ spec: type: string template: type: string + threshold: + properties: + critical: + type: string + high: + type: string + info: + type: string + low: + type: string + medium: + type: string + type: object type: object transform: properties: @@ -754,6 +819,19 @@ spec: type: string template: type: string + threshold: + properties: + critical: + type: string + high: + type: string + info: + type: string + low: + type: string + medium: + type: string + type: object type: object transform: properties: @@ -976,6 +1054,19 @@ spec: type: string template: type: string + threshold: + properties: + critical: + type: string + high: + type: string + info: + type: string + low: + type: string + medium: + type: string + type: object type: object transform: properties: @@ -1280,6 +1371,19 @@ spec: type: string template: type: string + threshold: + properties: + critical: + type: string + high: + type: string + info: + type: string + low: + type: string + medium: + type: string + type: object type: object transform: properties: @@ -1519,6 +1623,19 @@ spec: type: string template: type: string + threshold: + properties: + critical: + type: string + high: + type: string + info: + type: string + low: + type: string + medium: + type: string + type: object type: object transform: properties: @@ -1631,6 +1748,19 @@ spec: type: string template: type: string + threshold: + properties: + critical: + type: string + high: + type: string + info: + type: string + low: + type: string + medium: + type: string + type: object type: object transform: properties: @@ -1995,6 +2125,19 @@ spec: type: string template: type: string + threshold: + properties: + critical: + type: string + high: + type: string + info: + type: string + low: + type: string + medium: + type: string + type: object type: object totalSize: description: TotalSize present on the filesystem @@ -2086,6 +2229,19 @@ spec: type: string template: type: string + threshold: + properties: + critical: + type: string + high: + type: string + info: + type: string + low: + type: string + medium: + type: string + type: object type: object transform: properties: @@ -2370,6 +2526,19 @@ spec: type: string template: type: string + threshold: + properties: + critical: + type: string + high: + type: string + info: + type: string + low: + type: string + medium: + type: string + type: object type: object thresholdMillis: description: Maximum duration in milliseconds for the HTTP request. It will fail the check if it takes longer. @@ -2541,6 +2710,19 @@ spec: type: string template: type: string + threshold: + properties: + critical: + type: string + high: + type: string + info: + type: string + low: + type: string + medium: + type: string + type: object type: object testResults: type: string @@ -2629,6 +2811,19 @@ spec: type: string template: type: string + threshold: + properties: + critical: + type: string + high: + type: string + info: + type: string + low: + type: string + medium: + type: string + type: object type: object transform: properties: @@ -2935,6 +3130,19 @@ spec: type: string template: type: string + threshold: + properties: + critical: + type: string + high: + type: string + info: + type: string + low: + type: string + medium: + type: string + type: object type: object transform: properties: @@ -3059,6 +3267,19 @@ spec: type: string template: type: string + threshold: + properties: + critical: + type: string + high: + type: string + info: + type: string + low: + type: string + medium: + type: string + type: object type: object transform: properties: @@ -3258,6 +3479,19 @@ spec: type: string template: type: string + threshold: + properties: + critical: + type: string + high: + type: string + info: + type: string + low: + type: string + medium: + type: string + type: object type: object transform: properties: @@ -3453,6 +3687,19 @@ spec: type: string template: type: string + threshold: + properties: + critical: + type: string + high: + type: string + info: + type: string + low: + type: string + medium: + type: string + type: object type: object transform: properties: @@ -3516,6 +3763,19 @@ spec: type: string template: type: string + threshold: + properties: + critical: + type: string + high: + type: string + info: + type: string + low: + type: string + medium: + type: string + type: object type: object transform: properties: diff --git a/config/deploy/manifests.yaml b/config/deploy/manifests.yaml index cbb6b5316..eb6c4d097 100644 --- a/config/deploy/manifests.yaml +++ b/config/deploy/manifests.yaml @@ -173,6 +173,19 @@ spec: type: string template: type: string + threshold: + properties: + critical: + type: string + high: + type: string + info: + type: string + low: + type: string + medium: + type: string + type: object type: object transform: properties: @@ -306,6 +319,19 @@ spec: type: string template: type: string + threshold: + properties: + critical: + type: string + high: + type: string + info: + type: string + low: + type: string + medium: + type: string + type: object type: object transform: properties: @@ -451,6 +477,19 @@ spec: type: string template: type: string + threshold: + properties: + critical: + type: string + high: + type: string + info: + type: string + low: + type: string + medium: + type: string + type: object type: object transform: properties: @@ -545,6 +584,19 @@ spec: type: string template: type: string + threshold: + properties: + critical: + type: string + high: + type: string + info: + type: string + low: + type: string + medium: + type: string + type: object type: object thresholdMillis: description: ThresholdMillis the maximum duration of a Run. (Optional) @@ -695,6 +747,19 @@ spec: type: string template: type: string + threshold: + properties: + critical: + type: string + high: + type: string + info: + type: string + low: + type: string + medium: + type: string + type: object type: object transform: properties: @@ -754,6 +819,19 @@ spec: type: string template: type: string + threshold: + properties: + critical: + type: string + high: + type: string + info: + type: string + low: + type: string + medium: + type: string + type: object type: object transform: properties: @@ -976,6 +1054,19 @@ spec: type: string template: type: string + threshold: + properties: + critical: + type: string + high: + type: string + info: + type: string + low: + type: string + medium: + type: string + type: object type: object transform: properties: @@ -1280,6 +1371,19 @@ spec: type: string template: type: string + threshold: + properties: + critical: + type: string + high: + type: string + info: + type: string + low: + type: string + medium: + type: string + type: object type: object transform: properties: @@ -1519,6 +1623,19 @@ spec: type: string template: type: string + threshold: + properties: + critical: + type: string + high: + type: string + info: + type: string + low: + type: string + medium: + type: string + type: object type: object transform: properties: @@ -1631,6 +1748,19 @@ spec: type: string template: type: string + threshold: + properties: + critical: + type: string + high: + type: string + info: + type: string + low: + type: string + medium: + type: string + type: object type: object transform: properties: @@ -1995,6 +2125,19 @@ spec: type: string template: type: string + threshold: + properties: + critical: + type: string + high: + type: string + info: + type: string + low: + type: string + medium: + type: string + type: object type: object totalSize: description: TotalSize present on the filesystem @@ -2086,6 +2229,19 @@ spec: type: string template: type: string + threshold: + properties: + critical: + type: string + high: + type: string + info: + type: string + low: + type: string + medium: + type: string + type: object type: object transform: properties: @@ -2370,6 +2526,19 @@ spec: type: string template: type: string + threshold: + properties: + critical: + type: string + high: + type: string + info: + type: string + low: + type: string + medium: + type: string + type: object type: object thresholdMillis: description: Maximum duration in milliseconds for the HTTP request. It will fail the check if it takes longer. @@ -2541,6 +2710,19 @@ spec: type: string template: type: string + threshold: + properties: + critical: + type: string + high: + type: string + info: + type: string + low: + type: string + medium: + type: string + type: object type: object testResults: type: string @@ -2629,6 +2811,19 @@ spec: type: string template: type: string + threshold: + properties: + critical: + type: string + high: + type: string + info: + type: string + low: + type: string + medium: + type: string + type: object type: object transform: properties: @@ -2935,6 +3130,19 @@ spec: type: string template: type: string + threshold: + properties: + critical: + type: string + high: + type: string + info: + type: string + low: + type: string + medium: + type: string + type: object type: object transform: properties: @@ -3059,6 +3267,19 @@ spec: type: string template: type: string + threshold: + properties: + critical: + type: string + high: + type: string + info: + type: string + low: + type: string + medium: + type: string + type: object type: object transform: properties: @@ -3258,6 +3479,19 @@ spec: type: string template: type: string + threshold: + properties: + critical: + type: string + high: + type: string + info: + type: string + low: + type: string + medium: + type: string + type: object type: object transform: properties: @@ -3453,6 +3687,19 @@ spec: type: string template: type: string + threshold: + properties: + critical: + type: string + high: + type: string + info: + type: string + low: + type: string + medium: + type: string + type: object type: object transform: properties: @@ -3516,6 +3763,19 @@ spec: type: string template: type: string + threshold: + properties: + critical: + type: string + high: + type: string + info: + type: string + low: + type: string + medium: + type: string + type: object type: object transform: properties: diff --git a/config/schemas/canary.schema.json b/config/schemas/canary.schema.json index 2bdf053df..f28cac4de 100644 --- a/config/schemas/canary.schema.json +++ b/config/schemas/canary.schema.json @@ -48,7 +48,7 @@ "$ref": "#/$defs/Labels" }, "test": { - "$ref": "#/$defs/Template" + "$ref": "#/$defs/TestTemplate" }, "display": { "$ref": "#/$defs/Template" @@ -123,7 +123,7 @@ "$ref": "#/$defs/Labels" }, "test": { - "$ref": "#/$defs/Template" + "$ref": "#/$defs/TestTemplate" }, "display": { "$ref": "#/$defs/Template" @@ -163,7 +163,7 @@ "$ref": "#/$defs/Labels" }, "test": { - "$ref": "#/$defs/Template" + "$ref": "#/$defs/TestTemplate" }, "display": { "$ref": "#/$defs/Template" @@ -214,7 +214,7 @@ "$ref": "#/$defs/Labels" }, "test": { - "$ref": "#/$defs/Template" + "$ref": "#/$defs/TestTemplate" }, "display": { "$ref": "#/$defs/Template" @@ -655,7 +655,7 @@ "type": "boolean" }, "test": { - "$ref": "#/$defs/Template" + "$ref": "#/$defs/TestTemplate" }, "display": { "$ref": "#/$defs/Template" @@ -697,7 +697,7 @@ "ConfigDBCheck": { "properties": { "test": { - "$ref": "#/$defs/Template" + "$ref": "#/$defs/TestTemplate" }, "display": { "$ref": "#/$defs/Template" @@ -874,7 +874,7 @@ "$ref": "#/$defs/Labels" }, "test": { - "$ref": "#/$defs/Template" + "$ref": "#/$defs/TestTemplate" }, "display": { "$ref": "#/$defs/Template" @@ -972,7 +972,7 @@ "$ref": "#/$defs/Labels" }, "test": { - "$ref": "#/$defs/Template" + "$ref": "#/$defs/TestTemplate" }, "display": { "$ref": "#/$defs/Template" @@ -1083,7 +1083,7 @@ "$ref": "#/$defs/Labels" }, "test": { - "$ref": "#/$defs/Template" + "$ref": "#/$defs/TestTemplate" }, "display": { "$ref": "#/$defs/Template" @@ -1158,7 +1158,7 @@ "$ref": "#/$defs/Labels" }, "test": { - "$ref": "#/$defs/Template" + "$ref": "#/$defs/TestTemplate" }, "display": { "$ref": "#/$defs/Template" @@ -1197,7 +1197,7 @@ "$ref": "#/$defs/Labels" }, "test": { - "$ref": "#/$defs/Template" + "$ref": "#/$defs/TestTemplate" }, "display": { "$ref": "#/$defs/Template" @@ -1325,7 +1325,7 @@ "$ref": "#/$defs/Labels" }, "test": { - "$ref": "#/$defs/Template" + "$ref": "#/$defs/TestTemplate" }, "display": { "$ref": "#/$defs/Template" @@ -1365,7 +1365,7 @@ "$ref": "#/$defs/Labels" }, "test": { - "$ref": "#/$defs/Template" + "$ref": "#/$defs/TestTemplate" }, "display": { "$ref": "#/$defs/Template" @@ -1580,7 +1580,7 @@ "type": "string" }, "test": { - "$ref": "#/$defs/Template" + "$ref": "#/$defs/TestTemplate" }, "display": { "$ref": "#/$defs/Template" @@ -1616,7 +1616,7 @@ "$ref": "#/$defs/Labels" }, "test": { - "$ref": "#/$defs/Template" + "$ref": "#/$defs/TestTemplate" }, "display": { "$ref": "#/$defs/Template" @@ -1779,7 +1779,7 @@ "$ref": "#/$defs/Labels" }, "test": { - "$ref": "#/$defs/Template" + "$ref": "#/$defs/TestTemplate" }, "display": { "$ref": "#/$defs/Template" @@ -1822,7 +1822,7 @@ "$ref": "#/$defs/Labels" }, "test": { - "$ref": "#/$defs/Template" + "$ref": "#/$defs/TestTemplate" }, "display": { "$ref": "#/$defs/Template" @@ -2039,7 +2039,7 @@ "$ref": "#/$defs/Labels" }, "test": { - "$ref": "#/$defs/Template" + "$ref": "#/$defs/TestTemplate" }, "display": { "$ref": "#/$defs/Template" @@ -2195,7 +2195,7 @@ "$ref": "#/$defs/Labels" }, "test": { - "$ref": "#/$defs/Template" + "$ref": "#/$defs/TestTemplate" }, "display": { "$ref": "#/$defs/Template" @@ -2238,7 +2238,7 @@ "$ref": "#/$defs/Labels" }, "test": { - "$ref": "#/$defs/Template" + "$ref": "#/$defs/TestTemplate" }, "display": { "$ref": "#/$defs/Template" @@ -2528,6 +2528,48 @@ "additionalProperties": false, "type": "object" }, + "TestTemplate": { + "properties": { + "template": { + "type": "string" + }, + "jsonPath": { + "type": "string" + }, + "expr": { + "type": "string" + }, + "javascript": { + "type": "string" + }, + "threshold": { + "$ref": "#/$defs/TestThreshold" + } + }, + "additionalProperties": false, + "type": "object" + }, + "TestThreshold": { + "properties": { + "info": { + "type": "string" + }, + "low": { + "type": "string" + }, + "medium": { + "type": "string" + }, + "high": { + "type": "string" + }, + "critical": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object" + }, "Time": { "properties": {}, "additionalProperties": false, diff --git a/config/schemas/component.schema.json b/config/schemas/component.schema.json index 7bc0361e9..0709dbce2 100644 --- a/config/schemas/component.schema.json +++ b/config/schemas/component.schema.json @@ -48,7 +48,7 @@ "$ref": "#/$defs/Labels" }, "test": { - "$ref": "#/$defs/Template" + "$ref": "#/$defs/TestTemplate" }, "display": { "$ref": "#/$defs/Template" @@ -123,7 +123,7 @@ "$ref": "#/$defs/Labels" }, "test": { - "$ref": "#/$defs/Template" + "$ref": "#/$defs/TestTemplate" }, "display": { "$ref": "#/$defs/Template" @@ -163,7 +163,7 @@ "$ref": "#/$defs/Labels" }, "test": { - "$ref": "#/$defs/Template" + "$ref": "#/$defs/TestTemplate" }, "display": { "$ref": "#/$defs/Template" @@ -214,7 +214,7 @@ "$ref": "#/$defs/Labels" }, "test": { - "$ref": "#/$defs/Template" + "$ref": "#/$defs/TestTemplate" }, "display": { "$ref": "#/$defs/Template" @@ -561,7 +561,7 @@ "type": "boolean" }, "test": { - "$ref": "#/$defs/Template" + "$ref": "#/$defs/TestTemplate" }, "display": { "$ref": "#/$defs/Template" @@ -840,7 +840,7 @@ "ConfigDBCheck": { "properties": { "test": { - "$ref": "#/$defs/Template" + "$ref": "#/$defs/TestTemplate" }, "display": { "$ref": "#/$defs/Template" @@ -1035,7 +1035,7 @@ "$ref": "#/$defs/Labels" }, "test": { - "$ref": "#/$defs/Template" + "$ref": "#/$defs/TestTemplate" }, "display": { "$ref": "#/$defs/Template" @@ -1151,7 +1151,7 @@ "$ref": "#/$defs/Labels" }, "test": { - "$ref": "#/$defs/Template" + "$ref": "#/$defs/TestTemplate" }, "display": { "$ref": "#/$defs/Template" @@ -1262,7 +1262,7 @@ "$ref": "#/$defs/Labels" }, "test": { - "$ref": "#/$defs/Template" + "$ref": "#/$defs/TestTemplate" }, "display": { "$ref": "#/$defs/Template" @@ -1337,7 +1337,7 @@ "$ref": "#/$defs/Labels" }, "test": { - "$ref": "#/$defs/Template" + "$ref": "#/$defs/TestTemplate" }, "display": { "$ref": "#/$defs/Template" @@ -1376,7 +1376,7 @@ "$ref": "#/$defs/Labels" }, "test": { - "$ref": "#/$defs/Template" + "$ref": "#/$defs/TestTemplate" }, "display": { "$ref": "#/$defs/Template" @@ -1537,7 +1537,7 @@ "$ref": "#/$defs/Labels" }, "test": { - "$ref": "#/$defs/Template" + "$ref": "#/$defs/TestTemplate" }, "display": { "$ref": "#/$defs/Template" @@ -1577,7 +1577,7 @@ "$ref": "#/$defs/Labels" }, "test": { - "$ref": "#/$defs/Template" + "$ref": "#/$defs/TestTemplate" }, "display": { "$ref": "#/$defs/Template" @@ -1792,7 +1792,7 @@ "type": "string" }, "test": { - "$ref": "#/$defs/Template" + "$ref": "#/$defs/TestTemplate" }, "display": { "$ref": "#/$defs/Template" @@ -1828,7 +1828,7 @@ "$ref": "#/$defs/Labels" }, "test": { - "$ref": "#/$defs/Template" + "$ref": "#/$defs/TestTemplate" }, "display": { "$ref": "#/$defs/Template" @@ -2041,7 +2041,7 @@ "$ref": "#/$defs/Labels" }, "test": { - "$ref": "#/$defs/Template" + "$ref": "#/$defs/TestTemplate" }, "display": { "$ref": "#/$defs/Template" @@ -2084,7 +2084,7 @@ "$ref": "#/$defs/Labels" }, "test": { - "$ref": "#/$defs/Template" + "$ref": "#/$defs/TestTemplate" }, "display": { "$ref": "#/$defs/Template" @@ -2301,7 +2301,7 @@ "$ref": "#/$defs/Labels" }, "test": { - "$ref": "#/$defs/Template" + "$ref": "#/$defs/TestTemplate" }, "display": { "$ref": "#/$defs/Template" @@ -2457,7 +2457,7 @@ "$ref": "#/$defs/Labels" }, "test": { - "$ref": "#/$defs/Template" + "$ref": "#/$defs/TestTemplate" }, "display": { "$ref": "#/$defs/Template" @@ -2500,7 +2500,7 @@ "$ref": "#/$defs/Labels" }, "test": { - "$ref": "#/$defs/Template" + "$ref": "#/$defs/TestTemplate" }, "display": { "$ref": "#/$defs/Template" @@ -2924,6 +2924,48 @@ "additionalProperties": false, "type": "object" }, + "TestTemplate": { + "properties": { + "template": { + "type": "string" + }, + "jsonPath": { + "type": "string" + }, + "expr": { + "type": "string" + }, + "javascript": { + "type": "string" + }, + "threshold": { + "$ref": "#/$defs/TestThreshold" + } + }, + "additionalProperties": false, + "type": "object" + }, + "TestThreshold": { + "properties": { + "info": { + "type": "string" + }, + "low": { + "type": "string" + }, + "medium": { + "type": "string" + }, + "high": { + "type": "string" + }, + "critical": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object" + }, "Time": { "properties": {}, "additionalProperties": false, diff --git a/config/schemas/health_alertmanager.schema.json b/config/schemas/health_alertmanager.schema.json index e8b21a521..66cacdd3a 100644 --- a/config/schemas/health_alertmanager.schema.json +++ b/config/schemas/health_alertmanager.schema.json @@ -18,7 +18,7 @@ "$ref": "#/$defs/Labels" }, "test": { - "$ref": "#/$defs/Template" + "$ref": "#/$defs/TestTemplate" }, "display": { "$ref": "#/$defs/Template" @@ -160,6 +160,48 @@ }, "additionalProperties": false, "type": "object" + }, + "TestTemplate": { + "properties": { + "template": { + "type": "string" + }, + "jsonPath": { + "type": "string" + }, + "expr": { + "type": "string" + }, + "javascript": { + "type": "string" + }, + "threshold": { + "$ref": "#/$defs/TestThreshold" + } + }, + "additionalProperties": false, + "type": "object" + }, + "TestThreshold": { + "properties": { + "info": { + "type": "string" + }, + "low": { + "type": "string" + }, + "medium": { + "type": "string" + }, + "high": { + "type": "string" + }, + "critical": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object" } } } \ No newline at end of file diff --git a/config/schemas/health_awsconfig.schema.json b/config/schemas/health_awsconfig.schema.json index 3fc17bcba..f5090a1ad 100644 --- a/config/schemas/health_awsconfig.schema.json +++ b/config/schemas/health_awsconfig.schema.json @@ -48,7 +48,7 @@ "$ref": "#/$defs/Labels" }, "test": { - "$ref": "#/$defs/Template" + "$ref": "#/$defs/TestTemplate" }, "display": { "$ref": "#/$defs/Template" @@ -155,6 +155,48 @@ }, "additionalProperties": false, "type": "object" + }, + "TestTemplate": { + "properties": { + "template": { + "type": "string" + }, + "jsonPath": { + "type": "string" + }, + "expr": { + "type": "string" + }, + "javascript": { + "type": "string" + }, + "threshold": { + "$ref": "#/$defs/TestThreshold" + } + }, + "additionalProperties": false, + "type": "object" + }, + "TestThreshold": { + "properties": { + "info": { + "type": "string" + }, + "low": { + "type": "string" + }, + "medium": { + "type": "string" + }, + "high": { + "type": "string" + }, + "critical": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object" } } } \ No newline at end of file diff --git a/config/schemas/health_awsconfigrule.schema.json b/config/schemas/health_awsconfigrule.schema.json index e3c0ba95e..86ebdf707 100644 --- a/config/schemas/health_awsconfigrule.schema.json +++ b/config/schemas/health_awsconfigrule.schema.json @@ -48,7 +48,7 @@ "$ref": "#/$defs/Labels" }, "test": { - "$ref": "#/$defs/Template" + "$ref": "#/$defs/TestTemplate" }, "display": { "$ref": "#/$defs/Template" @@ -166,6 +166,48 @@ }, "additionalProperties": false, "type": "object" + }, + "TestTemplate": { + "properties": { + "template": { + "type": "string" + }, + "jsonPath": { + "type": "string" + }, + "expr": { + "type": "string" + }, + "javascript": { + "type": "string" + }, + "threshold": { + "$ref": "#/$defs/TestThreshold" + } + }, + "additionalProperties": false, + "type": "object" + }, + "TestThreshold": { + "properties": { + "info": { + "type": "string" + }, + "low": { + "type": "string" + }, + "medium": { + "type": "string" + }, + "high": { + "type": "string" + }, + "critical": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object" } } } \ No newline at end of file diff --git a/config/schemas/health_azuredevops.schema.json b/config/schemas/health_azuredevops.schema.json index b231f3825..c9755cece 100644 --- a/config/schemas/health_azuredevops.schema.json +++ b/config/schemas/health_azuredevops.schema.json @@ -18,7 +18,7 @@ "$ref": "#/$defs/Labels" }, "test": { - "$ref": "#/$defs/Template" + "$ref": "#/$defs/TestTemplate" }, "display": { "$ref": "#/$defs/Template" @@ -154,6 +154,48 @@ }, "additionalProperties": false, "type": "object" + }, + "TestTemplate": { + "properties": { + "template": { + "type": "string" + }, + "jsonPath": { + "type": "string" + }, + "expr": { + "type": "string" + }, + "javascript": { + "type": "string" + }, + "threshold": { + "$ref": "#/$defs/TestThreshold" + } + }, + "additionalProperties": false, + "type": "object" + }, + "TestThreshold": { + "properties": { + "info": { + "type": "string" + }, + "low": { + "type": "string" + }, + "medium": { + "type": "string" + }, + "high": { + "type": "string" + }, + "critical": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object" } } } \ No newline at end of file diff --git a/config/schemas/health_cloudwatch.schema.json b/config/schemas/health_cloudwatch.schema.json index e93212c60..c885362d7 100644 --- a/config/schemas/health_cloudwatch.schema.json +++ b/config/schemas/health_cloudwatch.schema.json @@ -42,7 +42,7 @@ "type": "boolean" }, "test": { - "$ref": "#/$defs/Template" + "$ref": "#/$defs/TestTemplate" }, "display": { "$ref": "#/$defs/Template" @@ -163,6 +163,48 @@ }, "additionalProperties": false, "type": "object" + }, + "TestTemplate": { + "properties": { + "template": { + "type": "string" + }, + "jsonPath": { + "type": "string" + }, + "expr": { + "type": "string" + }, + "javascript": { + "type": "string" + }, + "threshold": { + "$ref": "#/$defs/TestThreshold" + } + }, + "additionalProperties": false, + "type": "object" + }, + "TestThreshold": { + "properties": { + "info": { + "type": "string" + }, + "low": { + "type": "string" + }, + "medium": { + "type": "string" + }, + "high": { + "type": "string" + }, + "critical": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object" } } } \ No newline at end of file diff --git a/config/schemas/health_configdb.schema.json b/config/schemas/health_configdb.schema.json index 8db4cbad5..35d7bdbc1 100644 --- a/config/schemas/health_configdb.schema.json +++ b/config/schemas/health_configdb.schema.json @@ -6,7 +6,7 @@ "ConfigDBCheck": { "properties": { "test": { - "$ref": "#/$defs/Template" + "$ref": "#/$defs/TestTemplate" }, "display": { "$ref": "#/$defs/Template" @@ -62,6 +62,48 @@ }, "additionalProperties": false, "type": "object" + }, + "TestTemplate": { + "properties": { + "template": { + "type": "string" + }, + "jsonPath": { + "type": "string" + }, + "expr": { + "type": "string" + }, + "javascript": { + "type": "string" + }, + "threshold": { + "$ref": "#/$defs/TestThreshold" + } + }, + "additionalProperties": false, + "type": "object" + }, + "TestThreshold": { + "properties": { + "info": { + "type": "string" + }, + "low": { + "type": "string" + }, + "medium": { + "type": "string" + }, + "high": { + "type": "string" + }, + "critical": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object" } } } \ No newline at end of file diff --git a/config/schemas/health_databasebackupcheck.schema.json b/config/schemas/health_databasebackupcheck.schema.json index 707174a84..43f651076 100644 --- a/config/schemas/health_databasebackupcheck.schema.json +++ b/config/schemas/health_databasebackupcheck.schema.json @@ -33,7 +33,7 @@ "$ref": "#/$defs/Labels" }, "test": { - "$ref": "#/$defs/Template" + "$ref": "#/$defs/TestTemplate" }, "display": { "$ref": "#/$defs/Template" @@ -155,6 +155,48 @@ }, "additionalProperties": false, "type": "object" + }, + "TestTemplate": { + "properties": { + "template": { + "type": "string" + }, + "jsonPath": { + "type": "string" + }, + "expr": { + "type": "string" + }, + "javascript": { + "type": "string" + }, + "threshold": { + "$ref": "#/$defs/TestThreshold" + } + }, + "additionalProperties": false, + "type": "object" + }, + "TestThreshold": { + "properties": { + "info": { + "type": "string" + }, + "low": { + "type": "string" + }, + "medium": { + "type": "string" + }, + "high": { + "type": "string" + }, + "critical": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object" } } } \ No newline at end of file diff --git a/config/schemas/health_dynatrace.schema.json b/config/schemas/health_dynatrace.schema.json index 07c64266b..ab58e0903 100644 --- a/config/schemas/health_dynatrace.schema.json +++ b/config/schemas/health_dynatrace.schema.json @@ -33,7 +33,7 @@ "$ref": "#/$defs/Labels" }, "test": { - "$ref": "#/$defs/Template" + "$ref": "#/$defs/TestTemplate" }, "display": { "$ref": "#/$defs/Template" @@ -127,6 +127,48 @@ }, "additionalProperties": false, "type": "object" + }, + "TestTemplate": { + "properties": { + "template": { + "type": "string" + }, + "jsonPath": { + "type": "string" + }, + "expr": { + "type": "string" + }, + "javascript": { + "type": "string" + }, + "threshold": { + "$ref": "#/$defs/TestThreshold" + } + }, + "additionalProperties": false, + "type": "object" + }, + "TestThreshold": { + "properties": { + "info": { + "type": "string" + }, + "low": { + "type": "string" + }, + "medium": { + "type": "string" + }, + "high": { + "type": "string" + }, + "critical": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object" } } } \ No newline at end of file diff --git a/config/schemas/health_elasticsearch.schema.json b/config/schemas/health_elasticsearch.schema.json index 7fbf163a7..8717dadfc 100644 --- a/config/schemas/health_elasticsearch.schema.json +++ b/config/schemas/health_elasticsearch.schema.json @@ -49,7 +49,7 @@ "$ref": "#/$defs/Labels" }, "test": { - "$ref": "#/$defs/Template" + "$ref": "#/$defs/TestTemplate" }, "display": { "$ref": "#/$defs/Template" @@ -149,6 +149,48 @@ }, "additionalProperties": false, "type": "object" + }, + "TestTemplate": { + "properties": { + "template": { + "type": "string" + }, + "jsonPath": { + "type": "string" + }, + "expr": { + "type": "string" + }, + "javascript": { + "type": "string" + }, + "threshold": { + "$ref": "#/$defs/TestThreshold" + } + }, + "additionalProperties": false, + "type": "object" + }, + "TestThreshold": { + "properties": { + "info": { + "type": "string" + }, + "low": { + "type": "string" + }, + "medium": { + "type": "string" + }, + "high": { + "type": "string" + }, + "critical": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object" } } } \ No newline at end of file diff --git a/config/schemas/health_exec.schema.json b/config/schemas/health_exec.schema.json index ffe2b7f99..70085b97c 100644 --- a/config/schemas/health_exec.schema.json +++ b/config/schemas/health_exec.schema.json @@ -18,7 +18,7 @@ "$ref": "#/$defs/Labels" }, "test": { - "$ref": "#/$defs/Template" + "$ref": "#/$defs/TestTemplate" }, "display": { "$ref": "#/$defs/Template" @@ -62,6 +62,48 @@ }, "additionalProperties": false, "type": "object" + }, + "TestTemplate": { + "properties": { + "template": { + "type": "string" + }, + "jsonPath": { + "type": "string" + }, + "expr": { + "type": "string" + }, + "javascript": { + "type": "string" + }, + "threshold": { + "$ref": "#/$defs/TestThreshold" + } + }, + "additionalProperties": false, + "type": "object" + }, + "TestThreshold": { + "properties": { + "info": { + "type": "string" + }, + "low": { + "type": "string" + }, + "medium": { + "type": "string" + }, + "high": { + "type": "string" + }, + "critical": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object" } } } \ No newline at end of file diff --git a/config/schemas/health_folder.schema.json b/config/schemas/health_folder.schema.json index 080b7efe7..5b838e76f 100644 --- a/config/schemas/health_folder.schema.json +++ b/config/schemas/health_folder.schema.json @@ -106,7 +106,7 @@ "$ref": "#/$defs/Labels" }, "test": { - "$ref": "#/$defs/Template" + "$ref": "#/$defs/TestTemplate" }, "display": { "$ref": "#/$defs/Template" @@ -292,6 +292,48 @@ }, "additionalProperties": false, "type": "object" + }, + "TestTemplate": { + "properties": { + "template": { + "type": "string" + }, + "jsonPath": { + "type": "string" + }, + "expr": { + "type": "string" + }, + "javascript": { + "type": "string" + }, + "threshold": { + "$ref": "#/$defs/TestThreshold" + } + }, + "additionalProperties": false, + "type": "object" + }, + "TestThreshold": { + "properties": { + "info": { + "type": "string" + }, + "low": { + "type": "string" + }, + "medium": { + "type": "string" + }, + "high": { + "type": "string" + }, + "critical": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object" } } } \ No newline at end of file diff --git a/config/schemas/health_github.schema.json b/config/schemas/health_github.schema.json index 38e996a23..1ae126638 100644 --- a/config/schemas/health_github.schema.json +++ b/config/schemas/health_github.schema.json @@ -60,7 +60,7 @@ "$ref": "#/$defs/Labels" }, "test": { - "$ref": "#/$defs/Template" + "$ref": "#/$defs/TestTemplate" }, "display": { "$ref": "#/$defs/Template" @@ -125,6 +125,48 @@ }, "additionalProperties": false, "type": "object" + }, + "TestTemplate": { + "properties": { + "template": { + "type": "string" + }, + "jsonPath": { + "type": "string" + }, + "expr": { + "type": "string" + }, + "javascript": { + "type": "string" + }, + "threshold": { + "$ref": "#/$defs/TestThreshold" + } + }, + "additionalProperties": false, + "type": "object" + }, + "TestThreshold": { + "properties": { + "info": { + "type": "string" + }, + "low": { + "type": "string" + }, + "medium": { + "type": "string" + }, + "high": { + "type": "string" + }, + "critical": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object" } } } \ No newline at end of file diff --git a/config/schemas/health_http.schema.json b/config/schemas/health_http.schema.json index 86f00743b..aa5ae61d2 100644 --- a/config/schemas/health_http.schema.json +++ b/config/schemas/health_http.schema.json @@ -76,7 +76,7 @@ "$ref": "#/$defs/Labels" }, "test": { - "$ref": "#/$defs/Template" + "$ref": "#/$defs/TestTemplate" }, "display": { "$ref": "#/$defs/Template" @@ -198,6 +198,48 @@ }, "additionalProperties": false, "type": "object" + }, + "TestTemplate": { + "properties": { + "template": { + "type": "string" + }, + "jsonPath": { + "type": "string" + }, + "expr": { + "type": "string" + }, + "javascript": { + "type": "string" + }, + "threshold": { + "$ref": "#/$defs/TestThreshold" + } + }, + "additionalProperties": false, + "type": "object" + }, + "TestThreshold": { + "properties": { + "info": { + "type": "string" + }, + "low": { + "type": "string" + }, + "medium": { + "type": "string" + }, + "high": { + "type": "string" + }, + "critical": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object" } } } \ No newline at end of file diff --git a/config/schemas/health_junit.schema.json b/config/schemas/health_junit.schema.json index 388e7a2ed..24d390386 100644 --- a/config/schemas/health_junit.schema.json +++ b/config/schemas/health_junit.schema.json @@ -21,7 +21,7 @@ "type": "string" }, "test": { - "$ref": "#/$defs/Template" + "$ref": "#/$defs/TestTemplate" }, "display": { "$ref": "#/$defs/Template" @@ -67,6 +67,48 @@ }, "additionalProperties": false, "type": "object" + }, + "TestTemplate": { + "properties": { + "template": { + "type": "string" + }, + "jsonPath": { + "type": "string" + }, + "expr": { + "type": "string" + }, + "javascript": { + "type": "string" + }, + "threshold": { + "$ref": "#/$defs/TestThreshold" + } + }, + "additionalProperties": false, + "type": "object" + }, + "TestThreshold": { + "properties": { + "info": { + "type": "string" + }, + "low": { + "type": "string" + }, + "medium": { + "type": "string" + }, + "high": { + "type": "string" + }, + "critical": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object" } } } \ No newline at end of file diff --git a/config/schemas/health_kubernetes.schema.json b/config/schemas/health_kubernetes.schema.json index 1a1673ad7..43a4a9089 100644 --- a/config/schemas/health_kubernetes.schema.json +++ b/config/schemas/health_kubernetes.schema.json @@ -18,7 +18,7 @@ "$ref": "#/$defs/Labels" }, "test": { - "$ref": "#/$defs/Template" + "$ref": "#/$defs/TestTemplate" }, "display": { "$ref": "#/$defs/Template" @@ -92,6 +92,48 @@ }, "additionalProperties": false, "type": "object" + }, + "TestTemplate": { + "properties": { + "template": { + "type": "string" + }, + "jsonPath": { + "type": "string" + }, + "expr": { + "type": "string" + }, + "javascript": { + "type": "string" + }, + "threshold": { + "$ref": "#/$defs/TestThreshold" + } + }, + "additionalProperties": false, + "type": "object" + }, + "TestThreshold": { + "properties": { + "info": { + "type": "string" + }, + "low": { + "type": "string" + }, + "medium": { + "type": "string" + }, + "high": { + "type": "string" + }, + "critical": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object" } } } \ No newline at end of file diff --git a/config/schemas/health_mssql.schema.json b/config/schemas/health_mssql.schema.json index 6bbe145e9..7dbffd655 100644 --- a/config/schemas/health_mssql.schema.json +++ b/config/schemas/health_mssql.schema.json @@ -84,7 +84,7 @@ "$ref": "#/$defs/Labels" }, "test": { - "$ref": "#/$defs/Template" + "$ref": "#/$defs/TestTemplate" }, "display": { "$ref": "#/$defs/Template" @@ -144,6 +144,48 @@ }, "additionalProperties": false, "type": "object" + }, + "TestTemplate": { + "properties": { + "template": { + "type": "string" + }, + "jsonPath": { + "type": "string" + }, + "expr": { + "type": "string" + }, + "javascript": { + "type": "string" + }, + "threshold": { + "$ref": "#/$defs/TestThreshold" + } + }, + "additionalProperties": false, + "type": "object" + }, + "TestThreshold": { + "properties": { + "info": { + "type": "string" + }, + "low": { + "type": "string" + }, + "medium": { + "type": "string" + }, + "high": { + "type": "string" + }, + "critical": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object" } } } \ No newline at end of file diff --git a/config/schemas/health_mysql.schema.json b/config/schemas/health_mysql.schema.json index 412c22a59..815006675 100644 --- a/config/schemas/health_mysql.schema.json +++ b/config/schemas/health_mysql.schema.json @@ -84,7 +84,7 @@ "$ref": "#/$defs/Labels" }, "test": { - "$ref": "#/$defs/Template" + "$ref": "#/$defs/TestTemplate" }, "display": { "$ref": "#/$defs/Template" @@ -144,6 +144,48 @@ }, "additionalProperties": false, "type": "object" + }, + "TestTemplate": { + "properties": { + "template": { + "type": "string" + }, + "jsonPath": { + "type": "string" + }, + "expr": { + "type": "string" + }, + "javascript": { + "type": "string" + }, + "threshold": { + "$ref": "#/$defs/TestThreshold" + } + }, + "additionalProperties": false, + "type": "object" + }, + "TestThreshold": { + "properties": { + "info": { + "type": "string" + }, + "low": { + "type": "string" + }, + "medium": { + "type": "string" + }, + "high": { + "type": "string" + }, + "critical": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object" } } } \ No newline at end of file diff --git a/config/schemas/health_opensearch.schema.json b/config/schemas/health_opensearch.schema.json index 62cf19442..b4b94bd0a 100644 --- a/config/schemas/health_opensearch.schema.json +++ b/config/schemas/health_opensearch.schema.json @@ -84,7 +84,7 @@ "$ref": "#/$defs/Labels" }, "test": { - "$ref": "#/$defs/Template" + "$ref": "#/$defs/TestTemplate" }, "display": { "$ref": "#/$defs/Template" @@ -152,6 +152,48 @@ }, "additionalProperties": false, "type": "object" + }, + "TestTemplate": { + "properties": { + "template": { + "type": "string" + }, + "jsonPath": { + "type": "string" + }, + "expr": { + "type": "string" + }, + "javascript": { + "type": "string" + }, + "threshold": { + "$ref": "#/$defs/TestThreshold" + } + }, + "additionalProperties": false, + "type": "object" + }, + "TestThreshold": { + "properties": { + "info": { + "type": "string" + }, + "low": { + "type": "string" + }, + "medium": { + "type": "string" + }, + "high": { + "type": "string" + }, + "critical": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object" } } } \ No newline at end of file diff --git a/config/schemas/health_postgres.schema.json b/config/schemas/health_postgres.schema.json index 196dce3b5..52b850876 100644 --- a/config/schemas/health_postgres.schema.json +++ b/config/schemas/health_postgres.schema.json @@ -84,7 +84,7 @@ "$ref": "#/$defs/Labels" }, "test": { - "$ref": "#/$defs/Template" + "$ref": "#/$defs/TestTemplate" }, "display": { "$ref": "#/$defs/Template" @@ -144,6 +144,48 @@ }, "additionalProperties": false, "type": "object" + }, + "TestTemplate": { + "properties": { + "template": { + "type": "string" + }, + "jsonPath": { + "type": "string" + }, + "expr": { + "type": "string" + }, + "javascript": { + "type": "string" + }, + "threshold": { + "$ref": "#/$defs/TestThreshold" + } + }, + "additionalProperties": false, + "type": "object" + }, + "TestThreshold": { + "properties": { + "info": { + "type": "string" + }, + "low": { + "type": "string" + }, + "medium": { + "type": "string" + }, + "high": { + "type": "string" + }, + "critical": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object" } } } \ No newline at end of file diff --git a/config/schemas/health_prometheus.schema.json b/config/schemas/health_prometheus.schema.json index 9e7a1de14..11c77055b 100644 --- a/config/schemas/health_prometheus.schema.json +++ b/config/schemas/health_prometheus.schema.json @@ -26,7 +26,7 @@ "$ref": "#/$defs/Labels" }, "test": { - "$ref": "#/$defs/Template" + "$ref": "#/$defs/TestTemplate" }, "display": { "$ref": "#/$defs/Template" @@ -69,6 +69,48 @@ }, "additionalProperties": false, "type": "object" + }, + "TestTemplate": { + "properties": { + "template": { + "type": "string" + }, + "jsonPath": { + "type": "string" + }, + "expr": { + "type": "string" + }, + "javascript": { + "type": "string" + }, + "threshold": { + "$ref": "#/$defs/TestThreshold" + } + }, + "additionalProperties": false, + "type": "object" + }, + "TestThreshold": { + "properties": { + "info": { + "type": "string" + }, + "low": { + "type": "string" + }, + "medium": { + "type": "string" + }, + "high": { + "type": "string" + }, + "critical": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object" } } } \ No newline at end of file diff --git a/config/schemas/topology.schema.json b/config/schemas/topology.schema.json index 628b6f8c5..1e82b0449 100644 --- a/config/schemas/topology.schema.json +++ b/config/schemas/topology.schema.json @@ -48,7 +48,7 @@ "$ref": "#/$defs/Labels" }, "test": { - "$ref": "#/$defs/Template" + "$ref": "#/$defs/TestTemplate" }, "display": { "$ref": "#/$defs/Template" @@ -123,7 +123,7 @@ "$ref": "#/$defs/Labels" }, "test": { - "$ref": "#/$defs/Template" + "$ref": "#/$defs/TestTemplate" }, "display": { "$ref": "#/$defs/Template" @@ -163,7 +163,7 @@ "$ref": "#/$defs/Labels" }, "test": { - "$ref": "#/$defs/Template" + "$ref": "#/$defs/TestTemplate" }, "display": { "$ref": "#/$defs/Template" @@ -214,7 +214,7 @@ "$ref": "#/$defs/Labels" }, "test": { - "$ref": "#/$defs/Template" + "$ref": "#/$defs/TestTemplate" }, "display": { "$ref": "#/$defs/Template" @@ -561,7 +561,7 @@ "type": "boolean" }, "test": { - "$ref": "#/$defs/Template" + "$ref": "#/$defs/TestTemplate" }, "display": { "$ref": "#/$defs/Template" @@ -810,7 +810,7 @@ "ConfigDBCheck": { "properties": { "test": { - "$ref": "#/$defs/Template" + "$ref": "#/$defs/TestTemplate" }, "display": { "$ref": "#/$defs/Template" @@ -1005,7 +1005,7 @@ "$ref": "#/$defs/Labels" }, "test": { - "$ref": "#/$defs/Template" + "$ref": "#/$defs/TestTemplate" }, "display": { "$ref": "#/$defs/Template" @@ -1121,7 +1121,7 @@ "$ref": "#/$defs/Labels" }, "test": { - "$ref": "#/$defs/Template" + "$ref": "#/$defs/TestTemplate" }, "display": { "$ref": "#/$defs/Template" @@ -1232,7 +1232,7 @@ "$ref": "#/$defs/Labels" }, "test": { - "$ref": "#/$defs/Template" + "$ref": "#/$defs/TestTemplate" }, "display": { "$ref": "#/$defs/Template" @@ -1307,7 +1307,7 @@ "$ref": "#/$defs/Labels" }, "test": { - "$ref": "#/$defs/Template" + "$ref": "#/$defs/TestTemplate" }, "display": { "$ref": "#/$defs/Template" @@ -1346,7 +1346,7 @@ "$ref": "#/$defs/Labels" }, "test": { - "$ref": "#/$defs/Template" + "$ref": "#/$defs/TestTemplate" }, "display": { "$ref": "#/$defs/Template" @@ -1507,7 +1507,7 @@ "$ref": "#/$defs/Labels" }, "test": { - "$ref": "#/$defs/Template" + "$ref": "#/$defs/TestTemplate" }, "display": { "$ref": "#/$defs/Template" @@ -1547,7 +1547,7 @@ "$ref": "#/$defs/Labels" }, "test": { - "$ref": "#/$defs/Template" + "$ref": "#/$defs/TestTemplate" }, "display": { "$ref": "#/$defs/Template" @@ -1762,7 +1762,7 @@ "type": "string" }, "test": { - "$ref": "#/$defs/Template" + "$ref": "#/$defs/TestTemplate" }, "display": { "$ref": "#/$defs/Template" @@ -1798,7 +1798,7 @@ "$ref": "#/$defs/Labels" }, "test": { - "$ref": "#/$defs/Template" + "$ref": "#/$defs/TestTemplate" }, "display": { "$ref": "#/$defs/Template" @@ -2011,7 +2011,7 @@ "$ref": "#/$defs/Labels" }, "test": { - "$ref": "#/$defs/Template" + "$ref": "#/$defs/TestTemplate" }, "display": { "$ref": "#/$defs/Template" @@ -2054,7 +2054,7 @@ "$ref": "#/$defs/Labels" }, "test": { - "$ref": "#/$defs/Template" + "$ref": "#/$defs/TestTemplate" }, "display": { "$ref": "#/$defs/Template" @@ -2271,7 +2271,7 @@ "$ref": "#/$defs/Labels" }, "test": { - "$ref": "#/$defs/Template" + "$ref": "#/$defs/TestTemplate" }, "display": { "$ref": "#/$defs/Template" @@ -2427,7 +2427,7 @@ "$ref": "#/$defs/Labels" }, "test": { - "$ref": "#/$defs/Template" + "$ref": "#/$defs/TestTemplate" }, "display": { "$ref": "#/$defs/Template" @@ -2470,7 +2470,7 @@ "$ref": "#/$defs/Labels" }, "test": { - "$ref": "#/$defs/Template" + "$ref": "#/$defs/TestTemplate" }, "display": { "$ref": "#/$defs/Template" @@ -2894,6 +2894,48 @@ "additionalProperties": false, "type": "object" }, + "TestTemplate": { + "properties": { + "template": { + "type": "string" + }, + "jsonPath": { + "type": "string" + }, + "expr": { + "type": "string" + }, + "javascript": { + "type": "string" + }, + "threshold": { + "$ref": "#/$defs/TestThreshold" + } + }, + "additionalProperties": false, + "type": "object" + }, + "TestThreshold": { + "properties": { + "info": { + "type": "string" + }, + "low": { + "type": "string" + }, + "medium": { + "type": "string" + }, + "high": { + "type": "string" + }, + "critical": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object" + }, "Time": { "properties": {}, "additionalProperties": false, diff --git a/go.mod b/go.mod index b8473af16..3285342f5 100644 --- a/go.mod +++ b/go.mod @@ -22,7 +22,7 @@ require ( github.com/elastic/go-elasticsearch/v8 v8.1.0 github.com/fergusstrange/embedded-postgres v1.21.0 github.com/flanksource/commons v1.10.0 - github.com/flanksource/duty v1.0.113 + github.com/flanksource/duty v1.0.117 github.com/flanksource/kommons v0.31.1 github.com/friendsofgo/errors v0.9.2 github.com/go-ldap/ldap/v3 v3.4.1 diff --git a/go.sum b/go.sum index deb0c11f5..83db39967 100644 --- a/go.sum +++ b/go.sum @@ -1091,8 +1091,8 @@ github.com/fergusstrange/embedded-postgres v1.21.0 h1:Sups0nR31+OB4iOZ0ZU4IwUDsB github.com/fergusstrange/embedded-postgres v1.21.0/go.mod h1:wL562t1V+iuFwq0UcgMi2e9rp8CROY9wxWZEfP8Y874= github.com/flanksource/commons v1.10.0 h1:Mc+fzxq1rOJ08lapF0cc0bo9ZKNDxA7/81q2D/5jt0Q= github.com/flanksource/commons v1.10.0/go.mod h1:HpVjPtNe7v0UPk97kO/uUhOrYQ8yFD/mGglrTCkc9Ag= -github.com/flanksource/duty v1.0.113 h1:iQeMhn/Vjz+Rap4TpniGEwLOXcFeg9+X1GtcUsWp3+g= -github.com/flanksource/duty v1.0.113/go.mod h1:RJ/kcZ7dbL8/52tem757szVIA3IomS8bOAZIK0xb4rk= +github.com/flanksource/duty v1.0.117 h1:vuTQi2+CV758g8pdMCZP/PbmVkqMXAgQcUayzd6hNMo= +github.com/flanksource/duty v1.0.117/go.mod h1:RJ/kcZ7dbL8/52tem757szVIA3IomS8bOAZIK0xb4rk= github.com/flanksource/gomplate/v3 v3.20.1/go.mod h1:LPpzujBIg9HBXRUngDKK/zNmEjHpEUieKa/2oRjkCzI= github.com/flanksource/gomplate/v3 v3.20.3 h1:mnNaO37uwvv8Kvi4Xswj1tHKP5UMre3FLNaKvAwqhSw= github.com/flanksource/gomplate/v3 v3.20.3/go.mod h1:l4iCvp30TdhZk89eRGuNkPwlRjJLXdUSblr+VyuZfAk= diff --git a/hack/generate-schemas/go.mod b/hack/generate-schemas/go.mod index 276823dba..76537324c 100644 --- a/hack/generate-schemas/go.mod +++ b/hack/generate-schemas/go.mod @@ -73,7 +73,7 @@ require ( github.com/dustin/go-humanize v1.0.1 // indirect github.com/dustin/gojson v0.0.0-20160307161227-2e71ec9dd5ad // indirect github.com/emirpasic/gods v1.18.1 // indirect - github.com/flanksource/duty v1.0.113 // indirect + github.com/flanksource/duty v1.0.117 // indirect github.com/ghodss/yaml v1.0.0 // indirect github.com/go-logr/logr v1.2.4 // indirect github.com/go-openapi/inflect v0.19.0 // indirect diff --git a/hack/generate-schemas/go.sum b/hack/generate-schemas/go.sum index cd4aa426e..45347cff6 100644 --- a/hack/generate-schemas/go.sum +++ b/hack/generate-schemas/go.sum @@ -811,8 +811,8 @@ github.com/felixge/httpsnoop v1.0.3/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSw github.com/fergusstrange/embedded-postgres v1.21.0 h1:Sups0nR31+OB4iOZ0ZU4IwUDsB+dVGmcqj4S2ko0qTI= github.com/flanksource/commons v1.10.0 h1:Mc+fzxq1rOJ08lapF0cc0bo9ZKNDxA7/81q2D/5jt0Q= github.com/flanksource/commons v1.10.0/go.mod h1:HpVjPtNe7v0UPk97kO/uUhOrYQ8yFD/mGglrTCkc9Ag= -github.com/flanksource/duty v1.0.113 h1:iQeMhn/Vjz+Rap4TpniGEwLOXcFeg9+X1GtcUsWp3+g= -github.com/flanksource/duty v1.0.113/go.mod h1:RJ/kcZ7dbL8/52tem757szVIA3IomS8bOAZIK0xb4rk= +github.com/flanksource/duty v1.0.117 h1:vuTQi2+CV758g8pdMCZP/PbmVkqMXAgQcUayzd6hNMo= +github.com/flanksource/duty v1.0.117/go.mod h1:RJ/kcZ7dbL8/52tem757szVIA3IomS8bOAZIK0xb4rk= github.com/flanksource/gomplate/v3 v3.20.1/go.mod h1:LPpzujBIg9HBXRUngDKK/zNmEjHpEUieKa/2oRjkCzI= github.com/flanksource/gomplate/v3 v3.20.3 h1:mnNaO37uwvv8Kvi4Xswj1tHKP5UMre3FLNaKvAwqhSw= github.com/flanksource/gomplate/v3 v3.20.3/go.mod h1:l4iCvp30TdhZk89eRGuNkPwlRjJLXdUSblr+VyuZfAk= @@ -1481,8 +1481,8 @@ github.com/onsi/ginkgo v1.8.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+W github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= github.com/onsi/ginkgo v1.16.2/go.mod h1:CObGmKUOKaSC0RjmoAK7tKyn4Azo5P2IWuoMnvwxz1E= +github.com/onsi/ginkgo v1.16.4 h1:29JGrr5oVBm5ulCWet69zQkzWipVXIol6ygQUe/EzNc= github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0= -github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= github.com/onsi/ginkgo/v2 v2.1.3/go.mod h1:vw5CSIxN1JObi/U8gcbwft7ZxR2dgaR70JSE3/PpL4c= github.com/onsi/ginkgo/v2 v2.1.4/go.mod h1:um6tUpWM/cxCK3/FK8BXqEiUMUwRgSM4JXG47RKZmLU= github.com/onsi/ginkgo/v2 v2.1.6/go.mod h1:MEH45j8TBi6u9BMogfbp0stKC5cdGjumZj5Y7AG4VIk= diff --git a/pkg/api.go b/pkg/api.go index 2d61d7b7d..249312c34 100644 --- a/pkg/api.go +++ b/pkg/api.go @@ -12,6 +12,7 @@ import ( "github.com/flanksource/canary-checker/pkg/utils" "github.com/flanksource/commons/console" "github.com/flanksource/commons/logger" + "github.com/flanksource/duty/models" "github.com/google/uuid" "github.com/lib/pq" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -45,14 +46,15 @@ func (t *JSONTime) UnmarshalJSON(b []byte) error { } type CheckStatus struct { - Status bool `json:"status"` - Invalid bool `json:"invalid,omitempty"` - Time string `json:"time"` - Duration int `json:"duration"` - Message string `json:"message,omitempty"` - Error string `json:"error,omitempty"` - Detail interface{} `json:"-"` - Check *external.Check `json:"check,omitempty"` + Status bool `json:"status"` + Invalid bool `json:"invalid,omitempty"` + Time string `json:"time"` + Duration int `json:"duration"` + Message string `json:"message,omitempty"` + Error string `json:"error,omitempty"` + Detail interface{} `json:"-"` + Check *external.Check `json:"check,omitempty"` + TestSeverity models.Severity `json:"severity,omitempty"` } func (s CheckStatus) GetTime() (time.Time, error) { @@ -184,6 +186,7 @@ type Check struct { CanaryName string `json:"canary_name" gorm:"-"` Namespace string `json:"namespace" gorm:"-"` Labels types.JSONStringMap `json:"labels" gorm:"type:jsonstringmap"` + TestThreshold *v1.TestThreshold `json:"testThreshold,omitempty" gorm:"-"` Description string `json:"description,omitempty"` Status string `json:"status,omitempty"` Uptime Uptime `json:"uptime" gorm:"-"` @@ -205,7 +208,7 @@ type Check struct { } func FromExternalCheck(canary Canary, check external.Check) Check { - return Check{ + c := Check{ CanaryID: canary.ID, Type: check.GetType(), Icon: check.GetIcon(), @@ -215,18 +218,25 @@ func FromExternalCheck(canary Canary, check external.Check) Check { CanaryName: canary.Name, Labels: labels.FilterLabels(canary.Labels), } + + if testable, ok := check.(v1.TestFunction); ok { + c.TestThreshold = testable.GetTestThreshold() + } + + return c } func FromResult(result CheckResult) CheckStatus { return CheckStatus{ - Status: result.Pass, - Invalid: result.Invalid, - Duration: int(result.Duration), - Time: time.Now().UTC().Format(time.RFC3339), - Message: result.Message, - Error: result.Error, - Detail: result.Detail, - Check: &result.Check, + Status: result.Pass, + Invalid: result.Invalid, + Duration: int(result.Duration), + Time: time.Now().UTC().Format(time.RFC3339), + Message: result.Message, + Error: result.Error, + Detail: result.Detail, + Check: &result.Check, + TestSeverity: result.Severity, } } func FromV1(canary v1.Canary, check external.Check, statuses ...CheckStatus) Check { @@ -384,6 +394,7 @@ type URL struct { } type SystemResult struct{} + type CheckResult struct { Start time.Time Pass bool @@ -396,9 +407,9 @@ type CheckResult struct { Message string Error string Metrics []Metric - // Check is the configuration - Check external.Check - Canary v1.Canary + Check external.Check // Check is the configuration + Canary v1.Canary + Severity models.Severity } func (result CheckResult) GetDescription() string { diff --git a/pkg/cache/postgres.go b/pkg/cache/postgres.go index 40665c4fa..7ccc374cf 100644 --- a/pkg/cache/postgres.go +++ b/pkg/cache/postgres.go @@ -83,12 +83,12 @@ func (c *postgresCache) AddCheckStatus(check pkg.Check, status pkg.CheckStatus) invalid, message, status, + severity, time, created_at ) - VALUES($1,$2,$3,$4,$5,$6,$7,$8,NOW()) - ON CONFLICT (check_id,time) DO NOTHING; - `, + VALUES($1,$2,$3,$4,$5,$6,$7,$8,$9,NOW()) + ON CONFLICT (check_id,time) DO NOTHING;`, checks[0].ID, string(jsonDetails), status.Duration, @@ -96,6 +96,7 @@ func (c *postgresCache) AddCheckStatus(check pkg.Check, status pkg.CheckStatus) status.Invalid, status.Message, status.Status, + status.TestSeverity, status.Time, ) if err != nil {