@@ -581,7 +581,7 @@ func (p4m *P4MonitorMetrics) parseLicense() {
581
581
p4m .metrics = append (p4m .metrics ,
582
582
metricStruct {name : "p4_license_IP" ,
583
583
help : "P4D Licensed IP" ,
584
- mtype : "gauge" ,
584
+ mtype : "" , // Should be a gauge but for backwards compatibility we leave as untyped
585
585
value : "1" ,
586
586
labels : []labelStruct {{name : "licenseIP" , value : licenseIP }}})
587
587
}
@@ -1019,7 +1019,7 @@ func (p4m *P4MonitorMetrics) monitorProcesses() {
1019
1019
for cmd , count := range cmdCounts {
1020
1020
p4m .metrics = append (p4m .metrics , metricStruct {name : "p4_monitor_by_cmd" ,
1021
1021
help : "P4 running processes by cmd in monitor table" ,
1022
- mtype : "gauge " ,
1022
+ mtype : "counter " ,
1023
1023
value : fmt .Sprintf ("%d" , count ),
1024
1024
labels : []labelStruct {{name : "cmd" , value : cmd }}})
1025
1025
}
@@ -1028,7 +1028,7 @@ func (p4m *P4MonitorMetrics) monitorProcesses() {
1028
1028
for user , count := range userCounts {
1029
1029
p4m .metrics = append (p4m .metrics , metricStruct {name : "p4_monitor_by_user" ,
1030
1030
help : "P4 running processes by user in monitor table" ,
1031
- mtype : "gauge " ,
1031
+ mtype : "counter " ,
1032
1032
value : fmt .Sprintf ("%d" , count ),
1033
1033
labels : []labelStruct {{name : "user" , value : user }}})
1034
1034
}
@@ -1058,8 +1058,10 @@ func (p4m *P4MonitorMetrics) monitorProcesses() {
1058
1058
if err != nil {
1059
1059
p4m .logger .Errorf ("Error running 'ps ax': %v, err:%q" , err , errbuf .String ())
1060
1060
} else {
1061
- p4m .metrics = append (p4m .metrics , metricStruct {name : "p4_process_count" ,
1062
- help : "P4 ps running processes" ,
1061
+ // Old monitor_metrics.sh has p4_process_count but as a counter - should be a gauge!
1062
+ // So new name
1063
+ p4m .metrics = append (p4m .metrics , metricStruct {name : "p4_processes_count" ,
1064
+ help : "P4 count of running processes (via ps)" ,
1063
1065
mtype : "gauge" ,
1064
1066
value : fmt .Sprintf ("%d" , pcount )})
1065
1067
}
@@ -1205,14 +1207,14 @@ func (p4m *P4MonitorMetrics) monitorReplicas() {
1205
1207
if s .journal != "" {
1206
1208
p4m .metrics = append (p4m .metrics , metricStruct {name : "p4_replica_curr_jnl" ,
1207
1209
help : "Current journal for server" ,
1208
- mtype : "gauge " ,
1210
+ mtype : "counter " ,
1209
1211
value : s .journal ,
1210
1212
labels : []labelStruct {{name : "servername" , value : s .name }}})
1211
1213
}
1212
1214
if s .offset != "" {
1213
1215
p4m .metrics = append (p4m .metrics , metricStruct {name : "p4_replica_curr_pos" ,
1214
1216
help : "Current offset within for server" ,
1215
- mtype : "gauge" ,
1217
+ mtype : "counter" , // Probably should be a gauge but kept for compatibility
1216
1218
value : s .offset ,
1217
1219
labels : []labelStruct {{name : "servername" , value : s .name }}})
1218
1220
}
@@ -1292,11 +1294,13 @@ func (p4m *P4MonitorMetrics) monitorPull() {
1292
1294
if err != nil {
1293
1295
p4m .logger .Errorf ("Error counting pull queue: %v" , err )
1294
1296
} else {
1295
- p4m .metrics = append (p4m .metrics , metricStruct {name : "p4_pull_errors" ,
1297
+ // Old monitor_metrics.sh has p4_pull_errors - but incorrectly as a counter
1298
+ p4m .metrics = append (p4m .metrics , metricStruct {name : "p4_pull_error_count" ,
1296
1299
help : "Count of p4 pull transfers in failed state" ,
1297
1300
mtype : "gauge" ,
1298
1301
value : fmt .Sprintf ("%d" , failedCount )})
1299
- p4m .metrics = append (p4m .metrics , metricStruct {name : "p4_pull_queue" ,
1302
+ // Old monitor_metrics.sh has p4_pull_queue - but incorrectly as a counter
1303
+ p4m .metrics = append (p4m .metrics , metricStruct {name : "p4_pull_queue_count" ,
1300
1304
help : "Count of p4 pull files (not in failed state)" ,
1301
1305
mtype : "gauge" ,
1302
1306
value : fmt .Sprintf ("%d" , otherCount )})
@@ -1466,9 +1470,13 @@ func (p4m *P4MonitorMetrics) monitorRealTime() {
1466
1470
continue
1467
1471
}
1468
1472
name := "p4_" + strings .ReplaceAll (fields [0 ], "." , "_" )
1473
+ mtype := "gauge"
1474
+ if fields [0 ] == "rtv.db.io.records" || fields [0 ] == "rtv.svr.sessions.total" {
1475
+ mtype = "counter" // For backwards compatibility with monitor_metrics.sh and historical data
1476
+ }
1469
1477
p4m .metrics = append (p4m .metrics , metricStruct {name : name ,
1470
1478
help : fmt .Sprintf ("P4 realtime metric %s" , fields [0 ]),
1471
- mtype : "gauge" ,
1479
+ mtype : mtype ,
1472
1480
value : fields [3 ]})
1473
1481
}
1474
1482
p4m .writeMetricsFile ()
0 commit comments