health/pgs: track misplaced objects from their pgs
This commit is contained in:
parent
bd2206ffbb
commit
498d7ff177
|
@ -69,6 +69,12 @@ type ClusterHealthCollector struct {
|
||||||
// DegradedObjectsCount gives the no. of RADOS objects are constitute the degraded PGs.
|
// DegradedObjectsCount gives the no. of RADOS objects are constitute the degraded PGs.
|
||||||
DegradedObjectsCount prometheus.Gauge
|
DegradedObjectsCount prometheus.Gauge
|
||||||
|
|
||||||
|
// MisplacedObjectsCount gives the no. of RADOS objects that constitute the misplaced PGs.
|
||||||
|
// Misplaced PGs usually represent the PGs that are not in the storage locations that
|
||||||
|
// they should be in. This is different than degraded PGs which means a PG has fewer copies
|
||||||
|
// that it should.
|
||||||
|
MisplacedObjectsCount prometheus.Gauge
|
||||||
|
|
||||||
// OSDsDown show the no. of OSDs that are in the DOWN state.
|
// OSDsDown show the no. of OSDs that are in the DOWN state.
|
||||||
OSDsDown prometheus.Gauge
|
OSDsDown prometheus.Gauge
|
||||||
|
|
||||||
|
@ -174,6 +180,13 @@ func NewClusterHealthCollector(conn Conn) *ClusterHealthCollector {
|
||||||
Help: "No. of degraded objects across all PGs",
|
Help: "No. of degraded objects across all PGs",
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
MisplacedObjectsCount: prometheus.NewGauge(
|
||||||
|
prometheus.GaugeOpts{
|
||||||
|
Namespace: cephNamespace,
|
||||||
|
Name: "misplaced_objects",
|
||||||
|
Help: "No. of misplaced objects across all PGs",
|
||||||
|
},
|
||||||
|
),
|
||||||
OSDsDown: prometheus.NewGauge(
|
OSDsDown: prometheus.NewGauge(
|
||||||
prometheus.GaugeOpts{
|
prometheus.GaugeOpts{
|
||||||
Namespace: cephNamespace,
|
Namespace: cephNamespace,
|
||||||
|
@ -224,6 +237,7 @@ func (c *ClusterHealthCollector) metricsList() []prometheus.Metric {
|
||||||
c.StalePGs,
|
c.StalePGs,
|
||||||
c.StuckStalePGs,
|
c.StuckStalePGs,
|
||||||
c.DegradedObjectsCount,
|
c.DegradedObjectsCount,
|
||||||
|
c.MisplacedObjectsCount,
|
||||||
c.OSDsDown,
|
c.OSDsDown,
|
||||||
c.OSDsUp,
|
c.OSDsUp,
|
||||||
c.OSDsIn,
|
c.OSDsIn,
|
||||||
|
@ -280,16 +294,17 @@ func (c *ClusterHealthCollector) collect() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
degradedRegex = regexp.MustCompile(`([\d]+) pgs degraded`)
|
degradedRegex = regexp.MustCompile(`([\d]+) pgs degraded`)
|
||||||
stuckDegradedRegex = regexp.MustCompile(`([\d]+) pgs stuck degraded`)
|
stuckDegradedRegex = regexp.MustCompile(`([\d]+) pgs stuck degraded`)
|
||||||
uncleanRegex = regexp.MustCompile(`([\d]+) pgs unclean`)
|
uncleanRegex = regexp.MustCompile(`([\d]+) pgs unclean`)
|
||||||
stuckUncleanRegex = regexp.MustCompile(`([\d]+) pgs stuck unclean`)
|
stuckUncleanRegex = regexp.MustCompile(`([\d]+) pgs stuck unclean`)
|
||||||
undersizedRegex = regexp.MustCompile(`([\d]+) pgs undersized`)
|
undersizedRegex = regexp.MustCompile(`([\d]+) pgs undersized`)
|
||||||
stuckUndersizedRegex = regexp.MustCompile(`([\d]+) pgs stuck undersized`)
|
stuckUndersizedRegex = regexp.MustCompile(`([\d]+) pgs stuck undersized`)
|
||||||
staleRegex = regexp.MustCompile(`([\d]+) pgs stale`)
|
staleRegex = regexp.MustCompile(`([\d]+) pgs stale`)
|
||||||
stuckStaleRegex = regexp.MustCompile(`([\d]+) pgs stuck stale`)
|
stuckStaleRegex = regexp.MustCompile(`([\d]+) pgs stuck stale`)
|
||||||
degradedObjectsRegex = regexp.MustCompile(`recovery ([\d]+)/([\d]+) objects degraded`)
|
degradedObjectsRegex = regexp.MustCompile(`recovery ([\d]+)/([\d]+) objects degraded`)
|
||||||
osdsDownRegex = regexp.MustCompile(`([\d]+)/([\d]+) in osds are down`)
|
misplacedObjectsRegex = regexp.MustCompile(`recovery ([\d]+)/([\d]+) objects misplaced`)
|
||||||
|
osdsDownRegex = regexp.MustCompile(`([\d]+)/([\d]+) in osds are down`)
|
||||||
)
|
)
|
||||||
|
|
||||||
for _, s := range stats.Health.Summary {
|
for _, s := range stats.Health.Summary {
|
||||||
|
@ -374,6 +389,15 @@ func (c *ClusterHealthCollector) collect() error {
|
||||||
c.DegradedObjectsCount.Set(float64(v))
|
c.DegradedObjectsCount.Set(float64(v))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
matched = misplacedObjectsRegex.FindStringSubmatch(s.Summary)
|
||||||
|
if len(matched) == 3 {
|
||||||
|
v, err := strconv.Atoi(matched[1])
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
c.MisplacedObjectsCount.Set(float64(v))
|
||||||
|
}
|
||||||
|
|
||||||
matched = osdsDownRegex.FindStringSubmatch(s.Summary)
|
matched = osdsDownRegex.FindStringSubmatch(s.Summary)
|
||||||
if len(matched) == 3 {
|
if len(matched) == 3 {
|
||||||
v, err := strconv.Atoi(matched[1])
|
v, err := strconv.Atoi(matched[1])
|
||||||
|
|
|
@ -184,6 +184,23 @@ func TestClusterHealthCollector(t *testing.T) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
input: `
|
input: `
|
||||||
|
{
|
||||||
|
"osdmap": {
|
||||||
|
"osdmap": {
|
||||||
|
"num_osds": 0,
|
||||||
|
"num_up_osds": 0,
|
||||||
|
"num_in_osds": 0,
|
||||||
|
"num_remapped_pgs": 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"health": {"summary": [{"severity": "HEALTH_WARN", "summary": "recovery 20/40 objects misplaced"}]}
|
||||||
|
}`,
|
||||||
|
regexes: []*regexp.Regexp{
|
||||||
|
regexp.MustCompile(`misplaced_objects 20`),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
input: `
|
||||||
{
|
{
|
||||||
"osdmap": {
|
"osdmap": {
|
||||||
"osdmap": {
|
"osdmap": {
|
||||||
|
|
Loading…
Reference in New Issue