mirror of
https://github.com/DullJZ/s3-balance.git
synced 2026-06-28 06:21:23 +08:00
grafana display
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user