grafana display

This commit is contained in:
DullJZ
2025-10-21 19:59:28 +08:00
parent b2dc311f01
commit 0630cb09c7
3 changed files with 76 additions and 2 deletions

View File

@@ -99,6 +99,67 @@
"title": "QPS (操作/秒)",
"type": "timeseries"
},
{
"datasource": "Prometheus",
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"custom": {
"align": "auto",
"displayMode": "auto"
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
}
]
}
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 12,
"x": 12,
"y": 0
},
"id": 12,
"options": {
"footer": {
"fields": "",
"reducer": [
"sum"
],
"show": false
},
"showHeader": true
},
"targets": [
{
"expr": "sum by (bucket, category)(increase(s3_balance_backend_operations_total[$__range]))",
"instant": true,
"legendFormat": "",
"refId": "A"
}
],
"timeFrom": "now/M",
"title": "后端操作次数 (本自然月)",
"transformations": [
{
"id": "labelsToFields",
"options": {
"valueLabel": "操作次数"
}
}
],
"type": "table"
},
{
"datasource": "Prometheus",
"fieldConfig": {
@@ -334,5 +395,5 @@
"timezone": "",
"title": "S3 Balance 监控面板",
"uid": "s3-balance-monitoring",
"version": 1
"version": 2
}

View File

@@ -11,6 +11,10 @@ func (h *S3Handler) recordBackendOperation(b *bucket.BucketInfo, category bucket
if b == nil {
return
}
if h.metrics != nil {
h.metrics.RecordBackendOperation(b.Config.Name, string(category))
}
if disabled := b.RecordOperation(category); disabled {
log.Printf("Bucket %s disabled after exceeding %s-type operation limit", b.Config.Name, category)
}

View File

@@ -36,6 +36,11 @@ var (
Name: "s3_balance_balancer_decisions_total",
Help: "Total number of load balancing decisions",
}, []string{"strategy", "bucket"})
backendOperationsTotal = promauto.NewCounterVec(prometheus.CounterOpts{
Name: "s3_balance_backend_operations_total",
Help: "Total number of backend bucket operations by category",
}, []string{"bucket", "category"})
)
type Metrics struct{}
@@ -67,4 +72,8 @@ func (m *Metrics) RecordS3OperationDuration(operation, bucket string, duration f
func (m *Metrics) RecordBalancerDecision(strategy, bucket string) {
balancerDecisions.WithLabelValues(strategy, bucket).Inc()
}
}
func (m *Metrics) RecordBackendOperation(bucket, category string) {
backendOperationsTotal.WithLabelValues(bucket, category).Inc()
}