Skip to content

Commit f4d0e67

Browse files
sysadmindrtkkroland
authored andcommitted
Remove the useless metrics
Signed-off-by: Joe Adams <github@joeadams.io>
1 parent 25df307 commit f4d0e67

File tree

2 files changed

+0
-57
lines changed

2 files changed

+0
-57
lines changed

collector/nodes.go

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,6 @@ type Nodes struct {
174174
all bool
175175
node string
176176

177-
up prometheus.Gauge
178-
totalScrapes, jsonParseFailures prometheus.Counter
179-
180177
nodeMetrics []*nodeMetric
181178
gcCollectionMetrics []*gcCollectionMetric
182179
breakerMetrics []*breakerMetric
@@ -195,19 +192,6 @@ func NewNodes(logger log.Logger, client *http.Client, url *url.URL, all bool, no
195192
all: all,
196193
node: node,
197194

198-
up: prometheus.NewGauge(prometheus.GaugeOpts{
199-
Name: prometheus.BuildFQName(namespace, "node_stats", "up"),
200-
Help: "Was the last scrape of the Elasticsearch nodes endpoint successful.",
201-
}),
202-
totalScrapes: prometheus.NewCounter(prometheus.CounterOpts{
203-
Name: prometheus.BuildFQName(namespace, "node_stats", "total_scrapes"),
204-
Help: "Current total Elasticsearch node scrapes.",
205-
}),
206-
jsonParseFailures: prometheus.NewCounter(prometheus.CounterOpts{
207-
Name: prometheus.BuildFQName(namespace, "node_stats", "json_parse_failures"),
208-
Help: "Number of errors while parsing JSON.",
209-
}),
210-
211195
nodeMetrics: []*nodeMetric{
212196
{
213197
Type: prometheus.GaugeValue,
@@ -1869,9 +1853,6 @@ func (c *Nodes) Describe(ch chan<- *prometheus.Desc) {
18691853
for _, metric := range c.filesystemIODeviceMetrics {
18701854
ch <- metric.Desc
18711855
}
1872-
ch <- c.up.Desc()
1873-
ch <- c.totalScrapes.Desc()
1874-
ch <- c.jsonParseFailures.Desc()
18751856
}
18761857

18771858
func (c *Nodes) fetchAndDecodeNodeStats() (nodeStatsResponse, error) {
@@ -1907,36 +1888,25 @@ func (c *Nodes) fetchAndDecodeNodeStats() (nodeStatsResponse, error) {
19071888

19081889
bts, err := io.ReadAll(res.Body)
19091890
if err != nil {
1910-
c.jsonParseFailures.Inc()
19111891
return nsr, err
19121892
}
19131893

19141894
if err := json.Unmarshal(bts, &nsr); err != nil {
1915-
c.jsonParseFailures.Inc()
19161895
return nsr, err
19171896
}
19181897
return nsr, nil
19191898
}
19201899

19211900
// Collect gets nodes metric values
19221901
func (c *Nodes) Collect(ch chan<- prometheus.Metric) {
1923-
c.totalScrapes.Inc()
1924-
defer func() {
1925-
ch <- c.up
1926-
ch <- c.totalScrapes
1927-
ch <- c.jsonParseFailures
1928-
}()
1929-
19301902
nodeStatsResp, err := c.fetchAndDecodeNodeStats()
19311903
if err != nil {
1932-
c.up.Set(0)
19331904
level.Warn(c.logger).Log(
19341905
"msg", "failed to fetch and decode node stats",
19351906
"err", err,
19361907
)
19371908
return
19381909
}
1939-
c.up.Set(1)
19401910

19411911
for _, node := range nodeStatsResp.Nodes {
19421912
// Handle the node labels metric

collector/nodes_test.go

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -338,15 +338,6 @@ func TestNodesStats(t *testing.T) {
338338
# HELP elasticsearch_jvm_uptime_seconds JVM process uptime in seconds
339339
# TYPE elasticsearch_jvm_uptime_seconds gauge
340340
elasticsearch_jvm_uptime_seconds{cluster="elasticsearch",es_client_node="true",es_data_node="true",es_ingest_node="true",es_master_node="true",host="127.0.0.1",name="bVrN1Hx",type="mapped"} 14.845
341-
# HELP elasticsearch_node_stats_json_parse_failures Number of errors while parsing JSON.
342-
# TYPE elasticsearch_node_stats_json_parse_failures counter
343-
elasticsearch_node_stats_json_parse_failures 0
344-
# HELP elasticsearch_node_stats_total_scrapes Current total Elasticsearch node scrapes.
345-
# TYPE elasticsearch_node_stats_total_scrapes counter
346-
elasticsearch_node_stats_total_scrapes 1
347-
# HELP elasticsearch_node_stats_up Was the last scrape of the Elasticsearch nodes endpoint successful.
348-
# TYPE elasticsearch_node_stats_up gauge
349-
elasticsearch_node_stats_up 1
350341
# HELP elasticsearch_nodes_roles Node roles
351342
# TYPE elasticsearch_nodes_roles gauge
352343
elasticsearch_nodes_roles{cluster="elasticsearch",host="127.0.0.1",name="bVrN1Hx",role="client"} 1
@@ -806,15 +797,6 @@ func TestNodesStats(t *testing.T) {
806797
# HELP elasticsearch_jvm_uptime_seconds JVM process uptime in seconds
807798
# TYPE elasticsearch_jvm_uptime_seconds gauge
808799
elasticsearch_jvm_uptime_seconds{cluster="elasticsearch",es_client_node="true",es_data_node="true",es_ingest_node="true",es_master_node="true",host="172.17.0.2",name="9_P7yui",type="mapped"} 16.456
809-
# HELP elasticsearch_node_stats_json_parse_failures Number of errors while parsing JSON.
810-
# TYPE elasticsearch_node_stats_json_parse_failures counter
811-
elasticsearch_node_stats_json_parse_failures 0
812-
# HELP elasticsearch_node_stats_total_scrapes Current total Elasticsearch node scrapes.
813-
# TYPE elasticsearch_node_stats_total_scrapes counter
814-
elasticsearch_node_stats_total_scrapes 1
815-
# HELP elasticsearch_node_stats_up Was the last scrape of the Elasticsearch nodes endpoint successful.
816-
# TYPE elasticsearch_node_stats_up gauge
817-
elasticsearch_node_stats_up 1
818800
# HELP elasticsearch_nodes_roles Node roles
819801
# TYPE elasticsearch_nodes_roles gauge
820802
elasticsearch_nodes_roles{cluster="elasticsearch",host="172.17.0.2",name="9_P7yui",role="client"} 1
@@ -1338,15 +1320,6 @@ func TestNodesStats(t *testing.T) {
13381320
# HELP elasticsearch_jvm_uptime_seconds JVM process uptime in seconds
13391321
# TYPE elasticsearch_jvm_uptime_seconds gauge
13401322
elasticsearch_jvm_uptime_seconds{cluster="elasticsearch",es_client_node="true",es_data_node="true",es_ingest_node="true",es_master_node="true",host="172.17.0.2",name="aaf5a8a0bceb",type="mapped"} 21.844
1341-
# HELP elasticsearch_node_stats_json_parse_failures Number of errors while parsing JSON.
1342-
# TYPE elasticsearch_node_stats_json_parse_failures counter
1343-
elasticsearch_node_stats_json_parse_failures 0
1344-
# HELP elasticsearch_node_stats_total_scrapes Current total Elasticsearch node scrapes.
1345-
# TYPE elasticsearch_node_stats_total_scrapes counter
1346-
elasticsearch_node_stats_total_scrapes 1
1347-
# HELP elasticsearch_node_stats_up Was the last scrape of the Elasticsearch nodes endpoint successful.
1348-
# TYPE elasticsearch_node_stats_up gauge
1349-
elasticsearch_node_stats_up 1
13501323
# HELP elasticsearch_nodes_roles Node roles
13511324
# TYPE elasticsearch_nodes_roles gauge
13521325
elasticsearch_nodes_roles{cluster="elasticsearch",host="172.17.0.2",name="aaf5a8a0bceb",role="client"} 1

0 commit comments

Comments
 (0)