Description
openedon Apr 5, 2024
Request
The prometheus.operator.*
components allow for relabeling rules, but they cannot be passed in via reference.
Currently they are defined as
prometheus.operator.servicemonitors "services" {
forward_to = [prometheus.remote_write.staging.receiver]
rule {
action = "keep"
regex = env("HOSTNAME")
source_labels = ["__meta_kubernetes_pod_node_name"]
}
}
However, take the example from loki.source.journal
, the relabel rules are provided outside of the component and referenced as an argument.
loki.relabel "journal" {
forward_to = []
rule {
source_labels = ["__journal__systemd_unit"]
target_label = "unit"
}
}
loki.source.journal "read" {
forward_to = [loki.write.endpoint.receiver]
relabel_rules = loki.relabel.journal.rules
labels = {component = "loki.source.journal"}
}
Use case
By allowing a reference, the same rules can be used for all components and passed as arguments to modules / custom components.
prometheus.relabel "keep_backend_only" {
forward_to = []
rule {
action = "replace"
source_labels = ["__address__", "instance"]
separator = "/"
target_label = "host"
}
rule {
action = "keep"
source_labels = ["app"]
regex = "backend"
}
rule {
action = "labeldrop"
regex = "instance"
}
}
prometheus.operator.podmonitors "pods" {
forward_to = [prometheus.remote_write.staging.receiver]
relabel_rules = prometheus.relabel.keep_backend_only.rules
}
prometheus.operator.servicemonitors "services" {
forward_to = [prometheus.remote_write.staging.receiver]
relabel_rules = prometheus.relabel.keep_backend_only.rules
}
prometheus.operator.probes "probes" {
forward_to = [prometheus.remote_write.staging.receiver]
relabel_rules = prometheus.relabel.keep_backend_only.rules
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Metadata
Assignees
Type
Projects
Status
Incoming