-
Notifications
You must be signed in to change notification settings - Fork 691
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
add namespace to unseal error metric #463
add namespace to unseal error metric #463
Conversation
@@ -64,11 +64,6 @@ func init() { | |||
prometheus.MustRegister(unsealRequestsTotal) | |||
prometheus.MustRegister(unsealErrorsTotal) | |||
prometheus.MustRegister(conditionInfo) | |||
|
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.
Why did you have to remove this?
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.
becaue we can't populate it any more, as the label combination is status abd namespace, and you can't init labels with just reason field, you need both.
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.
I don't know why it had to be initialized in the first place.
@kskewes I see you added that in #375; is it really necessary these counters are set to 0?
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.
The backstory is here: https://www.robustperception.io/existential-issues-with-metrics
How it relates:
Sealed Secrets Controller behaviour in an error case as I understand it.
- Startup
- Attempt unseal but there's error. Increase the associated counter metric (with label).
- Retry unseal attempt 5 times and then give up.
Prometheus behaviour:
- Startup
- Detect Sealed Secrets Controller pod (service discovery)
- Scrape
/metrics
endpoint on retry interval (10s or 60s or as configured)
These scrapes can happen at any point after the controller has started up.
Situation:
- Prometheus client libraries initialise counters with no labels to 0 by default.
- Prometheus client libraries don't initialise counters with labels by default as it doesn't know what labels will be set.
So we do this manually. - Above enables easy alerting rules as you can check for an increase in the counter. An increase from null/non-existing metric to X value is not easily alert-able on. There's an
absent()
function in Prometheus but there are a lot of edge cases we have tried to handle in our other applications with varying degrees of success.
Options (in no specific order):
- Add the namespace label per this PR as is - this is likely to result in missed alerts as a error metric for a namespace is likely to go from
NaN
to5
within the scrape period interval due to fast retry loop and Prometheus won't catch it. The second increase (or unseal error) will alert via the existing alert. - Add the namespace label per this PR and have a go at rewriting the alert with namespace label and trying to catch
absent()
metrics withoffset
etc per the above link. - Add the namespace label and have the controller register the metrics per error reason per namespace. Controller would need to watch Namespaces via Kubernetes API and initialise metric for new namespaces as added. I think cardinality wise this if fine.
- Do nothing (We'd like the label, but little bit to do per above).
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.
Other options:
-
List+watch for namespaces via k8s api and initialize metrics based in existing namespaces.
-
Advise users on how to craft alerts correctly in case of missing values (using
or
and other trickeries as Brian hinted at in the linked doc)
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.
sounds reasonable; thanks
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.
Cool. The retry interval must have changed since I last tested. :)
With 10s scrape interval provided we have retries over at least 2 it might be ok.
It would be good to update the alert unit test in tests.yaml and the alert itself in jsonnet.
Would you like to do in separate PR? Or I can once we pull next release and can validate.
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.
Thanks Karl, I don't have bandwidth to take care of this, it would be really great if I could delegate that to you
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.
Sure. Happy to pickup after current tasks. :)
Can validate retry versus scrape intervals in the unit test.
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 we initialize at least "fetch" (which doesn't have a namespace) so the counter exists. See #543
thank you for taking a look and let me know if you have any problems with it, I might be able to help ;) |
Add part of the initialization from bitnami-labs#463 See bitnami-labs#543
I've been running sealed secrets and I love it thanks!
One caveat is that it's impossible to direct
SealedSecretsUnsealErrorRateHigh
alert to specific teams. So it ends up that one team, gets all of the failures.I think to solve it we can add the namespace to the metric so that alerts can be directed to teams that own approperiate namespaces.
One typical example is when a secret already exists and then you add a new sealed secret and it doesn't override the existing secret. In this case I would like to alert the appropriate namespace owner ;)