mirror of
https://github.com/prometheus/node_exporter.git
synced 2025-01-14 15:34:00 -08:00
bcache: add priorityStats flag (#1621)
* bcache: add priorityStats flag Fixes #1593 Signed-off-by: Aleksei Zakharov <zaharov@selectel.ru>
This commit is contained in:
parent
503e4fc848
commit
3b035c8fa1
|
@ -21,6 +21,11 @@ import (
|
||||||
"github.com/go-kit/kit/log"
|
"github.com/go-kit/kit/log"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
"github.com/prometheus/procfs/bcache"
|
"github.com/prometheus/procfs/bcache"
|
||||||
|
"gopkg.in/alecthomas/kingpin.v2"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
priorityStats = kingpin.Flag("collector.bcache.priorityStats", "Expose expensive priority stats.").Bool()
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
@ -50,7 +55,13 @@ func NewBcacheCollector(logger log.Logger) (Collector, error) {
|
||||||
// Update reads and exposes bcache stats.
|
// Update reads and exposes bcache stats.
|
||||||
// It implements the Collector interface.
|
// It implements the Collector interface.
|
||||||
func (c *bcacheCollector) Update(ch chan<- prometheus.Metric) error {
|
func (c *bcacheCollector) Update(ch chan<- prometheus.Metric) error {
|
||||||
stats, err := c.fs.Stats()
|
var stats []*bcache.Stats
|
||||||
|
var err error
|
||||||
|
if *priorityStats {
|
||||||
|
stats, err = c.fs.Stats()
|
||||||
|
} else {
|
||||||
|
stats, err = c.fs.StatsWithoutPriority()
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to retrieve bcache stats: %w", err)
|
return fmt.Errorf("failed to retrieve bcache stats: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -259,7 +270,10 @@ func (c *bcacheCollector) updateBcacheStats(ch chan<- prometheus.Metric, s *bcac
|
||||||
extraLabel: []string{"cache_device"},
|
extraLabel: []string{"cache_device"},
|
||||||
extraLabelValue: cache.Name,
|
extraLabelValue: cache.Name,
|
||||||
},
|
},
|
||||||
|
}
|
||||||
|
if *priorityStats {
|
||||||
// metrics in /sys/fs/bcache/<uuid>/<cache>/priority_stats
|
// metrics in /sys/fs/bcache/<uuid>/<cache>/priority_stats
|
||||||
|
priorityStatsMetrics := []bcacheMetric{
|
||||||
{
|
{
|
||||||
name: "priority_stats_unused_percent",
|
name: "priority_stats_unused_percent",
|
||||||
desc: "The percentage of the cache that doesn't contain any data.",
|
desc: "The percentage of the cache that doesn't contain any data.",
|
||||||
|
@ -277,6 +291,8 @@ func (c *bcacheCollector) updateBcacheStats(ch chan<- prometheus.Metric, s *bcac
|
||||||
extraLabelValue: cache.Name,
|
extraLabelValue: cache.Name,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
metrics = append(metrics, priorityStatsMetrics...)
|
||||||
|
}
|
||||||
allMetrics = append(allMetrics, metrics...)
|
allMetrics = append(allMetrics, metrics...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -106,6 +106,7 @@ fi
|
||||||
--collector.wifi.fixtures="collector/fixtures/wifi" \
|
--collector.wifi.fixtures="collector/fixtures/wifi" \
|
||||||
--collector.qdisc.fixtures="collector/fixtures/qdisc/" \
|
--collector.qdisc.fixtures="collector/fixtures/qdisc/" \
|
||||||
--collector.netclass.ignored-devices="(bond0|dmz|int)" \
|
--collector.netclass.ignored-devices="(bond0|dmz|int)" \
|
||||||
|
--collector.bcache.priorityStats \
|
||||||
--collector.cpu.info \
|
--collector.cpu.info \
|
||||||
--collector.cpu.info.flags-include="^(aes|avx.?|constant_tsc)$" \
|
--collector.cpu.info.flags-include="^(aes|avx.?|constant_tsc)$" \
|
||||||
--collector.cpu.info.bugs-include="^(cpu_meltdown|spectre_.*|mds)$" \
|
--collector.cpu.info.bugs-include="^(cpu_meltdown|spectre_.*|mds)$" \
|
||||||
|
|
Loading…
Reference in a new issue