mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
Adding new metric type to track in-flight remote read queries. (#4677)
Signed-off-by: tariqibrahim <tariq.ibrahim@microsoft.com>
This commit is contained in:
parent
468e49417c
commit
3f7ed7de49
|
@ -16,14 +16,30 @@ package remote
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
"github.com/prometheus/common/model"
|
"github.com/prometheus/common/model"
|
||||||
"github.com/prometheus/prometheus/pkg/labels"
|
"github.com/prometheus/prometheus/pkg/labels"
|
||||||
"github.com/prometheus/prometheus/storage"
|
"github.com/prometheus/prometheus/storage"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var remoteReadQueries = prometheus.NewGaugeVec(
|
||||||
|
prometheus.GaugeOpts{
|
||||||
|
Namespace: namespace,
|
||||||
|
Subsystem: subsystem,
|
||||||
|
Name: "remote_read_queries",
|
||||||
|
Help: "The number of in-flight remote read queries.",
|
||||||
|
},
|
||||||
|
[]string{"client"},
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
prometheus.MustRegister(remoteReadQueries)
|
||||||
|
}
|
||||||
|
|
||||||
// QueryableClient returns a storage.Queryable which queries the given
|
// QueryableClient returns a storage.Queryable which queries the given
|
||||||
// Client to select series sets.
|
// Client to select series sets.
|
||||||
func QueryableClient(c *Client) storage.Queryable {
|
func QueryableClient(c *Client) storage.Queryable {
|
||||||
|
remoteReadQueries.WithLabelValues(c.Name())
|
||||||
return storage.QueryableFunc(func(ctx context.Context, mint, maxt int64) (storage.Querier, error) {
|
return storage.QueryableFunc(func(ctx context.Context, mint, maxt int64) (storage.Querier, error) {
|
||||||
return &querier{
|
return &querier{
|
||||||
ctx: ctx,
|
ctx: ctx,
|
||||||
|
@ -49,6 +65,10 @@ func (q *querier) Select(p *storage.SelectParams, matchers ...*labels.Matcher) (
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
remoteReadGauge := remoteReadQueries.WithLabelValues(q.client.Name())
|
||||||
|
remoteReadGauge.Inc()
|
||||||
|
defer remoteReadGauge.Dec()
|
||||||
|
|
||||||
res, err := q.client.Read(q.ctx, query)
|
res, err := q.client.Read(q.ctx, query)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
Loading…
Reference in a new issue