Skip to content

Commit

Permalink
Merge pull request #6 from pcarranza/pc/add-version-to-alloc-labels
Browse files Browse the repository at this point in the history
Add version to alloc labels
  • Loading branch information
pcarranza authored Aug 1, 2018
2 parents b543b7b + a016f73 commit ef92f05
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
1 change: 1 addition & 0 deletions exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,7 @@ func (e *Exporter) collectAllocations(nodes nodeMap, ch chan<- prometheus.Metric
*alloc.Job.Region,
n.Datacenter,
n.Name,
fmt.Sprintf("%d", alloc.Job.Version),
}
ch <- prometheus.MustNewConstMetric(
allocationCPUPercent, prometheus.GaugeValue, stats.ResourceUsage.CpuStats.Percent, allocationLabels...,
Expand Down
28 changes: 17 additions & 11 deletions nomad-exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,60 +61,66 @@ var (
"How many jobs are there in the cluster.",
nil, nil,
)

allocationLabels = []string{"job", "group", "alloc", "region", "datacenter", "node", "version"}

allocationMemoryBytes = prometheus.NewDesc(
prometheus.BuildFQName(namespace, "", "allocation_memory_rss_bytes"),
"Allocation memory usage",
[]string{"job", "group", "alloc", "region", "datacenter", "node"}, nil,
allocationLabels, nil,
)
allocationMemoryBytesRequired = prometheus.NewDesc(
prometheus.BuildFQName(namespace, "", "allocation_memory_rss_required_bytes"),
"Allocation memory required.",
[]string{"job", "group", "alloc", "region", "datacenter", "node"}, nil,
allocationLabels, nil,
)
allocationCPURequired = prometheus.NewDesc(
prometheus.BuildFQName(namespace, "", "allocation_cpu_required"),
"Allocation CPU Required.",
[]string{"job", "group", "alloc", "region", "datacenter", "node"}, nil,
allocationLabels, nil,
)
allocationCPUPercent = prometheus.NewDesc(
prometheus.BuildFQName(namespace, "", "allocation_cpu_percent"),
"Allocation CPU usage.",
[]string{"job", "group", "alloc", "region", "datacenter", "node"}, nil,
allocationLabels, nil,
)
allocationCPUTicks = prometheus.NewDesc(
prometheus.BuildFQName(namespace, "", "allocation_cpu_ticks"),
"Allocation CPU Ticks usage.",
[]string{"job", "group", "alloc", "region", "datacenter", "node"}, nil,
allocationLabels, nil,
)
allocationCPUUserMode = prometheus.NewDesc(
prometheus.BuildFQName(namespace, "", "allocation_cpu_user_mode"),
"Allocation CPU User Mode Usage.",
[]string{"job", "group", "alloc", "region", "datacenter", "node"}, nil,
allocationLabels, nil,
)
allocationCPUSystemMode = prometheus.NewDesc(
prometheus.BuildFQName(namespace, "", "allocation_cpu_system_mode"),
"Allocation CPU System Mode Usage.",
[]string{"job", "group", "alloc", "region", "datacenter", "node"}, nil,
allocationLabels, nil,
)
allocationCPUThrottled = prometheus.NewDesc(
prometheus.BuildFQName(namespace, "", "allocation_cpu_throttle_time"),
"Allocation throttled CPU.",
[]string{"job", "group", "alloc", "region", "datacenter", "node"}, nil,
allocationLabels, nil,
)

taskLabels = append(allocationLabels, "task")

taskCPUTotalTicks = prometheus.NewDesc(
prometheus.BuildFQName(namespace, "", "task_cpu_total_ticks"),
"Task CPU total ticks.",
[]string{"job", "group", "alloc", "region", "datacenter", "node", "task"}, nil,
taskLabels, nil,
)
taskCPUPercent = prometheus.NewDesc(
prometheus.BuildFQName(namespace, "", "task_cpu_percent"),
"Task CPU usage percent.",
[]string{"job", "group", "alloc", "region", "datacenter", "node", "task"}, nil,
taskLabels, nil,
)
taskMemoryRssBytes = prometheus.NewDesc(
prometheus.BuildFQName(namespace, "", "task_memory_rss_bytes"),
"Task memory RSS usage in bytes.",
[]string{"job", "group", "alloc", "region", "datacenter", "node", "task"}, nil,
taskLabels, nil,
)

nodeResourceMemory = prometheus.NewDesc(
Expand Down

0 comments on commit ef92f05

Please sign in to comment.