Skip to content
This repository was archived by the owner on Dec 20, 2024. It is now read-only.

Commit 6304674

Browse files
authored
Merge pull request #1461 from antsystem/update-supernode-metrics
update supernode metrics
2 parents 9abd133 + ca55039 commit 6304674

File tree

4 files changed

+134
-11
lines changed

4 files changed

+134
-11
lines changed

docs/user_guide/dragonfly.json

Lines changed: 125 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,13 @@
6565
"rgba(237, 129, 40, 0.89)",
6666
"#56A64B"
6767
],
68+
"datasource": "${DS_PROMETHEUS}",
69+
"fieldConfig": {
70+
"defaults": {
71+
"custom": {}
72+
},
73+
"overrides": []
74+
},
6875
"format": "none",
6976
"gauge": {
7077
"maxValue": 100,
@@ -96,7 +103,6 @@
96103
"maxDataPoints": 100,
97104
"nullPointMode": "connected",
98105
"nullText": null,
99-
"options": {},
100106
"pluginVersion": "6.3.2",
101107
"postfix": "",
102108
"postfixFontSize": "50%",
@@ -121,6 +127,8 @@
121127
"targets": [
122128
{
123129
"expr": "up{instance=\"$supernode\"}",
130+
"interval": "",
131+
"legendFormat": "",
124132
"refId": "A"
125133
}
126134
],
@@ -154,7 +162,14 @@
154162
"rgba(237, 129, 40, 0.89)",
155163
"#d44a3a"
156164
],
157-
"description": "Total file size downloaded by dfget from supernode.",
165+
"datasource": "${DS_PROMETHEUS}",
166+
"description": "Total file size downloaded by supernode from source.",
167+
"fieldConfig": {
168+
"defaults": {
169+
"custom": {}
170+
},
171+
"overrides": []
172+
},
158173
"format": "decbytes",
159174
"gauge": {
160175
"maxValue": 100,
@@ -186,7 +201,6 @@
186201
"maxDataPoints": 100,
187202
"nullPointMode": "connected",
188203
"nullText": null,
189-
"options": {},
190204
"postfix": "",
191205
"postfixFontSize": "50%",
192206
"prefix": "",
@@ -209,7 +223,101 @@
209223
"tableColumn": "",
210224
"targets": [
211225
{
212-
"expr": "dragonfly_supernode_pieces_downloaded_size_bytes_total",
226+
"expr": "dragonfly_supernode_cdn_download_size_bytes_total{instance=\"$supernode\"}",
227+
"interval": "",
228+
"legendFormat": "",
229+
"refId": "A"
230+
}
231+
],
232+
"thresholds": "",
233+
"timeFrom": null,
234+
"timeShift": null,
235+
"title": "Supernode Back Source Size",
236+
"type": "singlestat",
237+
"valueFontSize": "80%",
238+
"valueMaps": [
239+
{
240+
"op": "=",
241+
"text": "N/A",
242+
"value": "null"
243+
}
244+
],
245+
"valueName": "current"
246+
},
247+
{
248+
"cacheTimeout": null,
249+
"colorBackground": false,
250+
"colorPrefix": false,
251+
"colorValue": false,
252+
"colors": [
253+
"#299c46",
254+
"rgba(237, 129, 40, 0.89)",
255+
"#d44a3a"
256+
],
257+
"datasource": "${DS_PROMETHEUS}",
258+
"description": "Total file size downloaded by dfget from supernode.",
259+
"fieldConfig": {
260+
"defaults": {
261+
"custom": {}
262+
},
263+
"overrides": []
264+
},
265+
"format": "decbytes",
266+
"gauge": {
267+
"maxValue": 100,
268+
"minValue": 0,
269+
"show": false,
270+
"thresholdLabels": false,
271+
"thresholdMarkers": true
272+
},
273+
"gridPos": {
274+
"h": 6,
275+
"w": 6,
276+
"x": 12,
277+
"y": 0
278+
},
279+
"id": 39,
280+
"interval": null,
281+
"links": [],
282+
"mappingType": 1,
283+
"mappingTypes": [
284+
{
285+
"name": "value to text",
286+
"value": 1
287+
},
288+
{
289+
"name": "range to text",
290+
"value": 2
291+
}
292+
],
293+
"maxDataPoints": 100,
294+
"nullPointMode": "connected",
295+
"nullText": null,
296+
"postfix": "",
297+
"postfixFontSize": "50%",
298+
"prefix": "",
299+
"prefixFontSize": "50%",
300+
"rangeMaps": [
301+
{
302+
"from": "null",
303+
"text": "N/A",
304+
"to": "null"
305+
}
306+
],
307+
"sparkline": {
308+
"fillColor": "rgba(31, 118, 189, 0.18)",
309+
"full": false,
310+
"lineColor": "rgb(31, 120, 193)",
311+
"show": true,
312+
"ymax": null,
313+
"ymin": null
314+
},
315+
"tableColumn": "",
316+
"targets": [
317+
{
318+
"expr": "dragonfly_supernode_pieces_downloaded_size_bytes_total{instance=\"$supernode\"}",
319+
"interval": "",
320+
"legendFormat": "",
213321
"refId": "A"
214322
}
215323
],
@@ -233,22 +341,31 @@
233341
"bars": false,
234342
"dashLength": 10,
235343
"dashes": false,
344+
"datasource": "${DS_PROMETHEUS}",
236345
"description": "Current peers in supernode.",
346+
"fieldConfig": {
347+
"defaults": {
348+
"custom": {}
349+
},
350+
"overrides": []
351+
},
237352
"fill": 1,
238353
"fillGradient": 0,
239354
"gridPos": {
240-
"h": 6,
241-
"w": 12,
242-
"x": 12,
243-
"y": 0
355+
"h": 8,
356+
"w": 24,
357+
"x": 0,
358+
"y": 6
244359
},
360+
"hiddenSeries": false,
245361
"id": 4,
246362
"legend": {
247363
"alignAsTable": true,
248364
"avg": true,
249365
"current": true,
250366
"max": true,
251367
"min": false,
368+
"rightSide": true,
252369
"show": true,
253370
"total": false,
254371
"values": true

supernode/daemon/mgr/cdn/manager.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ var _ mgr.CDNMgr = &Manager{}
5252
type metrics struct {
5353
cdnCacheHitCount *prometheus.CounterVec
5454
cdnDownloadCount *prometheus.CounterVec
55+
cdnDownloadBytes *prometheus.CounterVec
5556
cdnDownloadFailCount *prometheus.CounterVec
5657
}
5758

@@ -63,6 +64,10 @@ func newMetrics(register prometheus.Registerer) *metrics {
6364
cdnDownloadCount: metricsutils.NewCounter(config.SubsystemSupernode, "cdn_download_total",
6465
"Total times of cdn download", []string{}, register),
6566

67+
cdnDownloadBytes: metricsutils.NewCounter(config.SubsystemSupernode, "cdn_download_size_bytes_total",
68+
"total file size of cdn downloaded from source in bytes", []string{}, register,
69+
),
70+
6671
cdnDownloadFailCount: metricsutils.NewCounter(config.SubsystemSupernode, "cdn_download_failed_total",
6772
"Total failure times of cdn download", []string{}, register),
6873
}
@@ -165,6 +170,7 @@ func (cm *Manager) TriggerCDN(ctx context.Context, task *types.TaskInfo) (*types
165170
logrus.Errorf("failed to write for task %s: %v", task.ID, err)
166171
return getUpdateTaskInfoWithStatusOnly(types.TaskInfoCdnStatusFAILED), err
167172
}
173+
cm.metrics.cdnDownloadBytes.WithLabelValues().Add(float64(downloadMetadata.realHTTPFileLength))
168174

169175
realMD5 := reader.Md5()
170176
success, err := cm.handleCDNResult(ctx, task, realMD5, httpFileLength, downloadMetadata.realHTTPFileLength, downloadMetadata.realFileLength)

supernode/daemon/mgr/task/manager.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func newMetrics(register prometheus.Registerer) *metrics {
6767

6868
scheduleDurationMilliSeconds: metricsutils.NewHistogram(config.SubsystemSupernode, "schedule_duration_milliseconds",
6969
"Duration for task scheduling in milliseconds", []string{"peer"},
70-
prometheus.ExponentialBuckets(0.02, 2, 6), register),
70+
prometheus.ExponentialBuckets(0.01, 2, 7), register),
7171
}
7272
}
7373

