This repository has been archived by the owner on Jun 26, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
metrics.go
85 lines (76 loc) · 3.11 KB
/
metrics.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
82
83
84
85
package main
import "github.com/prometheus/client_golang/prometheus"
func AddMetrics() map[string]*prometheus.GaugeVec {
gaugeVecs := make(map[string]*prometheus.GaugeVec)
// stack metrics
gaugeVecs["stacksState"] = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: namespace,
Name: "stack_state",
Help: "State of defined stack as reported by the Docker Cloud API",
}, []string{"stack_name", "state"})
gaugeVecs["stackDeployedDate"] = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: namespace,
Name: "stack_deployed_date",
Help: "Date & time the stack was deployed in Unix seconds",
}, []string{"stack_name"})
// service metrics
gaugeVecs["serviceState"] = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: namespace,
Name: "service_state",
Help: "State of defined service as reported by the Docker Cloud API",
}, []string{"service_name", "stack_name", "state"})
gaugeVecs["serviceDeployedDate"] = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: namespace,
Name: "service_deployed_date",
Help: "Date & time the service was created in Unix seconds",
}, []string{"service_name", "stack_name"})
gaugeVecs["serviceContainersRunning"] = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: namespace,
Name: "service_containers_running",
Help: "Number of running containers",
}, []string{"service_name", "stack_name"})
gaugeVecs["serviceContainersTarget"] = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: namespace,
Name: "service_containers_target",
Help: "Target number of containers defined in config",
}, []string{"service_name", "stack_name"})
gaugeVecs["serviceContainersStopped"] = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: namespace,
Name: "service_containers_stopped",
Help: "Number of stopped containers",
}, []string{"service_name", "stack_name"})
// node metrics
gaugeVecs["nodeState"] = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: namespace,
Name: "node_state",
Help: "State of defined node as reported by the Docker Cloud API",
}, []string{"node_uuid", "availability_zone", "region", "node_cluster_name", "docker_version", "state"})
// node cluster metrics
gaugeVecs["nodeClusterState"] = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: namespace,
Name: "node_cluster_state",
Help: "State of defined node cluster as reported by the Docker Cloud API",
}, []string{"node_cluster_name", "state"})
gaugeVecs["nodeClusterNodesCurrent"] = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: namespace,
Name: "node_cluster_nodes_current",
Help: "State of defined node cluster as reported by the Docker Cloud API",
}, []string{"node_cluster_name"})
gaugeVecs["nodeClusterNodesTarget"] = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: namespace,
Name: "node_cluster_nodes_target",
Help: "State of defined node cluster as reported by the Docker Cloud API",
}, []string{"node_cluster_name"})
return gaugeVecs
}