mirror of https://github.com/prometheus/prometheus
Merge pull request #12251 from prymitive/query_samples_total
Add query_samples_total metricpull/12277/head
commit
f7c6130ff2
|
@ -70,6 +70,7 @@ type engineMetrics struct {
|
|||
queryPrepareTime prometheus.Observer
|
||||
queryInnerEval prometheus.Observer
|
||||
queryResultSort prometheus.Observer
|
||||
querySamples prometheus.Counter
|
||||
}
|
||||
|
||||
// convertibleToInt64 returns true if v does not over-/underflow an int64.
|
||||
|
@ -333,6 +334,12 @@ func NewEngine(opts EngineOpts) *Engine {
|
|||
Name: "queries_concurrent_max",
|
||||
Help: "The max number of concurrent queries.",
|
||||
}),
|
||||
querySamples: prometheus.NewCounter(prometheus.CounterOpts{
|
||||
Namespace: namespace,
|
||||
Subsystem: subsystem,
|
||||
Name: "query_samples_total",
|
||||
Help: "The total number of samples loaded by all queries.",
|
||||
}),
|
||||
queryQueueTime: queryResultSummary.WithLabelValues("queue_time"),
|
||||
queryPrepareTime: queryResultSummary.WithLabelValues("prepare_time"),
|
||||
queryInnerEval: queryResultSummary.WithLabelValues("inner_eval"),
|
||||
|
@ -358,6 +365,7 @@ func NewEngine(opts EngineOpts) *Engine {
|
|||
metrics.maxConcurrentQueries,
|
||||
metrics.queryLogEnabled,
|
||||
metrics.queryLogFailures,
|
||||
metrics.querySamples,
|
||||
queryResultSummary,
|
||||
)
|
||||
}
|
||||
|
@ -538,7 +546,10 @@ func (ng *Engine) newTestQuery(f func(context.Context) error) Query {
|
|||
// statements are not handled by the Engine.
|
||||
func (ng *Engine) exec(ctx context.Context, q *query) (v parser.Value, ws storage.Warnings, err error) {
|
||||
ng.metrics.currentQueries.Inc()
|
||||
defer ng.metrics.currentQueries.Dec()
|
||||
defer func() {
|
||||
ng.metrics.currentQueries.Dec()
|
||||
ng.metrics.querySamples.Add(float64(q.sampleStats.TotalSamples))
|
||||
}()
|
||||
|
||||
ctx, cancel := context.WithTimeout(ctx, ng.timeout)
|
||||
q.cancel = cancel
|
||||
|
|
Loading…
Reference in New Issue