Make version informations consistent between prometheus components

This also fixes #231 by adding the '-version' flag
This commit is contained in:
Steve Durrheimer 2016-04-30 19:58:17 +02:00
commit 60cbc9efc0
No known key found for this signature in database
GPG key ID: 8F443EBA70F74839
7 changed files with 122 additions and 62 deletions

View file

@ -365,6 +365,9 @@ node_disk_writes_merged{device="vda"} 2.0711856e+07
# HELP node_entropy_available_bits Bits of available entropy.
# TYPE node_entropy_available_bits gauge
node_entropy_available_bits 1337
# HELP node_exporter_build_info A metric with a constant '1' value labeled by version, revision, branch, and goversion from which node_exporter was built.
# TYPE node_exporter_build_info gauge
node_exporter_build_info{branch="master",goversion="go1.5.4",revision="252feb6",version="0.12.0rc3"} 1
# HELP node_exporter_scrape_duration_seconds node_exporter: Duration of a scrape job.
# TYPE node_exporter_scrape_duration_seconds summary
node_exporter_scrape_duration_seconds{collector="bonding",result="success",quantile="0.5"} 7.481600000000001e-05

View file

@ -1,51 +0,0 @@
// Copyright 2015 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package collector
import (
"github.com/prometheus/client_golang/prometheus"
)
var (
Version string
Revision string
Branch string
)
type versionCollector struct {
metric *prometheus.GaugeVec
}
func init() {
Factories["version"] = NewVersionCollector
}
func NewVersionCollector() (Collector, error) {
metric := prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "node_exporter_build_info",
Help: "A metric with a constant '1' value labeled by version, revision, and branch from which the node_exporter was built.",
},
[]string{"version", "revision", "branch"},
)
metric.WithLabelValues(Version, Revision, Branch).Set(1)
return &versionCollector{
metric: metric,
}, nil
}
func (c *versionCollector) Update(ch chan<- prometheus.Metric) (err error) {
c.metric.Collect(ch)
return err
}