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

Provide Relabel Rules argument to prometheus.operators.* components #192

Open
bentonam opened this issue Apr 5, 2024 · 1 comment · May be fixed by grafana/agent#6830
Open

Provide Relabel Rules argument to prometheus.operators.* components #192

bentonam opened this issue Apr 5, 2024 · 1 comment · May be fixed by grafana/agent#6830
Labels
enhancement New feature or request needs-attention proposal A proposal for new functionality.

Comments

@bentonam
Copy link
Contributor

bentonam commented 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
}
@bentonam bentonam added the enhancement New feature or request label Apr 5, 2024
@rfratto rfratto transferred this issue from grafana/agent Apr 11, 2024
Copy link
Contributor

This issue has not had any activity in the past 30 days, so the needs-attention label has been added to it.
If the opened issue is a bug, check to see if a newer release fixed your issue. If it is no longer relevant, please feel free to close this issue.
The needs-attention label signals to maintainers that something has fallen through the cracks. No action is needed by you; your issue will be kept open and you do not have to respond to this comment. The label will be removed the next time this job runs if there is new activity.
Thank you for your contributions!

@rfratto rfratto added the proposal A proposal for new functionality. label Jun 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request needs-attention proposal A proposal for new functionality.
Projects
Status: Incoming
Development

Successfully merging a pull request may close this issue.

2 participants