Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed registrar stats for beats >= 6.3 #3

Merged
merged 1 commit into from
Sep 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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