Skip to content

Commit 9587e29

Browse files
Adds sigv4 settings for remote write
Issue https://issues.redhat.com/browse/MON-2206 Problem: Prometheus and Prometheus operator already support sigv4 authentication for remote write. This should be possible to configure the same in the CMO configuration Solution: Add to the RemoteWriteSpec struct the Sigv4 field so users can specify Sigv4 configuration in the CMO ConfigMap, pass this field to the Prometheus CRD
1 parent 2c494f4 commit 9587e29

File tree

4 files changed

+47
-1
lines changed

4 files changed

+47
-1
lines changed

CHANGELOG.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44

55
- [#1567](https://github.com/openshift/cluster-monitoring-operator/pull/1567) Enable validating webhook for AlertmanagerConfig custom resources
66
- [#1557](https://github.com/openshift/cluster-monitoring-operator/pull/1557) Removing grafana from monitoring stack
7-
- [1578](https://github.com/openshift/cluster-monitoring-operator/pull/1578) Add temporary cluster id label to remote write relabel configs.
7+
- [#1578](https://github.com/openshift/cluster-monitoring-operator/pull/1578) Add temporary cluster id label to remote write relabel configs.
88
- [#1350](https://github.com/openshift/cluster-monitoring-operator/pull/1350) Support label scrape limits in user-workload monitoring
99
- [#1601](https://github.com/openshift/cluster-monitoring-operator/pull/1601) Expose the /federate endpoint of UWM Prometheus as a service
1010
- [#1617](https://github.com/openshift/cluster-monitoring-operator/pull/1617) Add Oauth2 setting to PrometheusK8s remoteWrite config
1111
- [#1598](https://github.com/openshift/cluster-monitoring-operator/pull/1598) Expose Authorization settings for remote write in the CMO configuration
12+
- [#1638](https://github.com/openshift/cluster-monitoring-operator/pull/1638) Expose sigv4 setting to Prometheus remoteWrite
1213

1314
## 4.10
1415

pkg/manifests/config.go

+2
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@ type RemoteWriteSpec struct {
158158
BearerTokenFile string `json:"bearerTokenFile,omitempty"`
159159
// Authorization section for remote write
160160
Authorization *monv1.SafeAuthorization `json:"authorization,omitempty"`
161+
// Sigv4 allows to configures AWS's Signature Verification 4
162+
Sigv4 *monv1.Sigv4 `json:"sigv4,omitempty"`
161163
// TLS Config to use for remote write.
162164
TLSConfig *monv1.SafeTLSConfig `json:"tlsConfig,omitempty"`
163165
// Optional ProxyURL

pkg/manifests/manifests.go

+1
Original file line numberDiff line numberDiff line change
@@ -4226,6 +4226,7 @@ func addRemoteWriteConfigs(clusterID string, rw []monv1.RemoteWriteSpec, rwTarge
42264226
WriteRelabelConfigs: writeRelabelConfigs,
42274227
BasicAuth: target.BasicAuth,
42284228
BearerTokenFile: target.BearerTokenFile,
4229+
Sigv4: target.Sigv4,
42294230
ProxyURL: target.ProxyURL,
42304231
MetadataConfig: target.MetadataConfig,
42314232
OAuth2: target.OAuth2,

pkg/manifests/manifests_test.go

+42
Original file line numberDiff line numberDiff line change
@@ -1344,6 +1344,48 @@ func TestRemoteWriteAuthorizationConfig(t *testing.T) {
13441344
},
13451345
},
13461346
},
1347+
{
1348+
name: "sigv4 authentication configuration",
1349+
config: `prometheusK8s:
1350+
remoteWrite:
1351+
- url: "https://authorization.remotewrite.com/api/write"
1352+
sigv4:
1353+
region: eu
1354+
accessKey:
1355+
name: aws-credentials
1356+
key: access
1357+
secretKey:
1358+
name: aws-credentials
1359+
key: secret
1360+
profile: "SomeProfile"
1361+
roleArn: "SomeRoleArn"
1362+
`,
1363+
checkFn: []func(*testing.T, monv1.RemoteWriteSpec){
1364+
func(t *testing.T, target monv1.RemoteWriteSpec) {
1365+
if target.Sigv4.Region != "eu" {
1366+
t.Fatalf("Region field not correct in section RemoteWriteSpec.Sigv4 expected 'eu', got %s", target.Sigv4)
1367+
}
1368+
if target.Sigv4.AccessKey.Name != "aws-credentials" {
1369+
t.Fatalf("Name field not correct in section RemoteWriteSpec.Sigv4.AccessKey expected 'aws-credentials', got %s", target.Sigv4.AccessKey.Name)
1370+
}
1371+
if target.Sigv4.AccessKey.Key != "access" {
1372+
t.Fatalf("Key field not correct in section RemoteWriteSpec.Sigv4.AccessKey expected 'access', got %s", target.Sigv4.AccessKey.Key)
1373+
}
1374+
if target.Sigv4.SecretKey.Name != "aws-credentials" {
1375+
t.Fatalf("Name field not correct in section RemoteWriteSpec.Sigv4.SecretKey expected 'aws-credentials', got %s", target.Sigv4.SecretKey.Name)
1376+
}
1377+
if target.Sigv4.SecretKey.Key != "secret" {
1378+
t.Fatalf("Key field not correct in section RemoteWriteSpec.Sigv4.SecretKey expected 'secret', got %s", target.Sigv4.SecretKey.Key)
1379+
}
1380+
if target.Sigv4.Profile != "SomeProfile" {
1381+
t.Fatalf("Profile field not correct in section RemoteWriteSpec.Sigv4 expected 'SomeProfile', got %s", target.Sigv4.Profile)
1382+
}
1383+
if target.Sigv4.RoleArn != "SomeRoleArn" {
1384+
t.Fatalf("RoleArn field not correct in section RemoteWriteSpec.Sigv4 expected 'SomeRoleArn', got %s", target.Sigv4.RoleArn)
1385+
}
1386+
},
1387+
},
1388+
},
13471389
} {
13481390
t.Run(tc.name, func(t *testing.T) {
13491391
c, err := NewConfigFromString(tc.config)

0 commit comments

Comments
 (0)