mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-24 05:04:05 -08:00
added the prometheus_remote_storage_remote_read_queries_total (#7328)
* added the prometheus_remote_storage_remote_read_queries_total query Signed-off-by: njingco <jingco.nicole@gmail.com> * adjusted the help label of remoteReadQueriesTotal Signed-off-by: njingco <jingco.nicole@gmail.com>
This commit is contained in:
parent
18d9ebf0ff
commit
5e9bd17b1f
|
@ -32,14 +32,27 @@ var remoteReadQueries = prometheus.NewGaugeVec(
|
|||
[]string{remoteName, endpoint},
|
||||
)
|
||||
|
||||
var remoteReadQueriesTotal = prometheus.NewCounterVec(
|
||||
prometheus.CounterOpts{
|
||||
Namespace: namespace,
|
||||
Subsystem: subsystem,
|
||||
Name: "remote_read_queries_total",
|
||||
Help: "The total number of remote read queries.",
|
||||
},
|
||||
[]string{remoteName, endpoint},
|
||||
)
|
||||
|
||||
func init() {
|
||||
prometheus.MustRegister(remoteReadQueries)
|
||||
prometheus.MustRegister(remoteReadQueriesTotal)
|
||||
}
|
||||
|
||||
// QueryableClient returns a storage.Queryable which queries the given
|
||||
// Client to select series sets.
|
||||
func QueryableClient(c *Client) storage.Queryable {
|
||||
remoteReadQueries.WithLabelValues(c.remoteName, c.url.String())
|
||||
remoteReadQueriesTotal.WithLabelValues(c.remoteName, c.url.String())
|
||||
|
||||
return storage.QueryableFunc(func(ctx context.Context, mint, maxt int64) (storage.Querier, error) {
|
||||
return &querier{
|
||||
ctx: ctx,
|
||||
|
@ -68,6 +81,9 @@ func (q *querier) Select(sortSeries bool, hints *storage.SelectHints, matchers .
|
|||
remoteReadGauge.Inc()
|
||||
defer remoteReadGauge.Dec()
|
||||
|
||||
remoteReadTotalCounter := remoteReadQueriesTotal.WithLabelValues(q.client.remoteName, q.client.url.String())
|
||||
remoteReadTotalCounter.Inc()
|
||||
|
||||
res, err := q.client.Read(q.ctx, query)
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("remote_read: %v", err)
|
||||
|
|
Loading…
Reference in a new issue