Skip to content

Commit

Permalink
feat: add Datasource dimension
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas-dufour authored and capuche2412 committed Jan 14, 2025
2 parents 49c6b70 + cfdce0d commit c5f3989
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ var (
type Task struct {
Type string
Runner_Status string
Datasource string
Total int
}

Expand All @@ -33,15 +34,15 @@ 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{},
)}
}

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)
Expand Down Expand Up @@ -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})

}

Expand All @@ -97,6 +98,7 @@ func (d *DruidTasksExporter) Collect(ch chan<- prometheus.Metric) {
float64(task.Total),
task.Type,
task.Runner_Status,
task.Datasource,
)
}
}
Expand Down

0 comments on commit c5f3989

Please sign in to comment.