Skip to content

Commit

Permalink
Reshape some metrics so they make more sense
Browse files Browse the repository at this point in the history
  • Loading branch information
pcarranza committed May 13, 2018
1 parent 9962d4e commit 1002a27
Showing 1 changed file with 45 additions and 8 deletions.
53 changes: 45 additions & 8 deletions nomad-exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,36 @@ var (
"Allocation memory usage",
[]string{"job", "group", "alloc", "region", "datacenter", "node"}, nil,
)
allocationMemoryBytesLimit = prometheus.NewDesc(
prometheus.BuildFQName(namespace, "", "allocation_memory_rss_bytes_limit"),
"Allocation memory limit.",
allocationMemoryBytesRequired = prometheus.NewDesc(
prometheus.BuildFQName(namespace, "", "allocation_memory_rss_required_bytes"),
"Allocation memory required.",
[]string{"job", "group", "alloc", "region", "datacenter", "node"}, nil,
)
allocationCPU = prometheus.NewDesc(
allocationCPURequired = prometheus.NewDesc(
prometheus.BuildFQName(namespace, "", "allocation_cpu_required"),
"Allocation CPU Required.",
[]string{"job", "group", "alloc", "region", "datacenter", "node"}, nil,
)
allocationCPUPercent = prometheus.NewDesc(
prometheus.BuildFQName(namespace, "", "allocation_cpu_percent"),
"Allocation CPU usage.",
[]string{"job", "group", "alloc", "region", "datacenter", "node"}, nil,
)
allocationCPUTicks = prometheus.NewDesc(
prometheus.BuildFQName(namespace, "", "allocation_cpu_ticks"),
"Allocation CPU Ticks usage.",
[]string{"job", "group", "alloc", "region", "datacenter", "node"}, nil,
)
allocationCPUUserMode = prometheus.NewDesc(
prometheus.BuildFQName(namespace, "", "allocation_cpu_user_mode"),
"Allocation CPU User Mode Usage.",
[]string{"job", "group", "alloc", "region", "datacenter", "node"}, nil,
)
allocationCPUSystemMode = prometheus.NewDesc(
prometheus.BuildFQName(namespace, "", "allocation_cpu_system_mode"),
"Allocation CPU System Mode Usage.",
[]string{"job", "group", "alloc", "region", "datacenter", "node"}, nil,
)
allocationCPUThrottled = prometheus.NewDesc(
prometheus.BuildFQName(namespace, "", "allocation_cpu_throttle_time"),
"Allocation throttled CPU.",
Expand Down Expand Up @@ -403,9 +423,13 @@ func (e *Exporter) Describe(ch chan<- *prometheus.Desc) {
ch <- serfLanMembersStatus
ch <- jobsTotal
ch <- allocationMemoryBytes
ch <- allocationCPU
ch <- allocationCPUPercent
ch <- allocationCPUTicks
ch <- allocationCPUUserMode
ch <- allocationCPUSystemMode
ch <- allocationCPUThrottled
ch <- allocationMemoryBytesLimit
ch <- allocationMemoryBytesRequired
ch <- allocationCPURequired
ch <- taskCPUPercent
ch <- taskCPUTotalTicks
ch <- taskMemoryRssBytes
Expand Down Expand Up @@ -792,7 +816,7 @@ func (e *Exporter) collectAllocations(ch chan<- prometheus.Metric) error {
node.Name,
}
ch <- prometheus.MustNewConstMetric(
allocationCPU, prometheus.GaugeValue, stats.ResourceUsage.CpuStats.Percent, allocationLabels...,
allocationCPUPercent, prometheus.GaugeValue, stats.ResourceUsage.CpuStats.Percent, allocationLabels...,
)
ch <- prometheus.MustNewConstMetric(
allocationCPUThrottled, prometheus.GaugeValue, float64(stats.ResourceUsage.CpuStats.ThrottledTime), allocationLabels...,
Expand All @@ -801,7 +825,20 @@ func (e *Exporter) collectAllocations(ch chan<- prometheus.Metric) error {
allocationMemoryBytes, prometheus.GaugeValue, float64(stats.ResourceUsage.MemoryStats.RSS), allocationLabels...,
)
ch <- prometheus.MustNewConstMetric(
allocationMemoryBytesLimit, prometheus.GaugeValue, float64(*alloc.Resources.MemoryMB)*1024*1024, allocationLabels...,
allocationCPUTicks, prometheus.GaugeValue, float64(stats.ResourceUsage.CpuStats.TotalTicks), allocationLabels...,
)
ch <- prometheus.MustNewConstMetric(
allocationCPUUserMode, prometheus.GaugeValue, float64(stats.ResourceUsage.CpuStats.UserMode), allocationLabels...,
)
ch <- prometheus.MustNewConstMetric(
allocationCPUSystemMode, prometheus.GaugeValue, float64(stats.ResourceUsage.CpuStats.SystemMode), allocationLabels...,
)

ch <- prometheus.MustNewConstMetric(
allocationMemoryBytesRequired, prometheus.GaugeValue, float64(*alloc.Resources.MemoryMB)*1024*1024, allocationLabels...,
)
ch <- prometheus.MustNewConstMetric(
allocationCPURequired, prometheus.GaugeValue, float64(*alloc.Resources.CPU), allocationLabels...,
)

for taskName, taskStats := range stats.Tasks {
Expand Down

0 comments on commit 1002a27

Please sign in to comment.