@@ -30,6 +30,7 @@ func Initialize(c context.Context, DBFunc func() *gorp.DbMap, instance string) {
30
30
nbWorkflowRuns := prometheus .NewCounter (prometheus.CounterOpts {Name : "nb_workflow_runs" , Help : "metrics nb_workflow_runs" , ConstLabels : labels })
31
31
nbWorkflowNodeRuns := prometheus .NewCounter (prometheus.CounterOpts {Name : "nb_workflow_node_runs" , Help : "metrics nb_workflow_node_runs" , ConstLabels : labels })
32
32
nbMaxWorkersBuilding := prometheus .NewCounter (prometheus.CounterOpts {Name : "nb_max_workers_building" , Help : "metrics nb_max_workers_building" , ConstLabels : labels })
33
+ nbJobs := prometheus .NewCounter (prometheus.CounterOpts {Name : "nb_jobs" , Help : "nb_jobs" , ConstLabels : labels })
33
34
queue := prometheus .NewGaugeVec (prometheus.GaugeOpts {Name : "queue" , Help : "metrics queue" , ConstLabels : prometheus.Labels {"instance" : instance }}, []string {"status" , "range" })
34
35
35
36
registry .MustRegister (nbUsers )
@@ -43,9 +44,10 @@ func Initialize(c context.Context, DBFunc func() *gorp.DbMap, instance string) {
43
44
registry .MustRegister (nbWorkflowRuns )
44
45
registry .MustRegister (nbWorkflowNodeRuns )
45
46
registry .MustRegister (nbMaxWorkersBuilding )
47
+ registry .MustRegister (nbJobs )
46
48
registry .MustRegister (queue )
47
49
48
- tick := time .NewTicker (30 * time .Second ).C
50
+ tick := time .NewTicker (9 * time .Second ).C
49
51
50
52
go func (c context.Context , DBFunc func () * gorp.DbMap ) {
51
53
for {
@@ -67,6 +69,7 @@ func Initialize(c context.Context, DBFunc func() *gorp.DbMap, instance string) {
67
69
count (DBFunc (), nbWorkflowRuns , "SELECT MAX(id) FROM workflow_run" )
68
70
count (DBFunc (), nbWorkflowNodeRuns , "SELECT MAX(id) FROM workflow_node_run" )
69
71
count (DBFunc (), nbMaxWorkersBuilding , "SELECT COUNT(1) FROM worker where status = 'Building'" )
72
+ count (DBFunc (), nbJobs , "SELECT MAX(id) FROM workflow_node_run_job_info" )
70
73
71
74
now := time .Now ()
72
75
now10s := now .Add (- 10 * time .Second )
@@ -81,13 +84,13 @@ func Initialize(c context.Context, DBFunc func() *gorp.DbMap, instance string) {
81
84
queryOld := "select COUNT(1) from workflow_node_run_job where queued < $1 and status = 'Waiting'"
82
85
83
86
countGauge (DBFunc (), * queue , "building" , "all" , queryBuilding )
84
- countGauge (DBFunc (), * queue , "waiting" , "less_10s " , query , now10s , now )
85
- countGauge (DBFunc (), * queue , "waiting" , "more_10s_less_30s " , query , now30s , now10s )
86
- countGauge (DBFunc (), * queue , "waiting" , "more_30s_less_1min " , query , now1min , now30s )
87
- countGauge (DBFunc (), * queue , "waiting" , "more_1min_less_2min " , query , now2min , now1min )
88
- countGauge (DBFunc (), * queue , "waiting" , "more_2min_less_5min " , query , now5min , now2min )
89
- countGauge (DBFunc (), * queue , "waiting" , "more_5min_less_10min " , query , now10min , now5min )
90
- countGauge (DBFunc (), * queue , "waiting" , "more_10min " , queryOld , now10min )
87
+ countGauge (DBFunc (), * queue , "waiting" , "10_less_10s " , query , now10s , now )
88
+ countGauge (DBFunc (), * queue , "waiting" , "20_more_10s_less_30s " , query , now30s , now10s )
89
+ countGauge (DBFunc (), * queue , "waiting" , "30_more_30s_less_1min " , query , now1min , now30s )
90
+ countGauge (DBFunc (), * queue , "waiting" , "40_more_1min_less_2min " , query , now2min , now1min )
91
+ countGauge (DBFunc (), * queue , "waiting" , "50_more_2min_less_5min " , query , now5min , now2min )
92
+ countGauge (DBFunc (), * queue , "waiting" , "60_more_5min_less_10min " , query , now10min , now5min )
93
+ countGauge (DBFunc (), * queue , "waiting" , "70_more_10min " , queryOld , now10min )
91
94
}
92
95
}
93
96
}(c , DBFunc )
0 commit comments