Browse Source

refactoring: make sure that query_duration_seconds metrics are the same (#7668)

* refactoring: make sure that query_duration_seconds are the same

Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>
pull/7624/head
Julien Pivotto 4 years ago committed by GitHub
parent
commit
22acb87e09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 59
      promql/engine.go

59
promql/engine.go

@ -60,10 +60,10 @@ type engineMetrics struct {
maxConcurrentQueries prometheus.Gauge maxConcurrentQueries prometheus.Gauge
queryLogEnabled prometheus.Gauge queryLogEnabled prometheus.Gauge
queryLogFailures prometheus.Counter queryLogFailures prometheus.Counter
queryQueueTime prometheus.Summary queryQueueTime prometheus.Observer
queryPrepareTime prometheus.Summary queryPrepareTime prometheus.Observer
queryInnerEval prometheus.Summary queryInnerEval prometheus.Observer
queryResultSort prometheus.Summary queryResultSort prometheus.Observer
} }
// convertibleToInt64 returns true if v does not over-/underflow an int64. // convertibleToInt64 returns true if v does not over-/underflow an int64.
@ -230,6 +230,16 @@ func NewEngine(opts EngineOpts) *Engine {
opts.Logger = log.NewNopLogger() opts.Logger = log.NewNopLogger()
} }
queryResultSummary := prometheus.NewSummaryVec(prometheus.SummaryOpts{
Namespace: namespace,
Subsystem: subsystem,
Name: "query_duration_seconds",
Help: "Query timings",
Objectives: map[float64]float64{0.5: 0.05, 0.9: 0.01, 0.99: 0.001},
},
[]string{"slice"},
)
metrics := &engineMetrics{ metrics := &engineMetrics{
currentQueries: prometheus.NewGauge(prometheus.GaugeOpts{ currentQueries: prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: namespace, Namespace: namespace,
@ -255,38 +265,10 @@ func NewEngine(opts EngineOpts) *Engine {
Name: "queries_concurrent_max", Name: "queries_concurrent_max",
Help: "The max number of concurrent queries.", Help: "The max number of concurrent queries.",
}), }),
queryQueueTime: prometheus.NewSummary(prometheus.SummaryOpts{ queryQueueTime: queryResultSummary.WithLabelValues("queue_time"),
Namespace: namespace, queryPrepareTime: queryResultSummary.WithLabelValues("prepare_time"),
Subsystem: subsystem, queryInnerEval: queryResultSummary.WithLabelValues("inner_eval"),
Name: "query_duration_seconds", queryResultSort: queryResultSummary.WithLabelValues("result_sort"),
Help: "Query timings",
ConstLabels: prometheus.Labels{"slice": "queue_time"},
Objectives: map[float64]float64{0.5: 0.05, 0.9: 0.01, 0.99: 0.001},
}),
queryPrepareTime: prometheus.NewSummary(prometheus.SummaryOpts{
Namespace: namespace,
Subsystem: subsystem,
Name: "query_duration_seconds",
Help: "Query timings",
ConstLabels: prometheus.Labels{"slice": "prepare_time"},
Objectives: map[float64]float64{0.5: 0.05, 0.9: 0.01, 0.99: 0.001},
}),
queryInnerEval: prometheus.NewSummary(prometheus.SummaryOpts{
Namespace: namespace,
Subsystem: subsystem,
Name: "query_duration_seconds",
Help: "Query timings",
ConstLabels: prometheus.Labels{"slice": "inner_eval"},
Objectives: map[float64]float64{0.5: 0.05, 0.9: 0.01, 0.99: 0.001},
}),
queryResultSort: prometheus.NewSummary(prometheus.SummaryOpts{
Namespace: namespace,
Subsystem: subsystem,
Name: "query_duration_seconds",
Help: "Query timings",
ConstLabels: prometheus.Labels{"slice": "result_sort"},
Objectives: map[float64]float64{0.5: 0.05, 0.9: 0.01, 0.99: 0.001},
}),
} }
if t := opts.ActiveQueryTracker; t != nil { if t := opts.ActiveQueryTracker; t != nil {
@ -308,10 +290,7 @@ func NewEngine(opts EngineOpts) *Engine {
metrics.maxConcurrentQueries, metrics.maxConcurrentQueries,
metrics.queryLogEnabled, metrics.queryLogEnabled,
metrics.queryLogFailures, metrics.queryLogFailures,
metrics.queryQueueTime, queryResultSummary,
metrics.queryPrepareTime,
metrics.queryInnerEval,
metrics.queryResultSort,
) )
} }

Loading…
Cancel
Save