Skip to content
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

Allow setting remote write default parameters #188

Merged
merged 1 commit into from
Oct 31, 2023
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
5 changes: 5 additions & 0 deletions class/defaults.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ parameters:
retention: 8d
volumeClaimTemplate: ${openshift4_monitoring:configs:prometheusK8s:volumeClaimTemplate}
thanosRuler: {}

remoteWriteDefaults:
cluster: {}
userWorkload: {}

alertManagerConfig:
route:
group_wait: 0s
Expand Down
11 changes: 8 additions & 3 deletions component/main.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ then remoteWriteConfig {
}
else remoteWriteConfig;

local patchRemoteWrite(promConfig) = promConfig {
local patchRemoteWrite(promConfig, defaults) = promConfig {
_remoteWrite+:: {},
} + {
local rwd = super._remoteWrite,
Expand All @@ -59,6 +59,11 @@ local patchRemoteWrite(promConfig) = promConfig {
function(name) transformRelabelConfigs(rwd[name] { name: name }),
std.objectFields(rwd)
),
} + {
remoteWrite: std.map(
function(rw) defaults + com.makeMergeable(rw),
super.remoteWrite,
),
};

local customRules =
Expand All @@ -80,7 +85,7 @@ local customRules =
} + std.mapWithKey(
function(field, value) value + params.defaultConfig,
params.configs {
prometheusK8s: patchRemoteWrite(super.prometheusK8s),
prometheusK8s: patchRemoteWrite(super.prometheusK8s, params.remoteWriteDefaults.cluster),
}
),
),
Expand All @@ -96,7 +101,7 @@ local customRules =
std.mapWithKey(
function(field, value) value + params.defaultConfig,
params.configsUserWorkload {
prometheus: patchRemoteWrite(super.prometheus),
prometheus: patchRemoteWrite(super.prometheus, params.remoteWriteDefaults.userWorkload),
}
)
),
Expand Down
28 changes: 28 additions & 0 deletions docs/modules/ROOT/pages/references/parameters.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -711,3 +711,31 @@ default:: `{}`
A dict of secrets to create in the namespace.
The key is the name of the secret, the value is the content of the secret.
The value must be a dict with a key `stringData` which is a dict of key/value pairs to add to the secret.

== `remoteWriteDefaults`

[horizontal]
type:: dict
default::
+
[source,yaml]
----
remoteWriteDefaults:
cluster: {}
userWorkload: {}
----
example::
+
[source,yaml]
----
remoteWriteDefaults:
cluster:
queueConfig:
maxShards: 80
userWorkload:
queueConfig:
maxShards: 20
----

A dict of default remote write configurations for the Prometheus component.
Those values are merged into each remote write configuration in `configs.prometheusK8s.remoteWrite` and `configsUserWorkload.prometheus.remoteWrite`.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ data:
"node-role.kubernetes.io/infra": ""
"remoteWrite":
- "name": "backwards-compatibility"
"queueConfig":
"maxShards": 80
"minShards": 5
- "basicAuth":
"password":
"key": "password"
Expand All @@ -42,6 +45,8 @@ data:
"headers":
"X-Scope-OrgID": "example"
"name": "example"
"queueConfig":
"maxShards": 70
"url": "https://prometheus.example.com/api/v1/write"
"writeRelabelConfigs":
- "action": "keep"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ data:
"node-role.kubernetes.io/infra": ""
"remoteWrite":
- "name": "backwards-compatibility-user"
"queueConfig":
"maxShards": 20
- "basicAuth":
"password":
"key": "password"
Expand All @@ -31,6 +33,8 @@ data:
"headers":
"X-Scope-OrgID": "customer"
"name": "example"
"queueConfig":
"maxShards": 20
"url": "https://user-prometheus.example.com/api/v1/write"
"writeRelabelConfigs":
- "action": "keep"
Expand Down
12 changes: 12 additions & 0 deletions tests/remote-write.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,20 @@ parameters:
username: prometheus
password: prometheus

remoteWriteDefaults:
cluster:
queueConfig:
maxShards: 80
userWorkload:
queueConfig:
maxShards: 20

configs:
prometheusK8s:
remoteWrite:
- name: backwards-compatibility
queueConfig:
minShards: 5
_remoteWrite:
example:
url: https://prometheus.example.com/api/v1/write
Expand All @@ -52,6 +62,8 @@ parameters:
password:
name: remote-write
key: password
queueConfig:
maxShards: 70

configsUserWorkload:
prometheus:
Expand Down
Loading