supernode/server/metrics.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func newMetrics(register prometheus.Registerer) *metrics {
5757
),
5858
requestDuration: metricsutils.NewHistogram(config.SubsystemSupernode, "http_request_duration_seconds",
5959
"Histogram of latencies for HTTP requests.", []string{"handler"},
60-
[]float64{.1, .2, .4, 1, 3, 8, 20, 60, 120}, register,
60+
[]float64{.01, .02, .04, .1, .2, .4, 1, 2, 4, 8, 20, 60, 120}, register,
6161
),
6262
requestSize: metricsutils.NewHistogram(config.SubsystemSupernode, "http_request_size_bytes",
6363
"Histogram of request size for HTTP requests.", []string{"handler"},
@@ -72,7 +72,7 @@ func newMetrics(register prometheus.Registerer) *metrics {
7272
),
7373
dfgetDownloadDuration: metricsutils.NewHistogram(config.SubsystemDfget, "download_duration_seconds",
7474
"Histogram of duration for dfget download.", []string{"callsystem", "peer"},
75-
[]float64{10, 30, 60, 120, 300, 600}, register,
75+
[]float64{1, 2, 5, 10, 30, 60, 120, 300, 600}, register,
7676
),
7777
dfgetDownloadFileSize: metricsutils.NewCounter(config.SubsystemDfget, "download_size_bytes_total",
7878
"Total file size downloaded by dfget in bytes", []string{"callsystem", "peer"}, register,

0 commit comments

Comments
 (0)