-
Notifications
You must be signed in to change notification settings - Fork 802
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
pkg/ruler: Add external_labels option #4499
pkg/ruler: Add external_labels option #4499
Conversation
Could someone review this PR and maybe approve the workflow to let the jobs run? Maybe @jtlisi, as it looks like you've contributed most of the notifier code. The goal here is to be able to specify external labels in Loki, so that all of the alerts it sends are tagged with a given set of labels, mimicking the behavior of Prometheus. This is very useful when running several instances of Loki in different regions or clusters, making the alerts they emit easily identifiable. |
ef85b1b
to
7363178
Compare
@bboreham I'm sorry to ping people at random, but I'd like at least to get the workflow approved to get the CI running, and if possible some feedback on the proposed changes. I'm happy to rework it if needed; being able to set external labels in Loki is really important for our use-case. |
This issue has been automatically marked as stale because it has not had any activity in the past 60 days. It will be closed in 15 days if no further activity occurs. Thank you for your contributions. |
I'm still hoping to get someone to take a look at this PR, as this feature is sorely needed. |
This seems a valid use case. It would be nice to configure it per rule as well, no? |
Hi @alanprot! I'm not sure I get what you mean, labels can already be set on individual rules. The goal of Anyway, the PR is now at grafana/loki#5450, if you want to continue the discussion there. |
(Actually, you may want to merge this here too; let me know if that's the case, I'll make the necessary adjustments.) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I missed this; it seems a nice PR, simple and well-constructed.
One question on the description.
CHANGELOG.md
Outdated
@@ -23,6 +23,7 @@ | |||
* [FEATURE] AlertManager: Add support for SNS Receiver. #4382 | |||
* [FEATURE] Distributor: Add label `status` to metric `cortex_distributor_ingester_append_failures_total` #4442 | |||
* [FEATURE] Queries: Added `present_over_time` PromQL function, also some TSDB optimisations. #4505 | |||
* [FEATURE] Ruler: Add `external_labels` option to tag all alerts with a given set of labels. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it only alerts, or recording rules too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I can tell, this only applies to alerts. It gets passed to the notifier configuration specifically, and I don't see any mention of external labels in vendor/github.com/prometheus/prometheus/rules/recording.go.
The Prometheus documentation also makes it clear that they apply when communicating with external systems:
The labels to add to any time series or alerts when communicating with external systems (federation, remote storage, Alertmanager).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you move the changelog to ## master / unreleased
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
7363178
to
be6065e
Compare
So the documentation generation is failing, but it's a bit tricky to resolve. The first issue is that
because external_labels:
name: value
foo: bar I can try and get around this by defining
which isn't perfect either. The way I defined it manually (which is how it's defined in the Prometheus documentation is
Finally, the other issue I had to get around is the fact that Any advice on how to handle both of these issues? |
Humm.. Seems that the best way would be following the other maps?
|
be6065e
to
3861db3
Compare
@alanprot Yeah, that makes a lot of sense. :) I also found the |
This option can be used to add a set of labels to all alerts emitted by the ruler. Signed-off-by: Benoît Knecht <bknecht@protonmail.ch>
Let the documentation generator understand the `labels.Labels` field, and generate `config-file-reference.md` with ```console $ go run tools/doc-generator \ > docs/configuration/config-file-reference.template > docs/configuration/config-file-reference.md ``` Signed-off-by: Benoît Knecht <bknecht@protonmail.ch>
3861db3
to
0bc1ebd
Compare
Thanks |
What this PR does:
Add an
external_labels
option for the ruler, to tag all alerts emitted by the ruler with a given set of labels.Checklist
CHANGELOG.md
updated