Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upDetect/forbid (verbatim) duplicated lines in the rules files #912
Comments
This comment has been minimized.
This comment has been minimized.
|
I'd say the current behaviour is correct. |
This comment has been minimized.
This comment has been minimized.
|
Found more duplicate rule files at SC... happens quite often, and goes completely undetected so far. @brian-brazil What's the use case for the current behavior? |
This comment has been minimized.
This comment has been minimized.
|
As you said in the OP, when you have different label values for each. |
This comment has been minimized.
This comment has been minimized.
|
Let me rephrase: What would be a use case for creating two rules with the same name that have different label values? |
This comment has been minimized.
This comment has been minimized.
|
If different teams had per-job rules, those applying to the Standard Exports would be in this situation. |
This comment has been minimized.
This comment has been minimized.
|
I guess that's a valid point... we have one server per team at SC, so basically one team manages all the rules on one server. But we could detect if a rule is completely identical to another one. Would that make sense? |
This comment has been minimized.
This comment has been minimized.
|
We could, but it'd break the abstraction that each rule runs every eval interval. It'll also cause oddities when we have ordered rule evaluation. |
This comment has been minimized.
This comment has been minimized.
|
I mean, we could simply reject to load the rules file if we have an exact duplicate. |
This comment has been minimized.
This comment has been minimized.
|
I'm not sure there's much value to that - should we also bail out if there's two rules that are effectively equal too? |
This comment has been minimized.
This comment has been minimized.
|
It might be difficult to detect “effectively equal” rules. But on at least three servers at SC, I found rule pairs that funneled into the same time series. One of them was basically a typo, i.e. two different expressions put their results into the same time series (bad). The other two were exact duplicates (copy&paste problem). The related time series had therefore duplicated samples, and with 0.15.0, those samples got rejected, and a counter got incremented on which you probably want to alert. So catching exactly duplicated rules will help to prevent a mistake that will later page you... |
This comment has been minimized.
This comment has been minimized.
|
I did use this feature (no quotes) to feed different queries / metrics into one uber-metric with different labels (@beorn7 this is on a branch r/n, I can show you). I think we should keep allowing them, and we can't tell beforehand that the labelsets will be different. I would vote to make a note of this in the documentation but allow people shooting themselves in the foot. |
This comment has been minimized.
This comment has been minimized.
|
… and if people get paged for this then that's exactly the right point in time to take note of it, because it's the only point when we can be sure it is a problem. |
This comment has been minimized.
This comment has been minimized.
|
Agreed, this sounds more like an example of bad external rule / config management than one with Prometheus per se. Would also vote to keep the current behavior. |
This comment has been minimized.
This comment has been minimized.
|
Still, if i have two or more literally (in the literal sense of "literally") identical rules, there is no way that can be meaningful. So should we at least error in that case? |
This comment has been minimized.
This comment has been minimized.
|
I'd be ok with erroring in that case. I'd say the usefulness is limited (slight decrease in computing resources, but the storage will just reject the second copy of identical samples anyways now), but it couldn't hurt. |
beorn7
changed the title
Detect/forbid duplicate rule names?
Detect/forbid (verbatim) duplicated lines in the rules files
Jul 22, 2015
This comment has been minimized.
This comment has been minimized.
|
I have adjusted the subject. |
This comment has been minimized.
This comment has been minimized.
|
|
brian-brazil
added
the
feature-request
label
Dec 16, 2015
fabxc
added
kind/enhancement
and removed
feature request
labels
Apr 28, 2016
tamsky
referenced this issue
Aug 24, 2016
Closed
add per __rulefile_name__ metrics for prometheus_evaluator_duration_seconds #1
This comment has been minimized.
This comment has been minimized.
|
This is probably something for a warning in promtool, once we add a general rule linter |
brian-brazil
added
component/promtool
priority/P3
labels
Jul 14, 2017
This comment has been minimized.
This comment has been minimized.
|
How does this play with rule-groups? Duplicated rule in rule-group would be an error as all rules in the rule-group are evaluated with the same timestamp. Also, duplicated rule across groups can also cause out-of-order appends. |
This comment has been minimized.
This comment has been minimized.
Not necessarily, each rule could be one iteration of a state machine and you can construct those to avoid duplicate timestamps. |
This comment has been minimized.
This comment has been minimized.
|
But how would avoid the entire rule-group being evaluated at the same timestamp? The same rule in different groups might make sense, but the same rule in the same group will be either a nop or an error right? |
This comment has been minimized.
This comment has been minimized.
|
You're thinking of normal simple rules, self-referential rules could have different effects when repeated. |
This comment has been minimized.
This comment has been minimized.
totallyunknown
commented
Mar 6, 2018
|
Can we add a duplicate rule name detection into promtool? |
beorn7 commentedJul 21, 2015
Accidentally, I found a case where the same rule name was used twice. That went without complaints by the server, and if both rule evaluations had resulted in different label sets, it might have just worked. However, they resulted in the same label set, so the results were funneled into the same time series, and now with our fancy monotonicity detector, we actually see warnings.
Question: Should we in general forbid to use the same rule name twice? Or are their use cases where you want to use the same rule name (but create different label values for the result)?
I tend to simply ban duplicate rule names, but perhaps I'm missing something.
@juliusv @brian-brazil