-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathformat.go
70 lines (62 loc) · 1.99 KB
/
format.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
package main
import (
"github.com/prometheus/client_golang/prometheus"
)
const (
// ONDAT_NAMESPACE defines the common namespace used by all our metrics.
// Not to be confused with the k8s namespace where resources live.
//
// "ondat_..."
ONDAT_NAMESPACE = "ondat"
// DISK_SUBSYSTEM defines the common category shared between all metrics we
// expose about PVCs
//
// "ondat_disk_..."
DISK_SUBSYSTEM = "disk"
// FILE_SYSTEM_SUBSYSTEM defines the common category shared between all filesystem
// metrics
//
// "ondat_filesystem_..."
FILE_SYSTEM_SUBSYSTEM = "filesystem"
// SCRAPE_SUBSYSTEM defines the category about the metrics gathering process
// itself (success, failures, duration, etc)
//
// "ondat_scrape_..."
SCRAPE_SUBSYSTEM = "scrape"
)
var (
// labels present in all disk metrics to identify the PVC
pvcLabels = []string{"pvc", "pvc_namespace"}
// labels present in all filesystem metrics to identify the device
fsLabels = []string{"pvc", "pvc_namespace", "device", "fstype", "mountpoint"}
// labels present in all scrape metrics to identify the collector
collectorLabels = []string{"collector"}
// scrapeDurationMetric defines the scrape duration metric
//
// shared between all metric collectors
scrapeDurationMetric = Metric{
desc: prometheus.NewDesc(
prometheus.BuildFQName(ONDAT_NAMESPACE, SCRAPE_SUBSYSTEM, "collector_duration_seconds"),
"Duration of a collector scrape.",
collectorLabels, nil,
),
valueType: prometheus.GaugeValue,
}
// scrapeDurationDesc defines the scrape success/failure metric
//
// shared between all metric collectors
scrapeSuccessMetric = Metric{
desc: prometheus.NewDesc(
prometheus.BuildFQName(ONDAT_NAMESPACE, SCRAPE_SUBSYSTEM, "collector_success"),
"Whether a collector succeeded.",
collectorLabels, nil,
),
valueType: prometheus.GaugeValue,
}
)
// Metric is a wrapper over prometheus types (desc and type) defining a
// standalone metric
type Metric struct {
desc *prometheus.Desc
valueType prometheus.ValueType
}