-
-
Notifications
You must be signed in to change notification settings - Fork 259
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
Prometheus: Add format_down config param #2201
Conversation
py3status/modules/prometheus.py
Outdated
(default "{__v:.0f}") | ||
format_down: Output if prometheus is not available | ||
(default 'n/a') |
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 use this module.
Does format = "[{__v:.0f}]"
work ? It hides.
Does format = "{__v:.0f}|\?show n/a"
work ? It shows n/a
. -- It's a replacement for format_down
.
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.
format = "{__v:.0f}|\?show n/a"
works! Thanks. Is this documented somewhere?
It only works in the module code, not from user config, right?
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.
This should work in user config too. Docs: https://py3status.readthedocs.io/en/latest/user-guide/configuration/#formatter
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.
If it doesn't work, then prometheus is not updated to py3status standards.
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 module has to be updated to use safe_format() for this to work it seems
try: | ||
r = self.py3.request(self.server + "/api/v1/query", params={"query": query}) | ||
except Exception as e: | ||
self.py3.log(f"prometheus: Request failed {e}") | ||
return [] |
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.
prometheus {
on_error = "hide"
}
... might be what you want in your config... It retries every 10 seconds, I think.
Maybe something like this, now using py3.safe_format() |
r = self.py3.request(self.server + "/api/v1/query", params={"query": query}) | ||
try: | ||
r = self.py3.request(self.server + "/api/v1/query", params={"query": query}) | ||
except Exception as e: |
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.
Just like @lasers I would rather display the error on the bar than silencing it please
on_error is the way to go for users who wish to dismiss errors like you
Almost there, thanks! |
@bbusse would you like to cope with the feedbacks so we can get this in? |
Yes, absolutely! Will take care of it tomorrow |
@bbusse If you don't mind... Can I get a |
@bbusse I'm closing this until you can/want to make some time to finish this, thanks again! |
No description provided.