-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Add version string to metrics #18061
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
Comments
Sounds like a useful feature. But Prometheus does not support string metrics and adding version string as a label does not sound like a good idea. Maybe we should convert semver to an integer e.g. 1.15.9 = 1 * 100^2 + 15 * 100 + 9 = 11509 |
@Flygrounder that's a good suggestion, although I'm not sure it'd work in all cases, as there are occasions when the version wouldn't always be in a format that could be converted so cleanly, ex |
But this is only the case with dev versions, for which you probably do not want to get alerts because they are constantly updated. Perhaps in that case reporting |
I think we had better keep the original version format, and just use a new field like |
To be clear, I was talking only about converting semver to an integer in Prometheus metrics, not for the entire project. Additional benefit of having version metric in contrast to |
I think that what you use for "semi-automated" upgrades or upgrade notifications varies from environment to environment and it would be hard to provide a unified approach. This is not to say that Gitea shouldn't include an approach for that (e.g. a notification in the admin panel or an email sent to the Gitea admins saying that a new version is available). I'm not sure what would be the best approach to populating a Prometheus metric with the latest available version of Gitea. Some ideas for how to approach the problem of picking up new versions automatically: Regardless of the mechanism used for updating, I think it's still useful to expose build info, so I opened: #22819 |
FYI: That exists already. https://docs.gitea.io/en-us/config-cheat-sheet/#cron----check-for-new-gitea-versions-cronupdate_checker |
Related to: #18061 This PR adds build info to the Prometheus metrics. This includes: - goarch: https://pkg.go.dev/runtime#GOARCH - goos: https://pkg.go.dev/runtime#pkg-constants - goversion: https://pkg.go.dev/runtime#Version - gitea version: just exposes the existing code.gitea.io/gitea/modules/setting.AppVer It's a similar approach to what some other Golang projects are doing, e.g. Prometheus: https://github.com/prometheus/common/blob/main/version/info.go example /metrics response from Prometheus: ``` # HELP prometheus_build_info A metric with a constant '1' value labeled by version, revision, branch, goversion from which prometheus was built, and the goos and goarch for the build. # TYPE prometheus_build_info gauge prometheus_build_info{branch="HEAD",goarch="amd64",goos="linux",goversion="go1.19.4",revision="c0d8a56c69014279464c0e15d8bfb0e153af0dab",version="2.41.0"} 1 ``` /metrics response from gitea with this PR: ``` # HELP gitea_build_info Build information # TYPE gitea_build_info gauge gitea_build_info{goarch="amd64",goos="linux",goversion="go1.20",version="2c6cc0b8c"} 1 ``` Signed-off-by: Michal Wasilewski <[email protected]> <!-- Please check the following: 1. Make sure you are targeting the `main` branch, pull requests on release branches are only allowed for bug fixes. 2. Read contributing guidelines: https://github.com/go-gitea/gitea/blob/main/CONTRIBUTING.md 3. Describe what your pull request does and which issue you're targeting (if any) --> Signed-off-by: Michal Wasilewski <[email protected]>
resolved by #22819 |
Feature Description
Hi,
I'm monitoring my Gitea instance via Prometheus and Grafana.
It would be great to have a string for the current Gitea version and the new one in the metrics to set an Grafana alert for possible new version on it.
Screenshots
No response
The text was updated successfully, but these errors were encountered: