Skip to content

Commit

Permalink
fix(main): get runner status instead of status
Browse files Browse the repository at this point in the history
  • Loading branch information
capuche2412 committed Dec 5, 2023
1 parent bb45897 commit dc6b26c
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@ var (
)

type Task struct {
Type string
Status string
RunnerStatus string
Total int
Type string
Runner_Status string
Total int
}

type DruidTasksExporter struct {
Expand All @@ -34,15 +33,15 @@ func NewDruidTasksExporter() *DruidTasksExporter {
Tasks: prometheus.NewDesc(
"dte_druid_tasks_total",
"Total number of Druid tasks per type and status.",
[]string{"type", "status", "runner_status"},
[]string{"type", "runner_status"},
prometheus.Labels{},
)}
}

func (d *DruidTasksExporter) RetrieveMetrics() []Task {

query, _ := json.Marshal(map[string]string{
"query": "SELECT type,status,count(*) AS total FROM sys.tasks GROUP BY status,type",
"query": "SELECT type,runner_status,count(*) AS total FROM sys.tasks GROUP BY type,runner_status",
})

reqBody := bytes.NewBuffer(query)
Expand All @@ -62,7 +61,7 @@ func (d *DruidTasksExporter) RetrieveMetrics() []Task {
if err != nil {
log.Fatalf("An Error occured while unmarshalling %s: %v", body, err)
}

fmt.Println(tasks)
return tasks
}

Expand All @@ -78,8 +77,7 @@ func (d *DruidTasksExporter) Collect(ch chan<- prometheus.Metric) {
prometheus.GaugeValue,
float64(task.Total),
task.Type,
task.Status,
task.Status,
task.Runner_Status,
)
}
}
Expand All @@ -97,7 +95,6 @@ func main() {

druid := NewDruidTasksExporter()
reg := prometheus.NewPedanticRegistry()

reg.MustRegister(druid)

http.Handle("/metrics", promhttp.HandlerFor(reg, promhttp.HandlerOpts{}))
Expand Down

0 comments on commit dc6b26c

Please sign in to comment.