@@ -106,6 +106,26 @@ func GetDruidDataSourcesTotalRows(pathURL string) DataSourcesTotalRows {
106
106
return datasources
107
107
}
108
108
109
+ // GetDruidTasksStatusCount returns count of different tasks by status
110
+ func GetDruidTasksStatusCount (pathURL string ) TaskStatusMetric {
111
+ kingpin .Parse ()
112
+ druidURL := * druid + pathURL
113
+ responseData , err := utils .GetResponse (druidURL , pathURL )
114
+ if err != nil {
115
+ logrus .Errorf ("Cannot retrieve data for druid's workers: %v" , err )
116
+ return nil
117
+ }
118
+ logrus .Debugf ("Successfully retrieved the data for druid task: %v" , pathURL )
119
+ var taskCount TaskStatusMetric
120
+ err = json .Unmarshal (responseData , & taskCount )
121
+ if err != nil {
122
+ logrus .Errorf ("Cannot parse JSON data: %v" , err )
123
+ return nil
124
+ }
125
+ logrus .Debugf ("Successfully collected tasks status count: %v" , pathURL )
126
+ return taskCount
127
+ }
128
+
109
129
// getDruidWorkersData return all the workers and its state
110
130
func getDruidWorkersData (pathURL string ) []worker {
111
131
kingpin .Parse ()
@@ -137,6 +157,10 @@ func (collector *MetricCollector) Describe(ch chan<- *prometheus.Desc) {
137
157
ch <- collector .DruidWorkers
138
158
ch <- collector .DruidTasks
139
159
ch <- collector .DruidSegmentReplicateSize
160
+ ch <- collector .DruidRunningTasks
161
+ ch <- collector .DruidWaitingTasks
162
+ ch <- collector .DruidCompletedTasks
163
+ ch <- collector .DruidPendingTasks
140
164
}
141
165
142
166
// Collector return the defined metrics
@@ -179,6 +203,22 @@ func Collector() *MetricCollector {
179
203
DruidDataSourcesTotalRows : prometheus .NewDesc ("druid_datasource_total_rows" ,
180
204
"Number of rows in a datasource" ,
181
205
[]string {"datasource_name" , "source" }, nil ),
206
+ DruidRunningTasks : prometheus .NewDesc ("druid_running_tasks" ,
207
+ "Druid running tasks count" ,
208
+ nil , nil ,
209
+ ),
210
+ DruidWaitingTasks : prometheus .NewDesc ("druid_waiting_tasks" ,
211
+ "Druid waiting tasks count" ,
212
+ nil , nil ,
213
+ ),
214
+ DruidCompletedTasks : prometheus .NewDesc ("druid_completed_tasks" ,
215
+ "Druid completed tasks count" ,
216
+ nil , nil ,
217
+ ),
218
+ DruidPendingTasks : prometheus .NewDesc ("druid_pending_tasks" ,
219
+ "Druid pending tasks count" ,
220
+ nil , nil ,
221
+ ),
182
222
}
183
223
}
184
224
@@ -203,6 +243,15 @@ func (collector *MetricCollector) Collect(ch chan<- prometheus.Metric) {
203
243
}
204
244
}
205
245
246
+ ch <- prometheus .MustNewConstMetric (collector .DruidRunningTasks ,
247
+ prometheus .GaugeValue , float64 (len (GetDruidTasksStatusCount (runningTask ))))
248
+ ch <- prometheus .MustNewConstMetric (collector .DruidWaitingTasks ,
249
+ prometheus .GaugeValue , float64 (len (GetDruidTasksStatusCount (waitingTask ))))
250
+ ch <- prometheus .MustNewConstMetric (collector .DruidCompletedTasks ,
251
+ prometheus .GaugeValue , float64 (len (GetDruidTasksStatusCount (completedTask ))))
252
+ ch <- prometheus .MustNewConstMetric (collector .DruidPendingTasks ,
253
+ prometheus .GaugeValue , float64 (len (GetDruidTasksStatusCount (pendingTask ))))
254
+
206
255
workers := getDruidWorkersData (workersURL )
207
256
208
257
for _ , worker := range workers {
0 commit comments