Use cgroups proto for prom metrics

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
Michael Crosby
2017-09-05 13:05:54 -04:00
parent 0973a084cf
commit ed45952826
9 changed files with 92 additions and 82 deletions

View File

@@ -14,7 +14,7 @@ var memoryMetrics = []*metric{
help: "The cache amount used",
unit: metrics.Bytes,
vt: prometheus.GaugeValue,
getValues: func(stats *cgroups.Stats) []value {
getValues: func(stats *cgroups.Metrics) []value {
if stats.Memory == nil {
return nil
}
@@ -30,13 +30,13 @@ var memoryMetrics = []*metric{
help: "The rss amount used",
unit: metrics.Bytes,
vt: prometheus.GaugeValue,
getValues: func(stats *cgroups.Stats) []value {
getValues: func(stats *cgroups.Metrics) []value {
if stats.Memory == nil {
return nil
}
return []value{
{
v: float64(stats.Memory.RSS),
v: float64(stats.Memory.Rss),
},
}
},
@@ -46,13 +46,13 @@ var memoryMetrics = []*metric{
help: "The rss_huge amount used",
unit: metrics.Bytes,
vt: prometheus.GaugeValue,
getValues: func(stats *cgroups.Stats) []value {
getValues: func(stats *cgroups.Metrics) []value {
if stats.Memory == nil {
return nil
}
return []value{
{
v: float64(stats.Memory.RSSHuge),
v: float64(stats.Memory.RssHuge),
},
}
},
@@ -62,7 +62,7 @@ var memoryMetrics = []*metric{
help: "The mapped_file amount used",
unit: metrics.Bytes,
vt: prometheus.GaugeValue,
getValues: func(stats *cgroups.Stats) []value {
getValues: func(stats *cgroups.Metrics) []value {
if stats.Memory == nil {
return nil
}
@@ -78,7 +78,7 @@ var memoryMetrics = []*metric{
help: "The dirty amount",
unit: metrics.Bytes,
vt: prometheus.GaugeValue,
getValues: func(stats *cgroups.Stats) []value {
getValues: func(stats *cgroups.Metrics) []value {
if stats.Memory == nil {
return nil
}
@@ -94,7 +94,7 @@ var memoryMetrics = []*metric{
help: "The writeback amount",
unit: metrics.Bytes,
vt: prometheus.GaugeValue,
getValues: func(stats *cgroups.Stats) []value {
getValues: func(stats *cgroups.Metrics) []value {
if stats.Memory == nil {
return nil
}
@@ -110,7 +110,7 @@ var memoryMetrics = []*metric{
help: "The pgpgin amount",
unit: metrics.Bytes,
vt: prometheus.GaugeValue,
getValues: func(stats *cgroups.Stats) []value {
getValues: func(stats *cgroups.Metrics) []value {
if stats.Memory == nil {
return nil
}
@@ -126,7 +126,7 @@ var memoryMetrics = []*metric{
help: "The pgpgout amount",
unit: metrics.Bytes,
vt: prometheus.GaugeValue,
getValues: func(stats *cgroups.Stats) []value {
getValues: func(stats *cgroups.Metrics) []value {
if stats.Memory == nil {
return nil
}
@@ -142,7 +142,7 @@ var memoryMetrics = []*metric{
help: "The pgfault amount",
unit: metrics.Bytes,
vt: prometheus.GaugeValue,
getValues: func(stats *cgroups.Stats) []value {
getValues: func(stats *cgroups.Metrics) []value {
if stats.Memory == nil {
return nil
}
@@ -158,7 +158,7 @@ var memoryMetrics = []*metric{
help: "The pgmajfault amount",
unit: metrics.Bytes,
vt: prometheus.GaugeValue,
getValues: func(stats *cgroups.Stats) []value {
getValues: func(stats *cgroups.Metrics) []value {
if stats.Memory == nil {
return nil
}
@@ -174,7 +174,7 @@ var memoryMetrics = []*metric{
help: "The inactive_anon amount",
unit: metrics.Bytes,
vt: prometheus.GaugeValue,
getValues: func(stats *cgroups.Stats) []value {
getValues: func(stats *cgroups.Metrics) []value {
if stats.Memory == nil {
return nil
}
@@ -190,7 +190,7 @@ var memoryMetrics = []*metric{
help: "The active_anon amount",
unit: metrics.Bytes,
vt: prometheus.GaugeValue,
getValues: func(stats *cgroups.Stats) []value {
getValues: func(stats *cgroups.Metrics) []value {
if stats.Memory == nil {
return nil
}
@@ -206,7 +206,7 @@ var memoryMetrics = []*metric{
help: "The inactive_file amount",
unit: metrics.Bytes,
vt: prometheus.GaugeValue,
getValues: func(stats *cgroups.Stats) []value {
getValues: func(stats *cgroups.Metrics) []value {
if stats.Memory == nil {
return nil
}
@@ -222,7 +222,7 @@ var memoryMetrics = []*metric{
help: "The active_file amount",
unit: metrics.Bytes,
vt: prometheus.GaugeValue,
getValues: func(stats *cgroups.Stats) []value {
getValues: func(stats *cgroups.Metrics) []value {
if stats.Memory == nil {
return nil
}
@@ -238,7 +238,7 @@ var memoryMetrics = []*metric{
help: "The unevictable amount",
unit: metrics.Bytes,
vt: prometheus.GaugeValue,
getValues: func(stats *cgroups.Stats) []value {
getValues: func(stats *cgroups.Metrics) []value {
if stats.Memory == nil {
return nil
}
@@ -254,7 +254,7 @@ var memoryMetrics = []*metric{
help: "The hierarchical_memory_limit amount",
unit: metrics.Bytes,
vt: prometheus.GaugeValue,
getValues: func(stats *cgroups.Stats) []value {
getValues: func(stats *cgroups.Metrics) []value {
if stats.Memory == nil {
return nil
}
@@ -270,7 +270,7 @@ var memoryMetrics = []*metric{
help: "The hierarchical_memsw_limit amount",
unit: metrics.Bytes,
vt: prometheus.GaugeValue,
getValues: func(stats *cgroups.Stats) []value {
getValues: func(stats *cgroups.Metrics) []value {
if stats.Memory == nil {
return nil
}
@@ -286,7 +286,7 @@ var memoryMetrics = []*metric{
help: "The total_cache amount used",
unit: metrics.Bytes,
vt: prometheus.GaugeValue,
getValues: func(stats *cgroups.Stats) []value {
getValues: func(stats *cgroups.Metrics) []value {
if stats.Memory == nil {
return nil
}
@@ -302,13 +302,13 @@ var memoryMetrics = []*metric{
help: "The total_rss amount used",
unit: metrics.Bytes,
vt: prometheus.GaugeValue,
getValues: func(stats *cgroups.Stats) []value {
getValues: func(stats *cgroups.Metrics) []value {
if stats.Memory == nil {
return nil
}
return []value{
{
v: float64(stats.Memory.TotalRSS),
v: float64(stats.Memory.TotalRss),
},
}
},
@@ -318,13 +318,13 @@ var memoryMetrics = []*metric{
help: "The total_rss_huge amount used",
unit: metrics.Bytes,
vt: prometheus.GaugeValue,
getValues: func(stats *cgroups.Stats) []value {
getValues: func(stats *cgroups.Metrics) []value {
if stats.Memory == nil {
return nil
}
return []value{
{
v: float64(stats.Memory.TotalRSSHuge),
v: float64(stats.Memory.TotalRssHuge),
},
}
},
@@ -334,7 +334,7 @@ var memoryMetrics = []*metric{
help: "The total_mapped_file amount used",
unit: metrics.Bytes,
vt: prometheus.GaugeValue,
getValues: func(stats *cgroups.Stats) []value {
getValues: func(stats *cgroups.Metrics) []value {
if stats.Memory == nil {
return nil
}
@@ -350,7 +350,7 @@ var memoryMetrics = []*metric{
help: "The total_dirty amount",
unit: metrics.Bytes,
vt: prometheus.GaugeValue,
getValues: func(stats *cgroups.Stats) []value {
getValues: func(stats *cgroups.Metrics) []value {
if stats.Memory == nil {
return nil
}
@@ -366,7 +366,7 @@ var memoryMetrics = []*metric{
help: "The total_writeback amount",
unit: metrics.Bytes,
vt: prometheus.GaugeValue,
getValues: func(stats *cgroups.Stats) []value {
getValues: func(stats *cgroups.Metrics) []value {
if stats.Memory == nil {
return nil
}
@@ -382,7 +382,7 @@ var memoryMetrics = []*metric{
help: "The total_pgpgin amount",
unit: metrics.Bytes,
vt: prometheus.GaugeValue,
getValues: func(stats *cgroups.Stats) []value {
getValues: func(stats *cgroups.Metrics) []value {
if stats.Memory == nil {
return nil
}
@@ -398,7 +398,7 @@ var memoryMetrics = []*metric{
help: "The total_pgpgout amount",
unit: metrics.Bytes,
vt: prometheus.GaugeValue,
getValues: func(stats *cgroups.Stats) []value {
getValues: func(stats *cgroups.Metrics) []value {
if stats.Memory == nil {
return nil
}
@@ -414,7 +414,7 @@ var memoryMetrics = []*metric{
help: "The total_pgfault amount",
unit: metrics.Bytes,
vt: prometheus.GaugeValue,
getValues: func(stats *cgroups.Stats) []value {
getValues: func(stats *cgroups.Metrics) []value {
if stats.Memory == nil {
return nil
}
@@ -430,7 +430,7 @@ var memoryMetrics = []*metric{
help: "The total_pgmajfault amount",
unit: metrics.Bytes,
vt: prometheus.GaugeValue,
getValues: func(stats *cgroups.Stats) []value {
getValues: func(stats *cgroups.Metrics) []value {
if stats.Memory == nil {
return nil
}
@@ -446,7 +446,7 @@ var memoryMetrics = []*metric{
help: "The total_inactive_anon amount",
unit: metrics.Bytes,
vt: prometheus.GaugeValue,
getValues: func(stats *cgroups.Stats) []value {
getValues: func(stats *cgroups.Metrics) []value {
if stats.Memory == nil {
return nil
}
@@ -462,7 +462,7 @@ var memoryMetrics = []*metric{
help: "The total_active_anon amount",
unit: metrics.Bytes,
vt: prometheus.GaugeValue,
getValues: func(stats *cgroups.Stats) []value {
getValues: func(stats *cgroups.Metrics) []value {
if stats.Memory == nil {
return nil
}
@@ -478,7 +478,7 @@ var memoryMetrics = []*metric{
help: "The total_inactive_file amount",
unit: metrics.Bytes,
vt: prometheus.GaugeValue,
getValues: func(stats *cgroups.Stats) []value {
getValues: func(stats *cgroups.Metrics) []value {
if stats.Memory == nil {
return nil
}
@@ -494,7 +494,7 @@ var memoryMetrics = []*metric{
help: "The total_active_file amount",
unit: metrics.Bytes,
vt: prometheus.GaugeValue,
getValues: func(stats *cgroups.Stats) []value {
getValues: func(stats *cgroups.Metrics) []value {
if stats.Memory == nil {
return nil
}
@@ -510,7 +510,7 @@ var memoryMetrics = []*metric{
help: "The total_unevictable amount",
unit: metrics.Bytes,
vt: prometheus.GaugeValue,
getValues: func(stats *cgroups.Stats) []value {
getValues: func(stats *cgroups.Metrics) []value {
if stats.Memory == nil {
return nil
}
@@ -526,7 +526,7 @@ var memoryMetrics = []*metric{
help: "The usage failcnt",
unit: metrics.Total,
vt: prometheus.GaugeValue,
getValues: func(stats *cgroups.Stats) []value {
getValues: func(stats *cgroups.Metrics) []value {
if stats.Memory == nil {
return nil
}
@@ -542,7 +542,7 @@ var memoryMetrics = []*metric{
help: "The memory limit",
unit: metrics.Bytes,
vt: prometheus.GaugeValue,
getValues: func(stats *cgroups.Stats) []value {
getValues: func(stats *cgroups.Metrics) []value {
if stats.Memory == nil {
return nil
}
@@ -558,7 +558,7 @@ var memoryMetrics = []*metric{
help: "The memory maximum usage",
unit: metrics.Bytes,
vt: prometheus.GaugeValue,
getValues: func(stats *cgroups.Stats) []value {
getValues: func(stats *cgroups.Metrics) []value {
if stats.Memory == nil {
return nil
}
@@ -574,7 +574,7 @@ var memoryMetrics = []*metric{
help: "The memory usage",
unit: metrics.Bytes,
vt: prometheus.GaugeValue,
getValues: func(stats *cgroups.Stats) []value {
getValues: func(stats *cgroups.Metrics) []value {
if stats.Memory == nil {
return nil
}
@@ -590,7 +590,7 @@ var memoryMetrics = []*metric{
help: "The swap failcnt",
unit: metrics.Total,
vt: prometheus.GaugeValue,
getValues: func(stats *cgroups.Stats) []value {
getValues: func(stats *cgroups.Metrics) []value {
if stats.Memory == nil {
return nil
}
@@ -606,7 +606,7 @@ var memoryMetrics = []*metric{
help: "The swap limit",
unit: metrics.Bytes,
vt: prometheus.GaugeValue,
getValues: func(stats *cgroups.Stats) []value {
getValues: func(stats *cgroups.Metrics) []value {
if stats.Memory == nil {
return nil
}
@@ -622,7 +622,7 @@ var memoryMetrics = []*metric{
help: "The swap maximum usage",
unit: metrics.Bytes,
vt: prometheus.GaugeValue,
getValues: func(stats *cgroups.Stats) []value {
getValues: func(stats *cgroups.Metrics) []value {
if stats.Memory == nil {
return nil
}
@@ -638,7 +638,7 @@ var memoryMetrics = []*metric{
help: "The swap usage",
unit: metrics.Bytes,
vt: prometheus.GaugeValue,
getValues: func(stats *cgroups.Stats) []value {
getValues: func(stats *cgroups.Metrics) []value {
if stats.Memory == nil {
return nil
}
@@ -654,7 +654,7 @@ var memoryMetrics = []*metric{
help: "The kernel failcnt",
unit: metrics.Total,
vt: prometheus.GaugeValue,
getValues: func(stats *cgroups.Stats) []value {
getValues: func(stats *cgroups.Metrics) []value {
if stats.Memory == nil {
return nil
}
@@ -670,7 +670,7 @@ var memoryMetrics = []*metric{
help: "The kernel limit",
unit: metrics.Bytes,
vt: prometheus.GaugeValue,
getValues: func(stats *cgroups.Stats) []value {
getValues: func(stats *cgroups.Metrics) []value {
if stats.Memory == nil {
return nil
}
@@ -686,7 +686,7 @@ var memoryMetrics = []*metric{
help: "The kernel maximum usage",
unit: metrics.Bytes,
vt: prometheus.GaugeValue,
getValues: func(stats *cgroups.Stats) []value {
getValues: func(stats *cgroups.Metrics) []value {
if stats.Memory == nil {
return nil
}
@@ -702,7 +702,7 @@ var memoryMetrics = []*metric{
help: "The kernel usage",
unit: metrics.Bytes,
vt: prometheus.GaugeValue,
getValues: func(stats *cgroups.Stats) []value {
getValues: func(stats *cgroups.Metrics) []value {
if stats.Memory == nil {
return nil
}
@@ -718,13 +718,13 @@ var memoryMetrics = []*metric{
help: "The kerneltcp failcnt",
unit: metrics.Total,
vt: prometheus.GaugeValue,
getValues: func(stats *cgroups.Stats) []value {
getValues: func(stats *cgroups.Metrics) []value {
if stats.Memory == nil {
return nil
}
return []value{
{
v: float64(stats.Memory.KernelTCP.Failcnt),
v: float64(stats.Memory.KernelTcp.Failcnt),
},
}
},
@@ -734,13 +734,13 @@ var memoryMetrics = []*metric{
help: "The kerneltcp limit",
unit: metrics.Bytes,
vt: prometheus.GaugeValue,
getValues: func(stats *cgroups.Stats) []value {
getValues: func(stats *cgroups.Metrics) []value {
if stats.Memory == nil {
return nil
}
return []value{
{
v: float64(stats.Memory.KernelTCP.Limit),
v: float64(stats.Memory.KernelTcp.Limit),
},
}
},
@@ -750,13 +750,13 @@ var memoryMetrics = []*metric{
help: "The kerneltcp maximum usage",
unit: metrics.Bytes,
vt: prometheus.GaugeValue,
getValues: func(stats *cgroups.Stats) []value {
getValues: func(stats *cgroups.Metrics) []value {
if stats.Memory == nil {
return nil
}
return []value{
{
v: float64(stats.Memory.KernelTCP.Max),
v: float64(stats.Memory.KernelTcp.Max),
},
}
},
@@ -766,13 +766,13 @@ var memoryMetrics = []*metric{
help: "The kerneltcp usage",
unit: metrics.Bytes,
vt: prometheus.GaugeValue,
getValues: func(stats *cgroups.Stats) []value {
getValues: func(stats *cgroups.Metrics) []value {
if stats.Memory == nil {
return nil
}
return []value{
{
v: float64(stats.Memory.KernelTCP.Usage),
v: float64(stats.Memory.KernelTcp.Usage),
},
}
},