Skip to content
This repository was archived by the owner on Apr 4, 2025. It is now read-only.

Commit 67af338

Browse files
authored
Merge pull request #3 from anandsinghkunwar/master
Fixed registrar stats for beats >= 6.3
2 parents 090f990 + 59b0466 commit 67af338

File tree

3 files changed

+28
-6
lines changed

3 files changed

+28
-6
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.1.0
1+
0.1.1

collector/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ func (b *mainCollector) Collect(ch chan<- prometheus.Metric) {
9292
err := b.fetchStatsEndpoint()
9393
if err != nil {
9494
ch <- prometheus.MustNewConstMetric(b.targetUp, prometheus.GaugeValue, float64(0)) // set target down
95-
log.Errorf("Failed getting /stats endpoint of target")
95+
log.Errorf("Failed getting /stats endpoint of target: " + err.Error())
9696
return
9797
}
9898

collector/registrar.go

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@ import (
66

77
//Registrar json structure
88
type Registrar struct {
9-
Writes float64 `json:"writes"`
9+
Writes struct {
10+
Fail float64 `json:"fail"`
11+
Success float64 `json:"success"`
12+
Total float64 `json:"total"`
13+
} `json:"writes"`
1014
States struct {
1115
Cleanup float64 `json:"cleanup"`
1216
Current float64 `json:"current"`
@@ -30,10 +34,28 @@ func NewRegistrarCollector(beatInfo *BeatInfo, stats *Stats) prometheus.Collecto
3034
desc: prometheus.NewDesc(
3135
prometheus.BuildFQName(beatInfo.Beat, "registrar", "writes"),
3236
"registrar.writes",
33-
nil, nil,
37+
nil, prometheus.Labels{"writes": "fail"},
3438
),
35-
eval: func(stats *Stats) float64 { return stats.Registrar.Writes },
36-
valType: prometheus.CounterValue,
39+
eval: func(stats *Stats) float64 { return stats.Registrar.Writes.Fail },
40+
valType: prometheus.GaugeValue,
41+
},
42+
{
43+
desc: prometheus.NewDesc(
44+
prometheus.BuildFQName(beatInfo.Beat, "registrar", "writes"),
45+
"registrar.writes",
46+
nil, prometheus.Labels{"writes": "success"},
47+
),
48+
eval: func(stats *Stats) float64 { return stats.Registrar.Writes.Success },
49+
valType: prometheus.GaugeValue,
50+
},
51+
{
52+
desc: prometheus.NewDesc(
53+
prometheus.BuildFQName(beatInfo.Beat, "registrar", "writes"),
54+
"registrar.writes",
55+
nil, prometheus.Labels{"writes": "total"},
56+
),
57+
eval: func(stats *Stats) float64 { return stats.Registrar.Writes.Total },
58+
valType: prometheus.GaugeValue,
3759
},
3860
{
3961
desc: prometheus.NewDesc(

0 commit comments

Comments
 (0)