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

Multiple relabel configs with action: keep results in all metrics being dropped #3996

Closed
roganartu opened this issue Mar 21, 2018 · 4 comments

Comments

@roganartu
Copy link
Contributor

roganartu commented Mar 21, 2018

Problem

The following set of relabel rules results in all metrics being dropped:

metric_relabel_configs:
      - source_labels: ['__name__']
        regex: foo_total
        action: keep
      - source_labels: ['__name__']
        regex: bar_total
        action: keep

According to the documentation, this behaviour is entirely expected and technically correct, but I don't think it's very user-friendly.

The relabel function only looks at a single config at a time, so the first rule drops everything that matches the second, and the second drops everything that matches the first: https://github.com/prometheus/prometheus/blob/master/relabel/relabel.go#L40

Workaround

metric_relabel_configs:
      - source_labels: ['__name__']
        regex: '(foo_total|bar_total)'
        action: keep

However this obviously quickly becomes cumbersome with any kind of complexity in regex and/or source labels, eg: for a (likely to grow and change over time) whitelist of metric-label combinations in remote_write.

Proposal

Make action: keep behaviour more consistent with it being the conceptual inverse of action: drop by keeping all metrics that match any action: keep config, not just those that match both. I think that action: keep configs OR'd together are likely more useful than the existing AND behaviour, but I have no data to back that up.

This breaks existing behaviour in two obvious ways, and perhaps more subtle ways:

  1. The existing AND-style behaviour (eg: chaining progressively less restrictive action: keep configs together instead of a single long one will no longer work)
  2. A fix likely requires processing all the action: keep configs together either before or after other relabel rules are applied. This will break configs that rely on order to work correctly (eg: using an initial action: keep followed by other configs that assume metrics to have been dropped).
@brian-brazil
Copy link
Contributor

Do you have a proposal?

@roganartu
Copy link
Contributor Author

edited to add proposal

@brian-brazil
Copy link
Contributor

That's a breaking change, which we can't do and would cause confusion. It's also a complete change in semantics for how actions work, as they're currently independent. If you want multiple keeps ORed together, you can already combine them into one action (and it's probably more efficient too).

@lock
Copy link

lock bot commented Mar 22, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked and limited conversation to collaborators Mar 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants