Skip to content

Commit f69f2d1

Browse files
adityathebemoshloop
authored andcommitted
fix(prometheus): support TLS
1 parent 5663121 commit f69f2d1

11 files changed

Lines changed: 36 additions & 47 deletions

File tree

api/v1/checks.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -791,9 +791,11 @@ type PrometheusCheck struct {
791791
Description `yaml:",inline" json:",inline"`
792792
Templatable `yaml:",inline" json:",inline"`
793793
Relatable `yaml:",inline" json:",inline"`
794+
795+
connection.PrometheusConnection `yaml:",inline" json:",inline"`
796+
794797
// Deprecated: use `url` instead
795-
Host string `yaml:"host,omitempty" json:"host,omitempty"`
796-
connection.HTTPConnection `yaml:",inline" json:",inline"`
798+
Host string `yaml:"host,omitempty" json:"host,omitempty"`
797799
// PromQL query
798800
Query string `yaml:"query" json:"query" template:"true"`
799801
}

api/v1/zz_generated.deepcopy.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

checks/prometheus.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func (c *PrometheusChecker) Check(ctx *context.Context, extConfig external.Check
3737
return results.Failf("host field is deprecated, use url field instead")
3838
}
3939

40-
if _, err := check.HTTPConnection.Hydrate(ctx, ctx.GetNamespace()); err != nil {
40+
if _, err := check.PrometheusConnection.Hydrate(ctx, ctx.GetNamespace()); err != nil {
4141
return results.Failf("error hydrating connection: %v", err)
4242
}
4343

@@ -46,11 +46,11 @@ func (c *PrometheusChecker) Check(ctx *context.Context, extConfig external.Check
4646
check.URL = prometheus.PrometheusURL
4747
}
4848

49-
if check.HTTPConnection.URL == "" {
49+
if check.PrometheusConnection.URL == "" {
5050
return results.Failf("Must specify a URL")
5151
}
5252

53-
promClient, err := prometheus.NewPrometheusAPI(ctx.Context, check.HTTPConnection)
53+
promClient, err := prometheus.NewPrometheusAPI(ctx.Context, check.PrometheusConnection)
5454
if err != nil {
5555
return results.ErrorMessage(err)
5656
}

cmd/root.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ var Root = &cobra.Command{
7474
logger.Infof("Setting default prometheus: %s", prometheus.PrometheusURL)
7575
runner.Prometheus, _ = prometheus.NewPrometheusAPI(
7676
context.New(),
77-
connection.HTTPConnection{URL: prometheus.PrometheusURL},
77+
connection.PrometheusConnection{HTTPConnection: connection.HTTPConnection{URL: prometheus.PrometheusURL}},
7878
)
7979
}
8080

config/schemas/canary.schema.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4544,10 +4544,6 @@
45444544
"$ref": "#/$defs/CheckRelationship",
45454545
"description": "Relationships defines a way to link the check results to components and configs\nusing lookup expressions."
45464546
},
4547-
"host": {
4548-
"type": "string",
4549-
"description": "Deprecated: use `url` instead"
4550-
},
45514547
"connection": {
45524548
"type": "string"
45534549
},
@@ -4587,6 +4583,10 @@
45874583
"awsSigV4": {
45884584
"$ref": "#/$defs/AWSSigV4"
45894585
},
4586+
"host": {
4587+
"type": "string",
4588+
"description": "Deprecated: use `url` instead"
4589+
},
45904590
"query": {
45914591
"type": "string",
45924592
"description": "PromQL query"

config/schemas/component.schema.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4910,10 +4910,6 @@
49104910
"$ref": "#/$defs/CheckRelationship",
49114911
"description": "Relationships defines a way to link the check results to components and configs\nusing lookup expressions."
49124912
},
4913-
"host": {
4914-
"type": "string",
4915-
"description": "Deprecated: use `url` instead"
4916-
},
49174913
"connection": {
49184914
"type": "string"
49194915
},
@@ -4953,6 +4949,10 @@
49534949
"awsSigV4": {
49544950
"$ref": "#/$defs/AWSSigV4"
49554951
},
4952+
"host": {
4953+
"type": "string",
4954+
"description": "Deprecated: use `url` instead"
4955+
},
49564956
"query": {
49574957
"type": "string",
49584958
"description": "PromQL query"

config/schemas/health_prometheus.schema.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -265,10 +265,6 @@
265265
"$ref": "#/$defs/CheckRelationship",
266266
"description": "Relationships defines a way to link the check results to components and configs\nusing lookup expressions."
267267
},
268-
"host": {
269-
"type": "string",
270-
"description": "Deprecated: use `url` instead"
271-
},
272268
"connection": {
273269
"type": "string"
274270
},
@@ -308,6 +304,10 @@
308304
"awsSigV4": {
309305
"$ref": "#/$defs/AWSSigV4"
310306
},
307+
"host": {
308+
"type": "string",
309+
"description": "Deprecated: use `url` instead"
310+
},
311311
"query": {
312312
"type": "string",
313313
"description": "PromQL query"

config/schemas/topology.schema.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4921,10 +4921,6 @@
49214921
"$ref": "#/$defs/CheckRelationship",
49224922
"description": "Relationships defines a way to link the check results to components and configs\nusing lookup expressions."
49234923
},
4924-
"host": {
4925-
"type": "string",
4926-
"description": "Deprecated: use `url` instead"
4927-
},
49284924
"connection": {
49294925
"type": "string"
49304926
},
@@ -4964,6 +4960,10 @@
49644960
"awsSigV4": {
49654961
"$ref": "#/$defs/AWSSigV4"
49664962
},
4963+
"host": {
4964+
"type": "string",
4965+
"description": "Deprecated: use `url` instead"
4966+
},
49674967
"query": {
49684968
"type": "string",
49694969
"description": "PromQL query"

go.mod

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -405,9 +405,6 @@ require (
405405
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
406406
github.com/xdg-go/scram v1.1.2 // indirect
407407
github.com/xdg-go/stringprep v1.0.4 // indirect
408-
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect
409-
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
410-
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
411408
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect
412409
github.com/xlab/treeprint v1.2.0 // indirect
413410
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect

go.sum

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1913,12 +1913,6 @@ github.com/xdg-go/scram v1.1.2 h1:FHX5I5B4i4hKRVRBCFRxq1iQRej7WO3hhBuJf+UUySY=
19131913
github.com/xdg-go/scram v1.1.2/go.mod h1:RT/sEzTbU5y00aCK8UOx6R7YryM0iF1N2MOmC3kKLN4=
19141914
github.com/xdg-go/stringprep v1.0.4 h1:XLI/Ng3O1Atzq0oBs3TWm+5ZVgkq2aqdlvP9JtoZ6c8=
19151915
github.com/xdg-go/stringprep v1.0.4/go.mod h1:mPGuuIYwz7CmR2bT9j4GbQqutWS1zV24gijq1dTyGkM=
1916-
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f h1:J9EGpcZtP0E/raorCMxlFGSTBrsSlaDGf3jU/qvAE2c=
1917-
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
1918-
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHovont7NscjpAxXsDA8S8BMYve8Y5+7cuRE7R0=
1919-
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ=
1920-
github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74=
1921-
github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y=
19221916
github.com/xhit/go-str2duration v1.2.0/go.mod h1:3cPSlfZlUHVlneIVfePFWcJZsuwf+P1v2SRTV4cUmp4=
19231917
github.com/xhit/go-str2duration/v2 v2.1.0/go.mod h1:ohY8p+0f07DiV6Em5LKB0s2YpLtXVyJfNt1+BlmyAsU=
19241918
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 h1:nIPpBwaJSVYIxUFsDv3M8ofmx9yWTog9BfvIu0q41lo=

0 commit comments

Comments
 (0)