diff --git a/other/metrics/grafana_seaweedfs.json b/other/metrics/grafana_seaweedfs.json index 8288fea93..10fd43b1e 100644 --- a/other/metrics/grafana_seaweedfs.json +++ b/other/metrics/grafana_seaweedfs.json @@ -4266,6 +4266,102 @@ } ], "pluginVersion": "10.3.1" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "title": "Volume Creation Rate", + "description": "Rate of volume creation operations by result", + "type": "timeseries", + "id": 216, + "gridPos": { + "h": 8, + "w": 12, + "x": 0, + "y": 118 + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 10, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 4, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "unit": "ops", + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + } + }, + "overrides": [] + }, + "options": { + "legend": { + "calcs": [ + "lastNotNull", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "editorMode": "code", + "expr": "rate(SeaweedFS_master_volume_creation_total{cluster=~\"$cluster\"}[5m])", + "range": true, + "refId": "A", + "legendFormat": "{{result}}" + } + ], + "pluginVersion": "10.3.1" } ] }, diff --git a/weed/stats/metrics.go b/weed/stats/metrics.go index e4a8cf1be..a4a5beeaa 100644 --- a/weed/stats/metrics.go +++ b/weed/stats/metrics.go @@ -128,6 +128,16 @@ var ( Help: "Current number of volumes that do not have enough replicas per collection/layout. 0 = healthy.", }, []string{"collection", "disk", "rp", "ttl"}) + // MasterVolumeCreationCounter counts volume creation (growth) operations by result (success, failure). + // Volume growth is orchestrated by the master, so this metric is exported by the master process. + MasterVolumeCreationCounter = prometheus.NewCounterVec( + prometheus.CounterOpts{ + Namespace: Namespace, + Subsystem: "master", + Name: "volume_creation_total", + Help: "Counter of volume creation operations by result (success, failure).", + }, []string{"result"}) + MasterPickForWriteErrorCounter = prometheus.NewCounter( prometheus.CounterOpts{ Namespace: Namespace, @@ -863,6 +873,7 @@ func init() { Gather.MustRegister(VolumeServerReplicationTargets) Gather.MustRegister(VolumeServerReplicationFailures) Gather.MustRegister(MasterUnderReplicatedVolumes) + Gather.MustRegister(MasterVolumeCreationCounter) Gather.MustRegister(S3RequestCounter) Gather.MustRegister(S3HandlerCounter) diff --git a/weed/topology/volume_growth.go b/weed/topology/volume_growth.go index 92382c3d6..2ccf85a68 100644 --- a/weed/topology/volume_growth.go +++ b/weed/topology/volume_growth.go @@ -13,6 +13,7 @@ import ( "google.golang.org/grpc" "github.com/seaweedfs/seaweedfs/weed/glog" + "github.com/seaweedfs/seaweedfs/weed/stats" "github.com/seaweedfs/seaweedfs/weed/storage" "github.com/seaweedfs/seaweedfs/weed/storage/needle" "github.com/seaweedfs/seaweedfs/weed/storage/super_block" @@ -136,8 +137,10 @@ func (vg *VolumeGrowth) GrowByCountAndType(grpcDialOption grpc.DialOption, targe for i := uint32(0); i < targetCount; i++ { if res, e := vg.findAndGrow(grpcDialOption, topo, option); e == nil { result = append(result, res...) + stats.MasterVolumeCreationCounter.WithLabelValues("success").Inc() } else { glog.V(0).Infof("create %d volume, created %d: %v", targetCount, len(result), e) + stats.MasterVolumeCreationCounter.WithLabelValues("failure").Inc() return result, e } }