Skip to content

MON-2206: Adds sigv4 settings for remote write #1638

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@

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

## 4.10

Expand Down
2 changes: 2 additions & 0 deletions pkg/manifests/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ type RemoteWriteSpec struct {
BearerTokenFile string `json:"bearerTokenFile,omitempty"`
// Authorization section for remote write
Authorization *monv1.SafeAuthorization `json:"authorization,omitempty"`
// Sigv4 allows to configures AWS's Signature Verification 4
Sigv4 *monv1.Sigv4 `json:"sigv4,omitempty"`
// TLS Config to use for remote write.
TLSConfig *monv1.SafeTLSConfig `json:"tlsConfig,omitempty"`
// Optional ProxyURL
Expand Down
1 change: 1 addition & 0 deletions pkg/manifests/manifests.go
Original file line number Diff line number Diff line change
Expand Up @@ -4226,6 +4226,7 @@ func addRemoteWriteConfigs(clusterID string, rw []monv1.RemoteWriteSpec, rwTarge
WriteRelabelConfigs: writeRelabelConfigs,
BasicAuth: target.BasicAuth,
BearerTokenFile: target.BearerTokenFile,
Sigv4: target.Sigv4,
ProxyURL: target.ProxyURL,
MetadataConfig: target.MetadataConfig,
OAuth2: target.OAuth2,
Expand Down
42 changes: 42 additions & 0 deletions pkg/manifests/manifests_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1344,6 +1344,48 @@ func TestRemoteWriteAuthorizationConfig(t *testing.T) {
},
},
},
{
name: "sigv4 authentication configuration",
config: `prometheusK8s:
remoteWrite:
- url: "https://authorization.remotewrite.com/api/write"
sigv4:
region: eu
accessKey:
name: aws-credentials
key: access
secretKey:
name: aws-credentials
key: secret
profile: "SomeProfile"
roleArn: "SomeRoleArn"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI
RoleArn has minimum filed size of 20, otherwise, would see error in prometheus-k8s pod logs

ts=2022-04-14T11:45:44.525Z caller=dedupe.go:112 component=remote level=warn remote_name=a42715 url=https://authorization.remotewrite.com/api/write msg="Failed to send batch, retrying" err="Post \"https://authorization.remotewrite.com/api/write\": failed to sign request: InvalidParameter: 1 validation error(s) found.\n- minimum field size of 20, AssumeRoleInput.RoleArn.\n"

`,
checkFn: []func(*testing.T, monv1.RemoteWriteSpec){
func(t *testing.T, target monv1.RemoteWriteSpec) {
if target.Sigv4.Region != "eu" {
t.Fatalf("Region field not correct in section RemoteWriteSpec.Sigv4 expected 'eu', got %s", target.Sigv4)
}
if target.Sigv4.AccessKey.Name != "aws-credentials" {
t.Fatalf("Name field not correct in section RemoteWriteSpec.Sigv4.AccessKey expected 'aws-credentials', got %s", target.Sigv4.AccessKey.Name)
}
if target.Sigv4.AccessKey.Key != "access" {
t.Fatalf("Key field not correct in section RemoteWriteSpec.Sigv4.AccessKey expected 'access', got %s", target.Sigv4.AccessKey.Key)
}
if target.Sigv4.SecretKey.Name != "aws-credentials" {
t.Fatalf("Name field not correct in section RemoteWriteSpec.Sigv4.SecretKey expected 'aws-credentials', got %s", target.Sigv4.SecretKey.Name)
}
if target.Sigv4.SecretKey.Key != "secret" {
t.Fatalf("Key field not correct in section RemoteWriteSpec.Sigv4.SecretKey expected 'secret', got %s", target.Sigv4.SecretKey.Key)
}
if target.Sigv4.Profile != "SomeProfile" {
t.Fatalf("Profile field not correct in section RemoteWriteSpec.Sigv4 expected 'SomeProfile', got %s", target.Sigv4.Profile)
}
if target.Sigv4.RoleArn != "SomeRoleArn" {
t.Fatalf("RoleArn field not correct in section RemoteWriteSpec.Sigv4 expected 'SomeRoleArn', got %s", target.Sigv4.RoleArn)
}
},
},
},
} {
t.Run(tc.name, func(t *testing.T) {
c, err := NewConfigFromString(tc.config)
Expand Down