From e6bf88a4d4948d60b9f1b9c432db46af7001368c Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Tue, 4 Feb 2020 15:53:15 +0200 Subject: [PATCH] app/vmselect: add a placeholder for `/api/v1/metadata`, which could be requested by Grafana See https://prometheus.io/docs/prometheus/latest/querying/api/#querying-metric-metadata VictoriaMetrics doesn't collect any metadata for metrics, so just return empty response. --- app/vmselect/main.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/vmselect/main.go b/app/vmselect/main.go index 36a35d72f8..255e387ee3 100644 --- a/app/vmselect/main.go +++ b/app/vmselect/main.go @@ -263,6 +263,12 @@ func selectHandler(w http.ResponseWriter, r *http.Request, p *httpserver.Path, a w.Header().Set("Content-Type", "application/json") fmt.Fprintf(w, "%s", `{"status":"success","data":{"alerts":[]}}`) return true + case "prometheus/api/v1/metadata": + // Return dumb placeholder + metadataRequests.Inc() + w.Header().Set("Content-Type", "application/json") + fmt.Fprintf(w, "%s", `{"status":"success","data":{}}`) + return true default: return false } @@ -327,6 +333,7 @@ var ( federateRequests = metrics.NewCounter(`vm_http_requests_total{path="/select/{}/prometheus/federate"}`) federateErrors = metrics.NewCounter(`vm_http_request_errors_total{path="/select/{}/prometheus/federate"}`) - rulesRequests = metrics.NewCounter(`vm_http_requests_total{path="/select/{}/prometheus/api/v1/rules"}`) - alertsRequests = metrics.NewCounter(`vm_http_requests_total{path="/select/{}/prometheus/api/v1/alerts"}`) + rulesRequests = metrics.NewCounter(`vm_http_requests_total{path="/select/{}/prometheus/api/v1/rules"}`) + alertsRequests = metrics.NewCounter(`vm_http_requests_total{path="/select/{}/prometheus/api/v1/alerts"}`) + metadataRequests = metrics.NewCounter(`vm_http_requests_total{path="/select/{}/prometheus/api/v1/metadata"}`) )