Collect at every scrape, rather than at regular intervals.
Switch to Update using the Collecter Collect interface, due to not knowing all metricnames in all modules beforehand we can't use Describe and thus the full Collecter interface. Remove 'updates', it's meaning varies by module and doesn't add much.
This commit is contained in:
parent
5c15c86f77
commit
1c17481a42
17 changed files with 193 additions and 286 deletions
|
|
@ -38,23 +38,18 @@ func NewLoadavgCollector(config Config) (Collector, error) {
|
|||
c := loadavgCollector{
|
||||
config: config,
|
||||
}
|
||||
|
||||
if _, err := prometheus.RegisterOrGet(load1); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &c, nil
|
||||
}
|
||||
|
||||
func (c *loadavgCollector) Update() (updates int, err error) {
|
||||
func (c *loadavgCollector) Update(ch chan<- prometheus.Metric) (err error) {
|
||||
load, err := getLoad1()
|
||||
if err != nil {
|
||||
return updates, fmt.Errorf("Couldn't get load: %s", err)
|
||||
return fmt.Errorf("Couldn't get load: %s", err)
|
||||
}
|
||||
updates++
|
||||
glog.V(1).Infof("Set node_load: %f", load)
|
||||
load1.Set(load)
|
||||
|
||||
return updates, err
|
||||
load1.Collect(ch)
|
||||
return err
|
||||
}
|
||||
|
||||
func getLoad1() (float64, error) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue