mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-04 09:49:50 +00:00
Expose version as prometheus metric
This commit is contained in:
parent
28585bc699
commit
9e6b3e4a9d
@ -16,6 +16,8 @@ limitations under the License.
|
|||||||
|
|
||||||
package version
|
package version
|
||||||
|
|
||||||
|
import "github.com/prometheus/client_golang/prometheus"
|
||||||
|
|
||||||
// Info contains versioning information.
|
// Info contains versioning information.
|
||||||
// TODO: Add []string of api versions supported? It's still unclear
|
// TODO: Add []string of api versions supported? It's still unclear
|
||||||
// how we'll want to distribute that information.
|
// how we'll want to distribute that information.
|
||||||
@ -45,3 +47,17 @@ func Get() Info {
|
|||||||
func (info Info) String() string {
|
func (info Info) String() string {
|
||||||
return info.GitVersion
|
return info.GitVersion
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
buildInfo := prometheus.NewGaugeVec(
|
||||||
|
prometheus.GaugeOpts{
|
||||||
|
Name: "kubernetes_build_info",
|
||||||
|
Help: "A metric with a constant '1' value labeled by major, minor, git version, git commit and git tree state from which Kubernetes was built.",
|
||||||
|
},
|
||||||
|
[]string{"major", "minor", "gitVersion", "gitCommit", "gitTreeState"},
|
||||||
|
)
|
||||||
|
info := Get()
|
||||||
|
buildInfo.WithLabelValues(info.Major, info.Minor, info.GitVersion, info.GitCommit, info.GitTreeState).Set(1)
|
||||||
|
|
||||||
|
prometheus.MustRegister(buildInfo)
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user