mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-23 20:37:12 +01:00
app/{vminsert,vmselect}: accept requests to paths with /graphite
and /prometheus
prefixes
This should improve compatibility with path prefixes from VictoriaMetrics cluster. See https://victoriametrics.github.io/Cluster-VictoriaMetrics.html#url-format
This commit is contained in:
parent
4d43ab0875
commit
803a00102a
@ -533,6 +533,7 @@ The `/api/v1/export` endpoint should return the following response:
|
|||||||
Extra labels may be added to all the imported time series by passing `extra_label=name=value` query args.
|
Extra labels may be added to all the imported time series by passing `extra_label=name=value` query args.
|
||||||
For example, `/api/put?extra_label=foo=bar` would add `{foo="bar"}` label to all the ingested metrics.
|
For example, `/api/put?extra_label=foo=bar` would add `{foo="bar"}` label to all the ingested metrics.
|
||||||
|
|
||||||
|
|
||||||
## Prometheus querying API usage
|
## Prometheus querying API usage
|
||||||
|
|
||||||
VictoriaMetrics supports the following handlers from [Prometheus querying API](https://prometheus.io/docs/prometheus/latest/querying/api/):
|
VictoriaMetrics supports the following handlers from [Prometheus querying API](https://prometheus.io/docs/prometheus/latest/querying/api/):
|
||||||
@ -548,6 +549,8 @@ VictoriaMetrics supports the following handlers from [Prometheus querying API](h
|
|||||||
* [/api/v1/targets](https://prometheus.io/docs/prometheus/latest/querying/api/#targets) - see [these docs](#how-to-scrape-prometheus-exporters-such-as-node-exporter) for more details.
|
* [/api/v1/targets](https://prometheus.io/docs/prometheus/latest/querying/api/#targets) - see [these docs](#how-to-scrape-prometheus-exporters-such-as-node-exporter) for more details.
|
||||||
|
|
||||||
These handlers can be queried from Prometheus-compatible clients such as Grafana or curl.
|
These handlers can be queried from Prometheus-compatible clients such as Grafana or curl.
|
||||||
|
All the Prometheus querying API handlers can be prepended with `/prometheus` prefix. For example, both `/prometheus/api/v1/query` and `/api/v1/query` should work.
|
||||||
|
|
||||||
|
|
||||||
### Prometheus querying API enhancements
|
### Prometheus querying API enhancements
|
||||||
|
|
||||||
@ -592,6 +595,8 @@ VictoriaMetrics supports the following Graphite APIs, which are needed for [Grap
|
|||||||
* Metrics API - see [these docs](#graphite-metrics-api-usage).
|
* Metrics API - see [these docs](#graphite-metrics-api-usage).
|
||||||
* Tags API - see [these docs](#graphite-tags-api-usage).
|
* Tags API - see [these docs](#graphite-tags-api-usage).
|
||||||
|
|
||||||
|
All the Graphite handlers can be pre-pended with `/graphite` prefix. For example, both `/graphite/metrics/find` and `/metrics/find` should work.
|
||||||
|
|
||||||
VictoriaMetrics supports `__graphite__` pseudo-label for filtering time series with Graphite-compatible filters in [MetricsQL](https://victoriametrics.github.io/MetricsQL.html).
|
VictoriaMetrics supports `__graphite__` pseudo-label for filtering time series with Graphite-compatible filters in [MetricsQL](https://victoriametrics.github.io/MetricsQL.html).
|
||||||
For example, `{__graphite__="foo.*.bar"}` is equivalent to `{__name__=~"foo[.][^.]*[.]bar"}`, but it works faster
|
For example, `{__graphite__="foo.*.bar"}` is equivalent to `{__name__=~"foo[.][^.]*[.]bar"}`, but it works faster
|
||||||
and it is easier to use when migrating from Graphite to VictoriaMetrics.
|
and it is easier to use when migrating from Graphite to VictoriaMetrics.
|
||||||
@ -599,8 +604,8 @@ and it is easier to use when migrating from Graphite to VictoriaMetrics.
|
|||||||
|
|
||||||
### Graphite Render API usage
|
### Graphite Render API usage
|
||||||
|
|
||||||
[VictoriaMetrics Enterprise](https://victoriametrics.com/enterprise.html) supports [Graphite Render API](https://graphite.readthedocs.io/en/stable/render_api.html) subset,
|
[VictoriaMetrics Enterprise](https://victoriametrics.com/enterprise.html) supports [Graphite Render API](https://graphite.readthedocs.io/en/stable/render_api.html) subset
|
||||||
which is needed for [Graphite datasource in Grafana](https://grafana.com/docs/grafana/latest/datasources/graphite/).
|
at `/render` endpoint. This subset is required for [Graphite datasource in Grafana](https://grafana.com/docs/grafana/latest/datasources/graphite/).
|
||||||
|
|
||||||
|
|
||||||
### Graphite Metrics API usage
|
### Graphite Metrics API usage
|
||||||
|
@ -92,7 +92,7 @@ func Stop() {
|
|||||||
func RequestHandler(w http.ResponseWriter, r *http.Request) bool {
|
func RequestHandler(w http.ResponseWriter, r *http.Request) bool {
|
||||||
path := strings.Replace(r.URL.Path, "//", "/", -1)
|
path := strings.Replace(r.URL.Path, "//", "/", -1)
|
||||||
switch path {
|
switch path {
|
||||||
case "/api/v1/write":
|
case "/prometheus/api/v1/write", "/api/v1/write":
|
||||||
prometheusWriteRequests.Inc()
|
prometheusWriteRequests.Inc()
|
||||||
if err := promremotewrite.InsertHandler(r); err != nil {
|
if err := promremotewrite.InsertHandler(r); err != nil {
|
||||||
prometheusWriteErrors.Inc()
|
prometheusWriteErrors.Inc()
|
||||||
@ -101,7 +101,7 @@ func RequestHandler(w http.ResponseWriter, r *http.Request) bool {
|
|||||||
}
|
}
|
||||||
w.WriteHeader(http.StatusNoContent)
|
w.WriteHeader(http.StatusNoContent)
|
||||||
return true
|
return true
|
||||||
case "/api/v1/import":
|
case "/prometheus/api/v1/import", "/api/v1/import":
|
||||||
vmimportRequests.Inc()
|
vmimportRequests.Inc()
|
||||||
if err := vmimport.InsertHandler(r); err != nil {
|
if err := vmimport.InsertHandler(r); err != nil {
|
||||||
vmimportErrors.Inc()
|
vmimportErrors.Inc()
|
||||||
@ -110,7 +110,7 @@ func RequestHandler(w http.ResponseWriter, r *http.Request) bool {
|
|||||||
}
|
}
|
||||||
w.WriteHeader(http.StatusNoContent)
|
w.WriteHeader(http.StatusNoContent)
|
||||||
return true
|
return true
|
||||||
case "/api/v1/import/csv":
|
case "/prometheus/api/v1/import/csv", "/api/v1/import/csv":
|
||||||
csvimportRequests.Inc()
|
csvimportRequests.Inc()
|
||||||
if err := csvimport.InsertHandler(r); err != nil {
|
if err := csvimport.InsertHandler(r); err != nil {
|
||||||
csvimportErrors.Inc()
|
csvimportErrors.Inc()
|
||||||
@ -119,7 +119,7 @@ func RequestHandler(w http.ResponseWriter, r *http.Request) bool {
|
|||||||
}
|
}
|
||||||
w.WriteHeader(http.StatusNoContent)
|
w.WriteHeader(http.StatusNoContent)
|
||||||
return true
|
return true
|
||||||
case "/api/v1/import/prometheus":
|
case "/prometheus/api/v1/import/prometheus", "/api/v1/import/prometheus":
|
||||||
prometheusimportRequests.Inc()
|
prometheusimportRequests.Inc()
|
||||||
if err := prometheusimport.InsertHandler(r); err != nil {
|
if err := prometheusimport.InsertHandler(r); err != nil {
|
||||||
prometheusimportErrors.Inc()
|
prometheusimportErrors.Inc()
|
||||||
@ -128,7 +128,7 @@ func RequestHandler(w http.ResponseWriter, r *http.Request) bool {
|
|||||||
}
|
}
|
||||||
w.WriteHeader(http.StatusNoContent)
|
w.WriteHeader(http.StatusNoContent)
|
||||||
return true
|
return true
|
||||||
case "/api/v1/import/native":
|
case "/prometheus/api/v1/import/native", "/api/v1/import/native":
|
||||||
nativeimportRequests.Inc()
|
nativeimportRequests.Inc()
|
||||||
if err := native.InsertHandler(r); err != nil {
|
if err := native.InsertHandler(r); err != nil {
|
||||||
nativeimportErrors.Inc()
|
nativeimportErrors.Inc()
|
||||||
@ -137,7 +137,7 @@ func RequestHandler(w http.ResponseWriter, r *http.Request) bool {
|
|||||||
}
|
}
|
||||||
w.WriteHeader(http.StatusNoContent)
|
w.WriteHeader(http.StatusNoContent)
|
||||||
return true
|
return true
|
||||||
case "/write", "/api/v2/write":
|
case "/influx/write", "/influx/api/v2/write", "/write", "/api/v2/write":
|
||||||
influxWriteRequests.Inc()
|
influxWriteRequests.Inc()
|
||||||
if err := influx.InsertHandlerForHTTP(r); err != nil {
|
if err := influx.InsertHandlerForHTTP(r); err != nil {
|
||||||
influxWriteErrors.Inc()
|
influxWriteErrors.Inc()
|
||||||
@ -146,23 +146,23 @@ func RequestHandler(w http.ResponseWriter, r *http.Request) bool {
|
|||||||
}
|
}
|
||||||
w.WriteHeader(http.StatusNoContent)
|
w.WriteHeader(http.StatusNoContent)
|
||||||
return true
|
return true
|
||||||
case "/query":
|
case "/influx/query", "/query":
|
||||||
// Emulate fake response for influx query.
|
// Emulate fake response for influx query.
|
||||||
// This is required for TSBS benchmark.
|
// This is required for TSBS benchmark.
|
||||||
influxQueryRequests.Inc()
|
influxQueryRequests.Inc()
|
||||||
fmt.Fprintf(w, `{"results":[{"series":[{"values":[]}]}]}`)
|
fmt.Fprintf(w, `{"results":[{"series":[{"values":[]}]}]}`)
|
||||||
return true
|
return true
|
||||||
case "/targets":
|
case "/prometheus/targets", "/targets":
|
||||||
promscrapeTargetsRequests.Inc()
|
promscrapeTargetsRequests.Inc()
|
||||||
promscrape.WriteHumanReadableTargetsStatus(w, r)
|
promscrape.WriteHumanReadableTargetsStatus(w, r)
|
||||||
return true
|
return true
|
||||||
case "/api/v1/targets":
|
case "/prometheus/api/v1/targets", "/api/v1/targets":
|
||||||
promscrapeAPIV1TargetsRequests.Inc()
|
promscrapeAPIV1TargetsRequests.Inc()
|
||||||
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
||||||
state := r.FormValue("state")
|
state := r.FormValue("state")
|
||||||
promscrape.WriteAPIV1Targets(w, state)
|
promscrape.WriteAPIV1Targets(w, state)
|
||||||
return true
|
return true
|
||||||
case "/-/reload":
|
case "/prometheus/-/reload", "/-/reload":
|
||||||
promscrapeConfigReloadRequests.Inc()
|
promscrapeConfigReloadRequests.Inc()
|
||||||
procutil.SelfSIGHUP()
|
procutil.SelfSIGHUP()
|
||||||
w.WriteHeader(http.StatusNoContent)
|
w.WriteHeader(http.StatusNoContent)
|
||||||
|
@ -23,7 +23,7 @@ var (
|
|||||||
func InsertHandler(req *http.Request) error {
|
func InsertHandler(req *http.Request) error {
|
||||||
path := req.URL.Path
|
path := req.URL.Path
|
||||||
switch path {
|
switch path {
|
||||||
case "/api/put":
|
case "/opentsdb/api/put", "/api/put":
|
||||||
extraLabels, err := parserCommon.GetExtraLabels(req)
|
extraLabels, err := parserCommon.GetExtraLabels(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -118,6 +118,16 @@ func RequestHandler(w http.ResponseWriter, r *http.Request) bool {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Strip /prometheus and /graphite prefixes in order to provide path compatibility with cluster version
|
||||||
|
//
|
||||||
|
// See https://victoriametrics.github.io/Cluster-VictoriaMetrics.html#url-format
|
||||||
|
switch {
|
||||||
|
case strings.HasPrefix(path, "/prometheus"):
|
||||||
|
path = path[len("/prometheus"):]
|
||||||
|
case strings.HasPrefix(path, "/graphite"):
|
||||||
|
path = path[len("/graphite"):]
|
||||||
|
}
|
||||||
|
|
||||||
if strings.HasPrefix(path, "/api/v1/label/") {
|
if strings.HasPrefix(path, "/api/v1/label/") {
|
||||||
s := path[len("/api/v1/label/"):]
|
s := path[len("/api/v1/label/"):]
|
||||||
if strings.HasSuffix(s, "/values") {
|
if strings.HasSuffix(s, "/values") {
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
# tip
|
# tip
|
||||||
|
|
||||||
|
* FEATURE: single-node VictoriaMetrics now accepts requests to handlers with `/prometheus` and `/graphite` prefixes such as `/prometheus/api/v1/query`. This improves compatibility with [handlers from VictoriaMetrics cluster](https://victoriametrics.github.io/Cluster-VictoriaMetrics.html#url-format).
|
||||||
* FEATURE: expose `process_open_fds` and `process_max_fds` metrics. These metrics can be used for alerting when `process_open_fds` reaches `process_max_fds`. See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/402 and https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1037
|
* FEATURE: expose `process_open_fds` and `process_max_fds` metrics. These metrics can be used for alerting when `process_open_fds` reaches `process_max_fds`. See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/402 and https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1037
|
||||||
* FEATURE: vmalert: add `-datasource.appendTypePrefix` command-line option for querying both Prometheus and Graphite datasource in cluster version of VictoriaMetrics. See [these docs](https://victoriametrics.github.io/vmalert.html#graphite) for details.
|
* FEATURE: vmalert: add `-datasource.appendTypePrefix` command-line option for querying both Prometheus and Graphite datasource in cluster version of VictoriaMetrics. See [these docs](https://victoriametrics.github.io/vmalert.html#graphite) for details.
|
||||||
|
|
||||||
|
@ -533,6 +533,7 @@ The `/api/v1/export` endpoint should return the following response:
|
|||||||
Extra labels may be added to all the imported time series by passing `extra_label=name=value` query args.
|
Extra labels may be added to all the imported time series by passing `extra_label=name=value` query args.
|
||||||
For example, `/api/put?extra_label=foo=bar` would add `{foo="bar"}` label to all the ingested metrics.
|
For example, `/api/put?extra_label=foo=bar` would add `{foo="bar"}` label to all the ingested metrics.
|
||||||
|
|
||||||
|
|
||||||
## Prometheus querying API usage
|
## Prometheus querying API usage
|
||||||
|
|
||||||
VictoriaMetrics supports the following handlers from [Prometheus querying API](https://prometheus.io/docs/prometheus/latest/querying/api/):
|
VictoriaMetrics supports the following handlers from [Prometheus querying API](https://prometheus.io/docs/prometheus/latest/querying/api/):
|
||||||
@ -548,6 +549,8 @@ VictoriaMetrics supports the following handlers from [Prometheus querying API](h
|
|||||||
* [/api/v1/targets](https://prometheus.io/docs/prometheus/latest/querying/api/#targets) - see [these docs](#how-to-scrape-prometheus-exporters-such-as-node-exporter) for more details.
|
* [/api/v1/targets](https://prometheus.io/docs/prometheus/latest/querying/api/#targets) - see [these docs](#how-to-scrape-prometheus-exporters-such-as-node-exporter) for more details.
|
||||||
|
|
||||||
These handlers can be queried from Prometheus-compatible clients such as Grafana or curl.
|
These handlers can be queried from Prometheus-compatible clients such as Grafana or curl.
|
||||||
|
All the Prometheus querying API handlers can be prepended with `/prometheus` prefix. For example, both `/prometheus/api/v1/query` and `/api/v1/query` should work.
|
||||||
|
|
||||||
|
|
||||||
### Prometheus querying API enhancements
|
### Prometheus querying API enhancements
|
||||||
|
|
||||||
@ -592,6 +595,8 @@ VictoriaMetrics supports the following Graphite APIs, which are needed for [Grap
|
|||||||
* Metrics API - see [these docs](#graphite-metrics-api-usage).
|
* Metrics API - see [these docs](#graphite-metrics-api-usage).
|
||||||
* Tags API - see [these docs](#graphite-tags-api-usage).
|
* Tags API - see [these docs](#graphite-tags-api-usage).
|
||||||
|
|
||||||
|
All the Graphite handlers can be pre-pended with `/graphite` prefix. For example, both `/graphite/metrics/find` and `/metrics/find` should work.
|
||||||
|
|
||||||
VictoriaMetrics supports `__graphite__` pseudo-label for filtering time series with Graphite-compatible filters in [MetricsQL](https://victoriametrics.github.io/MetricsQL.html).
|
VictoriaMetrics supports `__graphite__` pseudo-label for filtering time series with Graphite-compatible filters in [MetricsQL](https://victoriametrics.github.io/MetricsQL.html).
|
||||||
For example, `{__graphite__="foo.*.bar"}` is equivalent to `{__name__=~"foo[.][^.]*[.]bar"}`, but it works faster
|
For example, `{__graphite__="foo.*.bar"}` is equivalent to `{__name__=~"foo[.][^.]*[.]bar"}`, but it works faster
|
||||||
and it is easier to use when migrating from Graphite to VictoriaMetrics.
|
and it is easier to use when migrating from Graphite to VictoriaMetrics.
|
||||||
@ -599,8 +604,8 @@ and it is easier to use when migrating from Graphite to VictoriaMetrics.
|
|||||||
|
|
||||||
### Graphite Render API usage
|
### Graphite Render API usage
|
||||||
|
|
||||||
[VictoriaMetrics Enterprise](https://victoriametrics.com/enterprise.html) supports [Graphite Render API](https://graphite.readthedocs.io/en/stable/render_api.html) subset,
|
[VictoriaMetrics Enterprise](https://victoriametrics.com/enterprise.html) supports [Graphite Render API](https://graphite.readthedocs.io/en/stable/render_api.html) subset
|
||||||
which is needed for [Graphite datasource in Grafana](https://grafana.com/docs/grafana/latest/datasources/graphite/).
|
at `/render` endpoint. This subset is required for [Graphite datasource in Grafana](https://grafana.com/docs/grafana/latest/datasources/graphite/).
|
||||||
|
|
||||||
|
|
||||||
### Graphite Metrics API usage
|
### Graphite Metrics API usage
|
||||||
@ -1449,7 +1454,7 @@ The collected profiles may be analyzed with [go tool pprof](https://github.com/g
|
|||||||
* [netdata](https://github.com/netdata/netdata) can push data into VictoriaMetrics via `Prometheus remote_write API`.
|
* [netdata](https://github.com/netdata/netdata) can push data into VictoriaMetrics via `Prometheus remote_write API`.
|
||||||
See [these docs](https://github.com/netdata/netdata#integrations).
|
See [these docs](https://github.com/netdata/netdata#integrations).
|
||||||
* [go-graphite/carbonapi](https://github.com/go-graphite/carbonapi) can use VictoriaMetrics as time series backend.
|
* [go-graphite/carbonapi](https://github.com/go-graphite/carbonapi) can use VictoriaMetrics as time series backend.
|
||||||
See [this example](https://github.com/go-graphite/carbonapi/blob/master/cmd/carbonapi/carbonapi.example.prometheus.yaml).
|
See [this example](https://github.com/go-graphite/carbonapi/blob/main/cmd/carbonapi/carbonapi.example.victoriametrics.yaml).
|
||||||
* [Ansible role for installing single-node VictoriaMetrics](https://github.com/dreamteam-gg/ansible-victoriametrics-role).
|
* [Ansible role for installing single-node VictoriaMetrics](https://github.com/dreamteam-gg/ansible-victoriametrics-role).
|
||||||
* [Ansible role for installing cluster VictoriaMetrics](https://github.com/Slapper/ansible-victoriametrics-cluster-role).
|
* [Ansible role for installing cluster VictoriaMetrics](https://github.com/Slapper/ansible-victoriametrics-cluster-role).
|
||||||
* [Snap package for VictoriaMetrics](https://snapcraft.io/victoriametrics).
|
* [Snap package for VictoriaMetrics](https://snapcraft.io/victoriametrics).
|
||||||
|
Loading…
Reference in New Issue
Block a user