This repository has been archived by the owner on Jan 10, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 29
/
xdr.go
81 lines (72 loc) · 2.72 KB
/
xdr.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package main
import (
"strings"
as "github.com/aerospike/aerospike-client-go"
"github.com/prometheus/client_golang/prometheus"
)
var (
// DCMetrics lists the keys we report from aero's dc statistics command.
// See `asinfo -l -v dcs` for a list of XDR DCs.
// See `asinfo -l -v dc/<dc>` for detailed metrics for a given DC.
DCMetrics = []metric{
gauge("dc_as_open_conn", "Number of open connection to the Aerospike DC."),
gauge("dc_as_size", "The cluster size of the destination Aerospike DC."),
gauge("dc_http_good_locations", "Number of URLs that are considered healthy."),
gauge("dc_http_locations", "Number of URLs configured for the HTTP destination."),
counter("dc_ship_attempt", "Number of records that have been attempted to be shipped."),
counter("dc_ship_bytes", "Number of bytes shipped for this DC."),
counter("dc_ship_delete_success", "Number of delete transactions that have been successfully shipped."),
counter("dc_ship_destination_error", "Number of errors from the remote cluster(s) while shipping records for this DC."),
gauge("dc_ship_idle_avg", "Average number of ms of sleep for each record being shipped."),
gauge("dc_ship_idle_avg_pct", "Representation in percent of total time spent for dc_ship_idle_avg."),
gauge("dc_ship_inflight_objects", "Number of records that are inflight."),
gauge("dc_ship_latency_avg", "Moving average of shipping latency for the specific DC."),
counter("dc_ship_source_error", "Number of client layer errors while shipping records for this DC."),
counter("dc_ship_success", "Number of records that have been successfully shipped."),
// dc_state https://www.aerospike.com/docs/reference/metrics/?show-removed=0#dc_state
gauge("dc_timelag", "Time lag for this specific DC."),
}
)
type XdrDCCollector cmetrics
func newXdrDCCollector() XdrDCCollector {
dc := map[string]cmetric {}
for _, m := range DCMetrics {
dc[m.aeroName] = cmetric{
typ: m.typ,
desc: prometheus.NewDesc(
promkey(xdrDC, m.aeroName),
m.desc,
[]string{"dc"},
nil,
),
}
}
return dc
}
func (dcc XdrDCCollector) describe(ch chan<- *prometheus.Desc) {
for _, s := range dcc {
ch <- s.desc
}
}
func (sic XdrDCCollector) collect(conn *as.Connection) ([]prometheus.Metric, error) {
info, err := as.RequestInfo(conn, "dcs")
if err != nil {
return nil, err
}
var metrics []prometheus.Metric
for _, dc := range strings.Split(info["dcs"], ";") {
dcInfo, err := as.RequestInfo(conn, "dc/"+dc)
if err != nil {
return nil, err
}
metrics = append(
metrics,
infoCollect(
cmetrics(sic),
dcInfo["dc/"+dc],
dc,
)...,
)
}
return metrics, nil
}