Skip to content

Commit

Permalink
Merge pull request #3 from monitoring-tools/cluster_label_to_tasks_me…
Browse files Browse the repository at this point in the history
…tric

Renaming "tasks" metric to "task_group_duration_seconds" + new "cluster" label
  • Loading branch information
d-ulyanov authored Feb 5, 2020
2 parents 4696d85 + 36dac73 commit f845abb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# Changelog
All notable changes to this project will be documented in this file.

## [1.2.2] - 2020-01-05
### Changed
- Metric "tasks" was renamed to "task_group_duration_seconds".
### Added
- Label "cluster" to "task_group_duration_seconds" metric.

## [1.2.1] - 2019-12-24
### Added
- Nodes and indices requests cache hit and miss count
Expand Down
12 changes: 6 additions & 6 deletions collector/tasks/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@ import (
"strings"
"time"

"github.com/prometheus/client_golang/prometheus"
"github.com/monitoring-tools/prom-elasticsearch-exporter/elasticsearch"
"github.com/monitoring-tools/prom-elasticsearch-exporter/metrics"
"github.com/prometheus/client_golang/prometheus"
)

// Labels lists for different kind of metrics
var (
labelsTasks = []string{"action", "node"}
labelsTasks = []string{"action", "node", "cluster"}
)

// Label values extractors for different kind of metrics
var (
labelValuesTasks = func(action string, host string) []string {
return []string{action, host}
labelValuesTasks = func(action, host, cluster string) []string {
return []string{action, host, cluster}
}
)

Expand Down Expand Up @@ -51,7 +51,7 @@ func NewCollector(esClient elasticsearch.Client) *Collector {
return &Collector{
esClient: esClient,
taskMetric: newTaskMetric(
prometheus.GaugeValue, "tasks", "Task running time in seconds`",
prometheus.GaugeValue, "task_group_duration_seconds", "Task group running duration in seconds",
func(t float64) float64 { return t },
),
maxTasks: make(map[string]max),
Expand Down Expand Up @@ -97,7 +97,7 @@ func (c *Collector) Collect(clusterName string, ch chan<- prometheus.Metric) {
c.taskMetric.Desc(),
c.taskMetric.Type(),
c.taskMetric.Value(max.time),
labelValuesTasks(task.Action, task.Node)...,
labelValuesTasks(task.Action, task.Node, clusterName)...,
)
}
}

0 comments on commit f845abb

Please sign in to comment.