Merge pull request #816 from ZhuZhengyi/exporter

Fix: fix exporter vol usage ratio error
This commit is contained in:
awzhgw 2020-08-06 14:54:05 +08:00 committed by GitHub
commit 5b4901f00d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 47 additions and 48 deletions

View File

@ -15,7 +15,8 @@
"editable": true,
"gnetId": null,
"graphTooltip": 0,
"iteration": 1594609997387,
"id": 1,
"iteration": 1596694182271,
"links": [],
"panels": [
{
@ -104,7 +105,7 @@
"valueMaps": [
{
"op": "=",
"text": "N/A",
"text": "0",
"value": "null"
}
],
@ -182,7 +183,7 @@
"valueMaps": [
{
"op": "=",
"text": "N/A",
"text": "0",
"value": "null"
}
],
@ -259,7 +260,7 @@
"valueMaps": [
{
"op": "=",
"text": "N/A",
"text": "0",
"value": "null"
}
],
@ -336,7 +337,7 @@
"valueMaps": [
{
"op": "=",
"text": "N/A",
"text": "0",
"value": "null"
}
],
@ -413,7 +414,7 @@
"valueMaps": [
{
"op": "=",
"text": "N/A",
"text": "0",
"value": "null"
}
],
@ -491,7 +492,7 @@
"valueMaps": [
{
"op": "=",
"text": "N/A",
"text": "0",
"value": "null"
}
],
@ -608,7 +609,7 @@
"value": 300000
}
],
"unit": "decgbytes"
"unit": "gbytes"
},
"override": {},
"values": false
@ -679,7 +680,7 @@
"value": 5
}
],
"unit": "decgbytes"
"unit": "gbytes"
},
"override": {},
"values": false
@ -758,7 +759,7 @@
"value": 100
}
],
"unit": "decbytes"
"unit": "bytes"
},
"override": {},
"values": true
@ -1130,7 +1131,7 @@
"pluginVersion": "6.4.4",
"targets": [
{
"expr": "topk($topk, cfs_master_vol_used_GB{app=\"$app\",cluster=\"$cluster\", instance=\"$master_instance\"}/cfs_master_vol_total_GB{app=\"$app\",cluster=\"$cluster\", instance=\"$master_instance\"})",
"expr": "topk($topk, cfs_master_vol_usage_ratio{app=\"$app\",cluster=\"$cluster\",instance=\"$master_instance\"})",
"format": "time_series",
"instant": true,
"intervalFactor": 1,
@ -1176,7 +1177,7 @@
"current": false,
"max": false,
"min": false,
"show": true,
"show": false,
"total": false,
"values": false
},
@ -1216,7 +1217,7 @@
"title": "VolumeUsedSize",
"tooltip": {
"shared": true,
"sort": 0,
"sort": 2,
"value_type": "individual"
},
"type": "graph",
@ -1265,7 +1266,7 @@
"current": false,
"max": false,
"min": false,
"show": true,
"show": false,
"total": false,
"values": false
},
@ -1291,7 +1292,7 @@
"steppedLine": false,
"targets": [
{
"expr": "topk($topk, cfs_master_vol_used_GB{app=\"$app\",cluster=\"$cluster\", instance=\"$master_instance\"}/cfs_master_vol_total_GB{app=\"$app\",cluster=\"$cluster\", instance=\"$master_instance\"})",
"expr": "topk($topk, cfs_master_vol_usage_ratio{app=\"$app\",cluster=\"$cluster\",instance=\"$master_instance\"})",
"format": "time_series",
"intervalFactor": 1,
"legendFormat": "{{volName}}",
@ -1354,7 +1355,7 @@
"current": false,
"max": false,
"min": false,
"show": true,
"show": false,
"total": false,
"values": false
},
@ -1474,7 +1475,7 @@
"refId": "C"
},
{
"expr": "cfs_master_vol_used_GB{app=\"$app\",cluster=\"$cluster\", volName=\"$vol\", instance=\"$master_instance\"}/cfs_master_vol_total_GB{app=\"$app\",cluster=\"$cluster\", volName=\"$vol\", instance=\"$master_instance\"}",
"expr": "cfs_master_vol_usage_ratio{app=\"$app\",cluster=\"$cluster\", volName=\"$vol\", instance=\"$master_instance\"}",
"format": "time_series",
"intervalFactor": 1,
"legendFormat": "UsedRatio",
@ -4994,7 +4995,7 @@
"name": "vol",
"options": [],
"query": "label_values(cfs_master_vol_total_GB{app=\"$app\",cluster=\"$cluster\"}, volName)",
"refresh": 1,
"refresh": 2,
"regex": "",
"skipUrlSync": false,
"sort": 0,
@ -5007,8 +5008,8 @@
{
"allValue": null,
"current": {
"text": "192.168.0.11:17010",
"value": "192.168.0.11:17010"
"text": "192.168.0.13:17010",
"value": "192.168.0.13:17010"
},
"datasource": "Prometheus",
"definition": "label_values(up{app=\"$app\", role=\"$role\", cluster=\"$cluster\"}, instance)",
@ -5032,8 +5033,8 @@
{
"allValue": null,
"current": {
"text": "192.168.0.11",
"value": "192.168.0.11"
"text": "192.168.0.13",
"value": "192.168.0.13"
},
"datasource": "Prometheus",
"definition": "label_values(go_info{instance=\"$instance\", cluster=\"$cluster\"}, instance)",
@ -5057,8 +5058,8 @@
{
"allValue": null,
"current": {
"text": "192.168.0.11:17010",
"value": "192.168.0.11:17010"
"text": "192.168.0.13:17010",
"value": "192.168.0.13:17010"
},
"datasource": "Prometheus",
"definition": "label_values(up{app=\"$app\", role=\"master\", cluster=\"$cluster\"}, instance)",

View File

@ -61,7 +61,6 @@ type monitorMetrics struct {
metaNodesInactive *exporter.Gauge
volTotalGauge *exporter.Gauge
volUsedGauge *exporter.Gauge
volUsageRatioGauge *exporter.Gauge
}
func newMonitorMetrics(c *Cluster) *monitorMetrics {
@ -86,7 +85,6 @@ func (mm *monitorMetrics) start() {
mm.metaNodesInactive = exporter.NewGauge(MetricMetaNodesInactive)
mm.volTotalGauge = exporter.NewGauge(MetricVolTotalGB)
mm.volUsedGauge = exporter.NewGauge(MetricVolUsedGB)
mm.volUsageRatioGauge = exporter.NewGauge(MetricVolUsageGB)
go mm.statMetrics()
}
@ -114,17 +112,17 @@ func (mm *monitorMetrics) statMetrics() {
func (mm *monitorMetrics) doStat() {
dataNodeCount := mm.cluster.dataNodeCount()
mm.dataNodesCount.Set(int64(dataNodeCount))
mm.dataNodesCount.Set(float64(dataNodeCount))
metaNodeCount := mm.cluster.metaNodeCount()
mm.metaNodesCount.Set(int64(metaNodeCount))
mm.metaNodesCount.Set(float64(metaNodeCount))
volCount := len(mm.cluster.vols)
mm.volCount.Set(int64(volCount))
mm.dataNodesTotal.Set(int64(mm.cluster.dataNodeStatInfo.TotalGB))
mm.dataNodesUsed.Set(int64(mm.cluster.dataNodeStatInfo.UsedGB))
mm.dataNodeIncreased.Set(int64(mm.cluster.dataNodeStatInfo.IncreasedGB))
mm.metaNodesTotal.Set(int64(mm.cluster.metaNodeStatInfo.TotalGB))
mm.metaNodesUsed.Set(int64(mm.cluster.metaNodeStatInfo.UsedGB))
mm.metaNodesIncreased.Set(int64(mm.cluster.metaNodeStatInfo.IncreasedGB))
mm.volCount.Set(float64(volCount))
mm.dataNodesTotal.Set(float64(mm.cluster.dataNodeStatInfo.TotalGB))
mm.dataNodesUsed.Set(float64(mm.cluster.dataNodeStatInfo.UsedGB))
mm.dataNodeIncreased.Set(float64(mm.cluster.dataNodeStatInfo.IncreasedGB))
mm.metaNodesTotal.Set(float64(mm.cluster.metaNodeStatInfo.TotalGB))
mm.metaNodesUsed.Set(float64(mm.cluster.metaNodeStatInfo.UsedGB))
mm.metaNodesIncreased.Set(float64(mm.cluster.metaNodeStatInfo.IncreasedGB))
mm.setVolMetrics()
mm.setDiskErrorMetric()
mm.setInactiveDataNodesCount()
@ -142,11 +140,11 @@ func (mm *monitorMetrics) setVolMetrics() {
return true
}
labels := map[string]string{"volName": volName}
mm.volTotalGauge.SetWithLabels(int64(volStatInfo.TotalSize), labels)
mm.volUsedGauge.SetWithLabels(int64(volStatInfo.UsedSize), labels)
mm.volTotalGauge.SetWithLabels(float64(volStatInfo.TotalSize), labels)
mm.volUsedGauge.SetWithLabels(float64(volStatInfo.UsedSize), labels)
usedRatio, e := strconv.ParseFloat(volStatInfo.UsedRatio, 64)
if e == nil {
mm.volUsageRatioGauge.SetWithLabels(int64(usedRatio), labels)
mm.volUsage.SetWithLabels(usedRatio, labels)
}
return true
@ -186,7 +184,7 @@ func (mm *monitorMetrics) setInactiveMetaNodesCount() {
}
return true
})
mm.metaNodesInactive.Set(inactiveMetaNodesCount)
mm.metaNodesInactive.Set(float64(inactiveMetaNodesCount))
}
func (mm *monitorMetrics) setInactiveDataNodesCount() {
@ -201,7 +199,7 @@ func (mm *monitorMetrics) setInactiveDataNodesCount() {
}
return true
})
mm.dataNodesInactive.Set(inactiveDataNodesCount)
mm.dataNodesInactive.Set(float64(inactiveDataNodesCount))
}
func (mm *monitorMetrics) resetAllMetrics() {

View File

@ -55,7 +55,7 @@ func (c *Counter) Add(val int64) {
if !enabledPrometheus {
return
}
c.val = val
c.val = float64(val)
c.publish()
}

View File

@ -79,7 +79,7 @@ func Init(role string, cfg *config.Config) {
collect()
m := NewGauge("start_time")
m.Set(time.Now().Unix() * 1000)
m.Set(float64(time.Now().Unix() * 1000))
log.LogInfof("exporter Start: %v", addr)
}
@ -104,7 +104,7 @@ func InitWithRouter(role string, cfg *config.Config, router *mux.Router, exPort
collect()
m := NewGauge("start_time")
m.Set(time.Now().Unix() * 1000)
m.Set(float64(time.Now().Unix() * 1000))
log.LogInfof("exporter Start: %v %v", exporterPort, m)
}

View File

@ -36,7 +36,7 @@ func collectGauge() {
for {
m := <-GaugeCh
metric := m.Metric()
metric.Set(float64(m.val))
metric.Set(m.val)
log.LogDebugf("collect metric %v", m)
}
}
@ -44,7 +44,7 @@ func collectGauge() {
type Gauge struct {
name string
labels map[string]string
val int64
val float64
ch chan interface{}
}
@ -89,7 +89,7 @@ func (c *Gauge) Metric() prometheus.Gauge {
return actualMetric.(prometheus.Gauge)
}
func (g *Gauge) Set(val int64) {
func (g *Gauge) Set(val float64) {
if !enabledPrometheus {
return
}
@ -104,7 +104,7 @@ func (c *Gauge) publish() {
}
}
func (g *Gauge) SetWithLabels(val int64, labels map[string]string) {
func (g *Gauge) SetWithLabels(val float64, labels map[string]string) {
if !enabledPrometheus {
return
}

View File

@ -65,7 +65,7 @@ func (tp *TimePoint) Set() {
return
}
val := time.Since(tp.startTime).Nanoseconds()
tp.val = val
tp.val = float64(val)
tp.publish()
}