From 18ccd2c2294b0ba235a61cacd113dc6837f5d8d7 Mon Sep 17 00:00:00 2001 From: thomas-dufour <108265259+thomas-dufour@users.noreply.github.com> Date: Fri, 10 Jan 2025 18:35:20 +0100 Subject: [PATCH 1/2] feat: add Datasource dimension --- main.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index f657b2a..74cdc33 100644 --- a/main.go +++ b/main.go @@ -21,6 +21,7 @@ var ( type Task struct { Type string Runner_Status string + Datasource string Total int } @@ -33,7 +34,7 @@ func NewDruidTasksExporter() *DruidTasksExporter { Tasks: prometheus.NewDesc( "dte_druid_tasks_total", "Total number of Druid tasks per type and status.", - []string{"type", "runner_status"}, + []string{"type", "runner_status", "datasource"}, prometheus.Labels{}, )} } @@ -41,7 +42,7 @@ func NewDruidTasksExporter() *DruidTasksExporter { func (d *DruidTasksExporter) RetrieveMetrics() []Task { query, _ := json.Marshal(map[string]string{ - "query": "SELECT type,runner_status,count(*) AS total FROM sys.tasks GROUP BY type,runner_status", + "query": "SELECT type,runner_status,datasource,count(*) AS total FROM sys.tasks GROUP BY type,runner_status,datasource", }) reqBody := bytes.NewBuffer(query) @@ -84,7 +85,7 @@ func (d *DruidTasksExporter) Collect(ch chan<- prometheus.Metric) { } } if !is_present { - tasks = append(tasks, Task{Type: taskType, Runner_Status: status, Total: 0}) + tasks = append(tasks, Task{Type: taskType, Runner_Status: status, Datasource: "null", Total: 0}) } @@ -97,6 +98,7 @@ func (d *DruidTasksExporter) Collect(ch chan<- prometheus.Metric) { float64(task.Total), task.Type, task.Runner_Status, + task.Datasource ) } } From cfdce0d354195daaa3d0d8570d82f144a5a42ce6 Mon Sep 17 00:00:00 2001 From: thomas-dufour <108265259+thomas-dufour@users.noreply.github.com> Date: Fri, 10 Jan 2025 18:39:26 +0100 Subject: [PATCH 2/2] fix: add missing coma --- main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.go b/main.go index 74cdc33..b14b2f0 100644 --- a/main.go +++ b/main.go @@ -98,7 +98,7 @@ func (d *DruidTasksExporter) Collect(ch chan<- prometheus.Metric) { float64(task.Total), task.Type, task.Runner_Status, - task.Datasource + task.Datasource, ) } }