|
|
@ -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 |
|
|
|