Skip to content

Commit

Permalink
Renaming to match prometheus convention for counters.
Browse files Browse the repository at this point in the history
Removing some obsolete metrics that could be calculated using sum()
operator of prometheus.

fix #11
  • Loading branch information
Audrius Karabanovas committed Oct 3, 2019
1 parent 6cb9b4e commit 067e112
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 34 deletions.
40 changes: 13 additions & 27 deletions collector/beat.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,34 +52,29 @@ func NewBeatCollector(beatInfo *BeatInfo, stats *Stats) prometheus.Collector {
metrics: exportedMetrics{
{
desc: prometheus.NewDesc(
prometheus.BuildFQName(beatInfo.Beat, "cpu_time", "milliseconds"),
prometheus.BuildFQName(beatInfo.Beat, "cpu_time", "seconds_total"),
"beat.cpu.time",
nil, prometheus.Labels{"mode": "system"},
),
eval: func(stats *Stats) float64 { return stats.Beat.CPU.System.Time.MS },
eval: func(stats *Stats) float64 {
return (time.Duration(stats.Beat.CPU.System.Time.MS) * time.Millisecond).Seconds()
},
valType: prometheus.CounterValue,
},
{
desc: prometheus.NewDesc(
prometheus.BuildFQName(beatInfo.Beat, "cpu_time", "milliseconds"),
prometheus.BuildFQName(beatInfo.Beat, "cpu_time", "seconds_total"),
"beat.cpu.time",
nil, prometheus.Labels{"mode": "user"},
),
eval: func(stats *Stats) float64 { return stats.Beat.CPU.User.Time.MS },
valType: prometheus.CounterValue,
},
{
desc: prometheus.NewDesc(
prometheus.BuildFQName(beatInfo.Beat, "cpu_time", "milliseconds"),
"beat.cpu.time",
nil, prometheus.Labels{"mode": "total"},
),
eval: func(stats *Stats) float64 { return stats.Beat.CPU.Total.Time.MS },
eval: func(stats *Stats) float64 {
return (time.Duration(stats.Beat.CPU.User.Time.MS) * time.Millisecond).Seconds()
},
valType: prometheus.CounterValue,
},
{
desc: prometheus.NewDesc(
prometheus.BuildFQName(beatInfo.Beat, "cpu", "ticks"),
prometheus.BuildFQName(beatInfo.Beat, "cpu", "ticks_total"),
"beat.cpu.ticks",
nil, prometheus.Labels{"mode": "system"},
),
Expand All @@ -88,7 +83,7 @@ func NewBeatCollector(beatInfo *BeatInfo, stats *Stats) prometheus.Collector {
},
{
desc: prometheus.NewDesc(
prometheus.BuildFQName(beatInfo.Beat, "cpu", "ticks"),
prometheus.BuildFQName(beatInfo.Beat, "cpu", "ticks_total"),
"beat.cpu.ticks",
nil, prometheus.Labels{"mode": "user"},
),
Expand All @@ -97,16 +92,7 @@ func NewBeatCollector(beatInfo *BeatInfo, stats *Stats) prometheus.Collector {
},
{
desc: prometheus.NewDesc(
prometheus.BuildFQName(beatInfo.Beat, "cpu", "ticks"),
"beat.cpu.ticks",
nil, prometheus.Labels{"mode": "total"},
),
eval: func(stats *Stats) float64 { return stats.Beat.CPU.Total.Ticks },
valType: prometheus.CounterValue,
},
{
desc: prometheus.NewDesc(
prometheus.BuildFQName(beatInfo.Beat, "uptime", "seconds"),
prometheus.BuildFQName(beatInfo.Beat, "uptime", "seconds_total"),
"beat.info.uptime.ms",
nil, nil,
),
Expand All @@ -117,7 +103,7 @@ func NewBeatCollector(beatInfo *BeatInfo, stats *Stats) prometheus.Collector {
},
{
desc: prometheus.NewDesc(
prometheus.BuildFQName(beatInfo.Beat, "memstats", "gc_next"),
prometheus.BuildFQName(beatInfo.Beat, "memstats", "gc_next_total"),
"beat.memstats.gc_next",
nil, nil,
),
Expand All @@ -139,7 +125,7 @@ func NewBeatCollector(beatInfo *BeatInfo, stats *Stats) prometheus.Collector {
},
{
desc: prometheus.NewDesc(
prometheus.BuildFQName(beatInfo.Beat, "memstats", "memory_total"),
prometheus.BuildFQName(beatInfo.Beat, "memstats", "memory"),
"beat.memstats.memory_total",
nil, nil,
),
Expand Down
12 changes: 6 additions & 6 deletions collector/libbeat.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func NewLibBeatCollector(beatInfo *BeatInfo, stats *Stats) prometheus.Collector
metrics: exportedMetrics{
{
desc: prometheus.NewDesc(
prometheus.BuildFQName(beatInfo.Beat, "libbeat_config", "reloads"),
prometheus.BuildFQName(beatInfo.Beat, "libbeat_config", "reloads_total"),
"libbeat.config.reloads",
nil, nil,
),
Expand Down Expand Up @@ -114,7 +114,7 @@ func NewLibBeatCollector(beatInfo *BeatInfo, stats *Stats) prometheus.Collector
},
{
desc: prometheus.NewDesc(
prometheus.BuildFQName(beatInfo.Beat, "libbeat", "output_read_bytes"),
prometheus.BuildFQName(beatInfo.Beat, "libbeat", "output_read_bytes_total"),
"libbeat.output.read.bytes",
nil, nil,
),
Expand All @@ -125,7 +125,7 @@ func NewLibBeatCollector(beatInfo *BeatInfo, stats *Stats) prometheus.Collector
},
{
desc: prometheus.NewDesc(
prometheus.BuildFQName(beatInfo.Beat, "libbeat", "output_read_errors"),
prometheus.BuildFQName(beatInfo.Beat, "libbeat", "output_read_errors_total"),
"libbeat.output.read.errors",
nil, nil,
),
Expand All @@ -136,7 +136,7 @@ func NewLibBeatCollector(beatInfo *BeatInfo, stats *Stats) prometheus.Collector
},
{
desc: prometheus.NewDesc(
prometheus.BuildFQName(beatInfo.Beat, "libbeat", "output_write_bytes"),
prometheus.BuildFQName(beatInfo.Beat, "libbeat", "output_write_bytes_total"),
"libbeat.output.write.bytes",
nil, nil,
),
Expand All @@ -147,7 +147,7 @@ func NewLibBeatCollector(beatInfo *BeatInfo, stats *Stats) prometheus.Collector
},
{
desc: prometheus.NewDesc(
prometheus.BuildFQName(beatInfo.Beat, "libbeat", "output_write_errors"),
prometheus.BuildFQName(beatInfo.Beat, "libbeat", "output_write_errors_total"),
"libbeat.output.write.errors",
nil, nil,
),
Expand Down Expand Up @@ -322,7 +322,7 @@ func (c *libbeatCollector) Describe(ch chan<- *prometheus.Desc) {
}

libbeatOutputType = prometheus.NewDesc(
prometheus.BuildFQName(c.beatInfo.Beat, "libbeat", "output"),
prometheus.BuildFQName(c.beatInfo.Beat, "libbeat", "output_total"),
"libbeat.output.type",
[]string{"type"}, nil,
)
Expand Down
2 changes: 1 addition & 1 deletion collector/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func NewSystemCollector(beatInfo *BeatInfo, stats *Stats) prometheus.Collector {
metrics: exportedMetrics{
{
desc: prometheus.NewDesc(
prometheus.BuildFQName(beatInfo.Beat, "system_cpu", "cores"),
prometheus.BuildFQName(beatInfo.Beat, "system_cpu", "cores_total"),
"cpu cores",
nil, nil,
),
Expand Down

0 comments on commit 067e112

Please sign in to comment.