Skip to content

Commit

Permalink
Merge pull request #3 from anandsinghkunwar/master
Browse files Browse the repository at this point in the history
Fixed registrar stats for beats >= 6.3
  • Loading branch information
shivas authored Sep 14, 2018
2 parents 090f990 + 59b0466 commit 67af338
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.0
0.1.1
2 changes: 1 addition & 1 deletion collector/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func (b *mainCollector) Collect(ch chan<- prometheus.Metric) {
err := b.fetchStatsEndpoint()
if err != nil {
ch <- prometheus.MustNewConstMetric(b.targetUp, prometheus.GaugeValue, float64(0)) // set target down
log.Errorf("Failed getting /stats endpoint of target")
log.Errorf("Failed getting /stats endpoint of target: " + err.Error())
return
}

Expand Down
30 changes: 26 additions & 4 deletions collector/registrar.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ import (

//Registrar json structure
type Registrar struct {
Writes float64 `json:"writes"`
Writes struct {
Fail float64 `json:"fail"`
Success float64 `json:"success"`
Total float64 `json:"total"`
} `json:"writes"`
States struct {
Cleanup float64 `json:"cleanup"`
Current float64 `json:"current"`
Expand All @@ -30,10 +34,28 @@ func NewRegistrarCollector(beatInfo *BeatInfo, stats *Stats) prometheus.Collecto
desc: prometheus.NewDesc(
prometheus.BuildFQName(beatInfo.Beat, "registrar", "writes"),
"registrar.writes",
nil, nil,
nil, prometheus.Labels{"writes": "fail"},
),
eval: func(stats *Stats) float64 { return stats.Registrar.Writes },
valType: prometheus.CounterValue,
eval: func(stats *Stats) float64 { return stats.Registrar.Writes.Fail },
valType: prometheus.GaugeValue,
},
{
desc: prometheus.NewDesc(
prometheus.BuildFQName(beatInfo.Beat, "registrar", "writes"),
"registrar.writes",
nil, prometheus.Labels{"writes": "success"},
),
eval: func(stats *Stats) float64 { return stats.Registrar.Writes.Success },
valType: prometheus.GaugeValue,
},
{
desc: prometheus.NewDesc(
prometheus.BuildFQName(beatInfo.Beat, "registrar", "writes"),
"registrar.writes",
nil, prometheus.Labels{"writes": "total"},
),
eval: func(stats *Stats) float64 { return stats.Registrar.Writes.Total },
valType: prometheus.GaugeValue,
},
{
desc: prometheus.NewDesc(
Expand Down

0 comments on commit 67af338

Please sign in to comment.