metrics: Include number of slow requests

Ported from https://github.com/digitalocean/ceph_exporter/pull/66
This commit is contained in:
Jared Watts committed 2017-08-23 08:56:14 -07:00
1 parent 6924613081
commit 3edadd13b9
3 files changed
+39 -1

No files matched your search

+21
View File
@@ -78,6 +78,9 @@ type ClusterHealthCollector struct {
// in that state.
StuckStalePGs prometheus.Gauge
// SlowRequests depicts no. of total slow requests in the cluster
SlowRequests prometheus.Gauge
// DegradedObjectsCount gives the no. of RADOS objects are constitute the degraded PGs.
// This includes object replicas in its count.
DegradedObjectsCount prometheus.Gauge
@@ -217,6 +220,13 @@ func NewClusterHealthCollector(context *clusterd.Context, clusterName string) *C
Help: "No. of stuck stale PGs in the cluster",
},
),
SlowRequests: prometheus.NewGauge(
prometheus.GaugeOpts{
Namespace: cephNamespace,
Name: "slow_requests",
Help: "No. of slow requests",
},
),
DegradedObjectsCount: prometheus.NewGauge(
prometheus.GaugeOpts{
Namespace: cephNamespace,
@@ -358,6 +368,7 @@ func (c *ClusterHealthCollector) metricsList() []prometheus.Metric {
c.StuckUndersizedPGs,
c.StalePGs,
c.StuckStalePGs,
c.SlowRequests,
c.DegradedObjectsCount,
c.MisplacedObjectsCount,
c.OSDsDown,
@@ -407,6 +418,7 @@ func (c *ClusterHealthCollector) collect(stats cephclient.CephStatus) error {
stuckUndersizedRegex = regexp.MustCompile(`([\d]+) pgs stuck undersized`)
staleRegex = regexp.MustCompile(`([\d]+) pgs stale`)
stuckStaleRegex = regexp.MustCompile(`([\d]+) pgs stuck stale`)
slowRequestRegex = regexp.MustCompile(`([\d]+) slow requests are blocked`)
degradedObjectsRegex = regexp.MustCompile(`recovery ([\d]+)/([\d]+) objects degraded`)
misplacedObjectsRegex = regexp.MustCompile(`recovery ([\d]+)/([\d]+) objects misplaced`)
)
@@ -484,6 +496,15 @@ func (c *ClusterHealthCollector) collect(stats cephclient.CephStatus) error {
c.StuckStalePGs.Set(float64(v))
}
matched = slowRequestRegex.FindStringSubmatch(m.Summary.Message)
if len(matched) == 2 {
v, err := strconv.Atoi(matched[1])
if err != nil {
return err
}
c.SlowRequests.Set(float64(v))
}
matched = degradedObjectsRegex.FindStringSubmatch(m.Summary.Message)
if len(matched) == 3 {
v, err := strconv.Atoi(matched[1])
+18
View File
@@ -360,6 +360,24 @@ func TestClusterHealthCollector(t *testing.T) {
regexp.MustCompile(`total_pgs 52000`),
},
},
{
input: `
{
"health": {
"checks": {
"REQUEST_SLOW": {
"severity": "HEALTH_WARN",
"summary": {
"message": "6 slow requests are blocked > 32 sec"
}
}
}
}
}`,
regexes: []*regexp.Regexp{
regexp.MustCompile(`slow_requests 6`),
},
},
} {
func() {
executor := &exectest.MockExecutor{
-1
View File
@@ -289,7 +289,6 @@ func (o *OSDCollector) collect() error {
depth, err := node.Depth.Float64()
if err != nil {
return err
}