Skip to content

Commit

Permalink
added global logstash reloads counter
Browse files Browse the repository at this point in the history
  • Loading branch information
Piotr Boruc committed Feb 28, 2019
1 parent e29b89e commit 19c8925
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 5 deletions.
8 changes: 6 additions & 2 deletions vendor/collector/nodeinfo_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ type NodeInfoResponse struct {
HTTPAddress string `json:"http_address"`
ID string `json:"id"`
Name string `json:"name"`
Pipeline struct {
Reloads struct {
Successes int `json:"successes"`
Failures int `json:"failures"`
} `json:"reloads"`
Pipeline struct {
Workers int `json:"workers"`
BatchSize int `json:"batch_size"`
BatchDelay int `json:"batch_delay"`
Expand Down Expand Up @@ -42,7 +46,7 @@ func NodeInfo(endpoint string) (NodeInfoResponse, error) {
var response NodeInfoResponse

handler := &HTTPHandler{
Endpoint: endpoint + "/_node",
Endpoint: endpoint + "/_node/stats",
}

err := getMetrics(handler, &response)
Expand Down
28 changes: 25 additions & 3 deletions vendor/collector/nodeinfo_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ import (
type NodeInfoCollector struct {
endpoint string

NodeInfos *prometheus.Desc
OsInfos *prometheus.Desc
JvmInfos *prometheus.Desc
NodeInfos *prometheus.Desc
OsInfos *prometheus.Desc
JvmInfos *prometheus.Desc
ReloadsInfos *prometheus.Desc
}

// NewNodeInfoCollector function
Expand Down Expand Up @@ -42,6 +43,13 @@ func NewNodeInfoCollector(logstashEndpoint string) (Collector, error) {
[]string{"name", "version", "vendor"},
nil,
),

ReloadsInfos: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, subsystem, "reloads"),
"Logstash reloads",
[]string{"result"},
nil,
),
}, nil
}

Expand Down Expand Up @@ -86,5 +94,19 @@ func (c *NodeInfoCollector) collect(ch chan<- prometheus.Metric) (*prometheus.De
stats.Jvm.VMVendor,
)

ch <- prometheus.MustNewConstMetric(
c.ReloadsInfos,
prometheus.CounterValue,
float64(stats.Reloads.Successes),
"success",
)

ch <- prometheus.MustNewConstMetric(
c.ReloadsInfos,
prometheus.CounterValue,
float64(stats.Reloads.Failures),
"failure",
)

return nil, nil
}

0 comments on commit 19c8925

Please sign in to comment.