2022-02-15 14:19:55 +00:00
---
2023-10-13 11:54:33 +00:00
sort: 33
weight: 33
2023-04-30 10:31:45 +00:00
title: VictoriaMetrics API examples
menu:
docs:
2023-10-13 11:54:33 +00:00
parent: 'victoriametrics'
weight: 33
2022-02-15 14:19:55 +00:00
---
2022-02-15 19:24:49 +00:00
# VictoriaMetrics API examples
2022-02-15 14:19:55 +00:00
2023-11-07 08:54:32 +00:00
### /api/v1/admin/tsdb/delete_series
2022-02-15 14:19:55 +00:00
2022-02-15 19:24:49 +00:00
**Deletes time series from VictoriaMetrics**
2022-03-22 11:40:55 +00:00
2022-06-29 08:57:35 +00:00
Single-node VictoriaMetrics:
2022-02-22 18:08:35 +00:00
< div class = "with-copy" markdown = "1" >
2022-06-19 19:57:53 +00:00
```console
2022-06-29 08:57:35 +00:00
curl -v http://localhost:8428/api/v1/admin/tsdb/delete_series -d 'match[]=vm_http_request_errors_total'
2022-06-21 14:20:08 +00:00
```
< / div >
The expected output should return [HTTP Status 204 ](https://datatracker.ietf.org/doc/html/rfc7231#page-53 ) and will look like:
< div class = "with-copy" markdown = "1" >
```console
* Trying 127.0.0.1:8428...
* Connected to 127.0.0.1 (127.0.0.1) port 8428 (#0)
> GET /api/v1/admin/tsdb/delete_series?match[]=vm_http_request_errors_total HTTP/1.1
> Host: 127.0.0.1:8428
> User-Agent: curl/7.81.0
> Accept: */*
2022-07-11 17:18:30 +00:00
>
2022-06-21 14:20:08 +00:00
* Mark bundle as not supporting multiuse
< HTTP / 1 . 1 204 No Content
< X-Server-Hostname: eba075fb0e1a
< Date: Tue , 21 Jun 2022 07:33:35 GMT
2022-07-11 17:18:30 +00:00
<
2022-06-21 14:20:08 +00:00
* Connection #0 to host 127.0.0.1 left intact
2022-02-15 14:19:55 +00:00
```
2022-02-22 18:08:35 +00:00
< / div >
2022-06-29 08:57:35 +00:00
Cluster version of VictoriaMetrics:
2022-02-22 18:08:35 +00:00
< div class = "with-copy" markdown = "1" >
2022-06-19 19:57:53 +00:00
```console
2022-06-29 08:57:35 +00:00
curl -v http://< vmselect > :8481/delete/0/prometheus/api/v1/admin/tsdb/delete_series -d 'match[]=vm_http_request_errors_total'
2022-06-21 14:20:08 +00:00
```
< / div >
The expected output should return [HTTP Status 204 ](https://datatracker.ietf.org/doc/html/rfc7231#page-53 ) and will look like:
< div class = "with-copy" markdown = "1" >
```console
* Trying 127.0.0.1:8481...
* Connected to 127.0.0.1 (127.0.0.1) port 8481 (#0)
> GET /delete/0/prometheus/api/v1/admin/tsdb/delete_series?match[]=vm_http_request_errors_total HTTP/1.1
> Host: 127.0.0.1:8481
> User-Agent: curl/7.81.0
> Accept: */*
2022-07-11 17:18:30 +00:00
>
2022-06-21 14:20:08 +00:00
* Mark bundle as not supporting multiuse
< HTTP / 1 . 1 204 No Content
< X-Server-Hostname: 101ed7a45c94
< Date: Tue , 21 Jun 2022 07:21:36 GMT
2022-07-11 17:18:30 +00:00
<
2022-06-21 14:20:08 +00:00
* Connection #0 to host 127.0.0.1 left intact
2022-02-15 14:19:55 +00:00
```
2022-02-22 18:08:35 +00:00
< / div >
2022-02-15 14:19:55 +00:00
Additional information:
2022-03-22 11:40:55 +00:00
* [How to delete time series ](https://docs.victoriametrics.com/#how-to-delete-time-series )
2022-06-29 08:57:35 +00:00
* [URL format for VictoriaMetrics cluster ](https://docs.victoriametrics.com/Cluster-VictoriaMetrics.html#url-format )
2022-02-15 14:19:55 +00:00
2023-11-07 08:54:32 +00:00
### /api/v1/export
2022-02-15 14:19:55 +00:00
2022-06-29 08:57:35 +00:00
**Exports raw samples from VictoriaMetrics in JSON line format**
2022-03-22 11:40:55 +00:00
2022-06-29 08:57:35 +00:00
Single-node VictoriaMetrics:
2022-02-22 18:08:35 +00:00
< div class = "with-copy" markdown = "1" >
2022-06-19 19:57:53 +00:00
```console
2022-06-29 08:57:35 +00:00
curl http://localhost:8428/api/v1/export -d 'match[]=vm_http_request_errors_total' > filename.json
2022-02-15 14:19:55 +00:00
```
2022-02-22 18:08:35 +00:00
< / div >
2022-03-22 11:40:55 +00:00
2022-06-29 08:57:35 +00:00
Cluster version of VictoriaMetrics:
2022-02-22 18:08:35 +00:00
< div class = "with-copy" markdown = "1" >
2022-06-19 19:57:53 +00:00
```console
2022-06-29 08:57:35 +00:00
curl http://< vmselect > :8481/select/0/prometheus/api/v1/export -d 'match[]=vm_http_request_errors_total' > filename.json
2022-02-15 14:19:55 +00:00
```
2022-02-22 18:08:35 +00:00
< / div >
2022-03-22 11:40:55 +00:00
Additional information:
2022-06-29 08:57:35 +00:00
* [How to export time series ](https://docs.victoriametrics.com/#how-to-export-time-series )
* [How to import time series ](https://docs.victoriametrics.com/#how-to-import-time-series-data )
2022-09-05 14:25:05 +00:00
* [How to export data in JSON line format ](https://docs.victoriametrics.com/#how-to-export-data-in-json-line-format )
2022-06-29 08:57:35 +00:00
* [URL format for VictoriaMetrics cluster ](https://docs.victoriametrics.com/Cluster-VictoriaMetrics.html#url-format )
2022-02-15 14:19:55 +00:00
2023-11-07 08:54:32 +00:00
### /api/v1/export/csv
2022-06-29 08:57:35 +00:00
**Exports raw samples from VictoriaMetrics in CSV format**
2022-02-15 14:19:55 +00:00
2022-06-29 08:57:35 +00:00
Single-node VictoriaMetrics:
2022-02-22 18:08:35 +00:00
< div class = "with-copy" markdown = "1" >
2022-06-19 19:57:53 +00:00
```console
2022-06-29 08:57:35 +00:00
curl http://localhost:8428/api/v1/export/csv -d 'format=__name__,__value__,__timestamp__:unix_s' -d 'match[]=vm_http_request_errors_total' > filename.csv
2022-02-15 14:19:55 +00:00
```
2022-02-22 18:08:35 +00:00
< / div >
2022-06-29 08:57:35 +00:00
Cluster version of VictoriaMetrics:
2022-02-22 18:08:35 +00:00
< div class = "with-copy" markdown = "1" >
2022-06-19 19:57:53 +00:00
```console
2022-06-29 08:57:35 +00:00
curl http://< vmselect > :8481/select/0/prometheus/api/v1/export/csv -d 'format=__name__,__value__,__timestamp__:unix_s' -d 'match[]=vm_http_request_errors_total' > filename.csv
2022-02-15 14:19:55 +00:00
```
2022-02-22 18:08:35 +00:00
< / div >
2022-06-29 08:57:35 +00:00
Additional information:
2022-02-15 19:24:49 +00:00
2022-06-29 08:57:35 +00:00
* [How to export time series ](https://docs.victoriametrics.com/#how-to-export-time-series )
* [How to import time series ](https://docs.victoriametrics.com/#how-to-import-time-series-data )
* [URL format for VictoriaMetrics cluster ](https://docs.victoriametrics.com/Cluster-VictoriaMetrics.html#url-format )
2022-02-15 19:24:49 +00:00
2023-11-07 08:54:32 +00:00
### /api/v1/export/native
2022-02-15 19:24:49 +00:00
2022-06-29 08:57:35 +00:00
**Exports raw samples from VictoriaMetrics in native format**
2022-02-15 19:24:49 +00:00
2022-06-29 08:57:35 +00:00
Single-node VictoriaMetrics:
2022-02-22 18:08:35 +00:00
< div class = "with-copy" markdown = "1" >
2022-06-19 19:57:53 +00:00
```console
2022-06-29 08:57:35 +00:00
curl http://localhost:8428/api/v1/export/native -d 'match[]=vm_http_request_errors_total' > filename.bin
2022-02-15 19:24:49 +00:00
```
2022-02-15 14:19:55 +00:00
2022-02-22 18:08:35 +00:00
< / div >
2022-06-29 08:57:35 +00:00
Cluster version of VictoriaMetrics:
2022-02-22 18:08:35 +00:00
< div class = "with-copy" markdown = "1" >
2022-06-19 19:57:53 +00:00
```console
2022-06-29 08:57:35 +00:00
curl http://< vmselect > :8481/select/0/prometheus/api/v1/export/native -d 'match[]=vm_http_request_errors_total' > filename.bin
2022-02-15 19:24:49 +00:00
```
2022-02-22 18:08:35 +00:00
< / div >
2022-06-29 08:57:35 +00:00
More information:
* [How to export time series ](https://docs.victoriametrics.com/#how-to-export-time-series )
* [How to import time series ](https://docs.victoriametrics.com/#how-to-import-time-series-data )
* [URL format for VictoriaMetrics cluster ](https://docs.victoriametrics.com/Cluster-VictoriaMetrics.html#url-format )
2023-11-07 08:54:32 +00:00
### /api/v1/import
2022-06-29 08:57:35 +00:00
**Imports data to VictoriaMetrics in JSON line format**
Single-node VictoriaMetrics:
2022-04-12 08:27:17 +00:00
< div class = "with-copy" markdown = "1" >
2022-06-19 19:57:53 +00:00
```console
2023-06-21 04:04:17 +00:00
curl -H 'Content-Type: application/json' --data-binary "@filename.json" -X POST http://localhost:8428/api/v1/import
2022-04-12 08:27:17 +00:00
```
< / div >
2022-06-29 08:57:35 +00:00
Cluster version of VictoriaMetrics:
< div class = "with-copy" markdown = "1" >
2022-02-15 14:19:55 +00:00
2022-06-29 08:57:35 +00:00
```console
2023-06-21 04:04:17 +00:00
curl -H 'Content-Type: application/json' --data-binary "@filename.json" -X POST http://< vminsert > :8480/insert/0/prometheus/api/v1/import
2022-06-29 08:57:35 +00:00
```
< / div >
More information:
* [How to import time series ](https://docs.victoriametrics.com/#how-to-import-time-series-data )
* [How to export time series ](https://docs.victoriametrics.com/#how-to-export-time-series )
* [URL format for VictoriaMetrics cluster ](https://docs.victoriametrics.com/Cluster-VictoriaMetrics.html#url-format )
2022-02-15 14:19:55 +00:00
2023-11-07 08:54:32 +00:00
### /api/v1/import/csv
2022-02-15 14:19:55 +00:00
**Imports CSV data to VictoriaMetrics**
2022-03-22 11:40:55 +00:00
2022-06-29 08:57:35 +00:00
Single-node VictoriaMetrics:
2022-02-22 18:08:35 +00:00
< div class = "with-copy" markdown = "1" >
2022-06-19 19:57:53 +00:00
```console
2022-02-15 14:19:55 +00:00
curl -d "GOOG,1.23,4.56,NYSE" 'http://localhost:8428/api/v1/import/csv?format=2:metric:ask,3:metric:bid,1:label:ticker,4:label:market'
```
2022-02-22 18:08:35 +00:00
< / div >
2022-06-29 08:57:35 +00:00
Cluster version of VictoriaMetrics:
2022-02-22 18:08:35 +00:00
< div class = "with-copy" markdown = "1" >
2022-06-19 19:57:53 +00:00
```console
2022-02-15 14:19:55 +00:00
curl -d "GOOG,1.23,4.56,NYSE" 'http://< vminsert > :8480/insert/0/prometheus/api/v1/import/csv?format=2:metric:ask,3:metric:bid,1:label:ticker,4:label:market'
```
2022-02-22 18:08:35 +00:00
< / div >
2022-03-22 11:40:55 +00:00
Additional information:
2022-06-29 08:57:35 +00:00
* [How to import time series ](https://docs.victoriametrics.com/#how-to-import-time-series-data )
* [How to export time series ](https://docs.victoriametrics.com/#how-to-export-time-series )
* [URL format for VictoriaMetrics cluster ](https://docs.victoriametrics.com/Cluster-VictoriaMetrics.html#url-format )
2022-02-15 14:19:55 +00:00
2023-11-07 08:54:32 +00:00
### /api/v1/import/native
2022-03-22 13:11:43 +00:00
2022-06-29 08:57:35 +00:00
**Imports data to VictoriaMetrics in native format**
2022-03-22 13:11:43 +00:00
2022-06-29 08:57:35 +00:00
Single-node VictoriaMetrics:
2022-03-22 13:11:43 +00:00
< div class = "with-copy" markdown = "1" >
2022-06-19 19:57:53 +00:00
```console
2022-06-29 08:57:35 +00:00
curl -X POST http://localhost:8428/api/v1/import/native -T filename.bin
2022-03-22 13:11:43 +00:00
```
2023-04-04 11:00:22 +00:00
< / div >
2022-03-22 13:11:43 +00:00
2022-06-29 08:57:35 +00:00
Cluster version of VictoriaMetrics:
2022-03-22 13:11:43 +00:00
< div class = "with-copy" markdown = "1" >
2022-06-19 19:57:53 +00:00
```console
2022-06-29 08:57:35 +00:00
curl -X POST http://< vminsert > :8480/insert/0/prometheus/api/v1/import/native -T filename.bin
2022-03-22 13:11:43 +00:00
```
< / div >
2022-06-29 08:57:35 +00:00
Additional information:
* [How to import time series ](https://docs.victoriametrics.com/#how-to-import-time-series-data )
* [How to export time series ](https://docs.victoriametrics.com/#how-to-export-time-series )
* [URL format for VictoriaMetrics cluster ](https://docs.victoriametrics.com/Cluster-VictoriaMetrics.html#url-format )
2022-03-22 13:11:43 +00:00
2023-11-07 08:54:32 +00:00
### /api/v1/import/prometheus
2022-03-22 13:11:43 +00:00
2022-06-29 08:57:35 +00:00
**Imports data to VictoriaMetrics in Prometheus text exposition format**
2022-03-22 13:11:43 +00:00
2022-06-29 08:57:35 +00:00
Single-node VictoriaMetrics:
2022-03-22 13:11:43 +00:00
< div class = "with-copy" markdown = "1" >
2022-06-19 19:57:53 +00:00
```console
2022-06-29 08:57:35 +00:00
curl -d 'metric_name{foo="bar"} 123' -X POST http://localhost:8428/api/v1/import/prometheus
2022-03-22 13:11:43 +00:00
```
2023-04-04 11:00:22 +00:00
< / div >
2022-06-29 08:57:35 +00:00
Cluster version of VictoriaMetrics:
2022-03-22 13:11:43 +00:00
< div class = "with-copy" markdown = "1" >
2022-06-19 19:57:53 +00:00
```console
2022-06-29 08:57:35 +00:00
curl -d 'metric_name{foo="bar"} 123' -X POST http://< vminsert > :8480/insert/0/prometheus/api/v1/import/prometheus
2022-03-22 13:11:43 +00:00
```
< / div >
2022-06-29 08:57:35 +00:00
Additional information:
2022-03-22 13:11:43 +00:00
2022-06-29 08:57:35 +00:00
* [How to import time series ](https://docs.victoriametrics.com/#how-to-import-time-series-data )
* [How to export time series ](https://docs.victoriametrics.com/#how-to-export-time-series )
* [URL format for VictoriaMetrics cluster ](https://docs.victoriametrics.com/Cluster-VictoriaMetrics.html#url-format )
2022-03-22 13:11:43 +00:00
2023-11-28 08:41:17 +00:00
### /api/v1/labels
2022-03-22 13:11:43 +00:00
2022-09-05 08:53:15 +00:00
**Get a list of label names at the given time range**
2022-06-29 08:57:35 +00:00
Single-node VictoriaMetrics:
2022-03-22 13:11:43 +00:00
< div class = "with-copy" markdown = "1" >
2022-06-19 19:57:53 +00:00
```console
2022-06-29 08:57:35 +00:00
curl http://localhost:8428/prometheus/api/v1/labels
2022-03-22 13:11:43 +00:00
```
< / div >
2022-06-29 08:57:35 +00:00
Cluster version of VictoriaMetrics:
2022-03-22 13:11:43 +00:00
< div class = "with-copy" markdown = "1" >
2022-06-19 19:57:53 +00:00
```console
2022-06-29 08:57:35 +00:00
curl http://< vmselect > :8481/select/0/prometheus/api/v1/labels
2022-03-22 13:11:43 +00:00
```
< / div >
2023-05-10 07:50:41 +00:00
By default, VictoriaMetrics returns labels seen during the last day starting at 00:00 UTC. An arbitrary time range can be set via `start` and `end` query args.
2023-03-29 00:00:14 +00:00
The specified `start..end` time range is rounded to day granularity because of performance optimization concerns.
2022-09-05 08:53:15 +00:00
2022-06-29 08:57:35 +00:00
Additional information:
2022-03-22 13:11:43 +00:00
* [Prometheus querying API usage ](https://docs.victoriametrics.com/#prometheus-querying-api-usage )
2022-06-29 08:57:35 +00:00
* [Querying label values ](https://prometheus.io/docs/prometheus/latest/querying/api/#querying-label-values )
* [URL format for VictoriaMetrics cluster ](https://docs.victoriametrics.com/Cluster-VictoriaMetrics.html#url-format )
2022-03-22 13:11:43 +00:00
2023-11-07 08:54:32 +00:00
### /api/v1/label/.../values
2022-03-22 13:11:43 +00:00
2022-09-05 08:53:15 +00:00
**Get a list of values for a particular label on the given time range**
2022-03-22 13:11:43 +00:00
2022-06-29 08:57:35 +00:00
Single-node VictoriaMetrics:
2022-03-22 13:11:43 +00:00
< div class = "with-copy" markdown = "1" >
2022-06-19 19:57:53 +00:00
```console
2022-06-29 08:57:35 +00:00
curl http://localhost:8428/prometheus/api/v1/label/job/values
2022-03-22 13:11:43 +00:00
```
< / div >
2022-06-29 08:57:35 +00:00
Cluster version of VictoriaMetrics:
2022-03-22 13:11:43 +00:00
< div class = "with-copy" markdown = "1" >
2022-06-19 19:57:53 +00:00
```console
2022-06-29 08:57:35 +00:00
curl http://< vmselect > :8481/select/0/prometheus/api/v1/label/job/values
2022-03-22 13:11:43 +00:00
```
< / div >
2023-05-10 07:50:41 +00:00
By default, VictoriaMetrics returns labels values seen during the last day starting at 00:00 UTC. An arbitrary time range can be set via `start` and `end` query args.
2023-03-29 00:00:14 +00:00
The specified `start..end` time range is rounded to day granularity because of performance optimization concerns.
2022-09-05 08:53:15 +00:00
2022-06-29 08:57:35 +00:00
Additional information:
* [Prometheus querying API usage ](https://docs.victoriametrics.com/#prometheus-querying-api-usage )
* [Getting label names ](https://prometheus.io/docs/prometheus/latest/querying/api/#getting-label-names )
* [URL format for VictoriaMetrics cluster ](https://docs.victoriametrics.com/Cluster-VictoriaMetrics.html#url-format )
2023-11-07 08:54:32 +00:00
### /api/v1/query
2022-06-29 08:57:35 +00:00
**Performs PromQL/MetricsQL instant query**
Single-node VictoriaMetrics:
2022-03-22 13:11:43 +00:00
< div class = "with-copy" markdown = "1" >
2022-06-19 19:57:53 +00:00
```console
2022-06-29 08:57:35 +00:00
curl http://localhost:8428/prometheus/api/v1/query -d 'query=vm_http_request_errors_total'
2022-03-22 13:11:43 +00:00
```
2022-06-29 08:57:35 +00:00
< / div >
Cluster version of VictoriaMetrics:
< div class = "with-copy" markdown = "1" >
2022-06-19 19:57:53 +00:00
```console
2022-06-29 08:57:35 +00:00
curl http://< vmselect > :8481/select/0/prometheus/api/v1/query -d 'query=vm_http_request_errors_total'
2022-03-22 13:11:43 +00:00
```
< / div >
2022-06-29 08:57:35 +00:00
Additional information:
2022-03-22 13:11:43 +00:00
* [Prometheus querying API usage ](https://docs.victoriametrics.com/#prometheus-querying-api-usage )
2022-06-29 08:57:35 +00:00
* [Instant queries ](https://docs.victoriametrics.com/keyConcepts.html#instant-query )
2022-06-19 20:12:10 +00:00
* [Query language ](https://docs.victoriametrics.com/keyConcepts.html#metricsql )
2022-06-29 08:57:35 +00:00
* [URL format for VictoriaMetrics cluster ](https://docs.victoriametrics.com/Cluster-VictoriaMetrics.html#url-format )
2022-03-22 13:11:43 +00:00
2023-11-07 08:54:32 +00:00
### /api/v1/query_range
2022-03-22 13:11:43 +00:00
2022-06-29 08:57:35 +00:00
**Performs PromQL/MetricsQL range query**
2022-03-22 13:11:43 +00:00
2022-06-29 08:57:35 +00:00
Single-node VictoriaMetrics:
2022-03-22 13:11:43 +00:00
< div class = "with-copy" markdown = "1" >
2022-06-19 19:57:53 +00:00
```console
2022-06-29 08:57:35 +00:00
curl http://localhost:8428/prometheus/api/v1/query_range -d 'query=sum(increase(vm_http_request_errors_total{job="foo"}[5m]))' -d 'start=-1d' -d 'step=1h'
2022-03-22 13:11:43 +00:00
```
< / div >
2022-06-29 08:57:35 +00:00
Cluster version of VictoriaMetrics:
2022-03-22 13:11:43 +00:00
< div class = "with-copy" markdown = "1" >
2022-06-19 19:57:53 +00:00
```console
2022-06-29 08:57:35 +00:00
curl http://< vmselect > :8481/select/0/prometheus/api/v1/query_range -d 'query=sum(increase(vm_http_request_errors_total{job="foo"}[5m]))' -d 'start=-1d' -d 'step=1h'
2022-03-22 13:11:43 +00:00
```
< / div >
2022-06-29 08:57:35 +00:00
Additional information:
2022-03-22 13:11:43 +00:00
* [Prometheus querying API usage ](https://docs.victoriametrics.com/#prometheus-querying-api-usage )
2022-06-29 08:57:35 +00:00
* [Range queries ](https://docs.victoriametrics.com/keyConcepts.html#range-query )
* [Query language ](https://docs.victoriametrics.com/keyConcepts.html#metricsql )
* [URL format for VictoriaMetrics cluster ](https://docs.victoriametrics.com/Cluster-VictoriaMetrics.html#url-format )
2022-03-22 13:11:43 +00:00
2023-11-07 08:54:32 +00:00
### /api/v1/series
2022-03-22 13:11:43 +00:00
2022-09-05 08:53:15 +00:00
**Returns series names with their labels on the given time range**
2022-03-22 13:11:43 +00:00
2022-06-29 08:57:35 +00:00
Single-node VictoriaMetrics:
2022-03-22 13:11:43 +00:00
< div class = "with-copy" markdown = "1" >
2022-06-19 19:57:53 +00:00
```console
2022-06-29 08:57:35 +00:00
curl http://localhost:8428/prometheus/api/v1/series -d 'match[]=vm_http_request_errors_total'
2022-03-22 13:11:43 +00:00
```
< / div >
2022-06-29 08:57:35 +00:00
Cluster version of VictoriaMetrics:
2022-03-22 13:11:43 +00:00
< div class = "with-copy" markdown = "1" >
2022-06-19 19:57:53 +00:00
```console
2022-06-29 08:57:35 +00:00
curl http://< vmselect > :8481/select/0/prometheus/api/v1/series -d 'match[]=vm_http_request_errors_total'
2022-03-22 13:11:43 +00:00
```
< / div >
2023-05-10 07:50:41 +00:00
By default, VictoriaMetrics returns time series seen during the last day starting at 00:00 UTC. An arbitrary time range can be set via `start` and `end` query args.
2023-03-29 00:00:14 +00:00
The specified `start..end` time range is rounded to day granularity because of performance optimization concerns.
2022-09-05 08:53:15 +00:00
2022-06-29 08:57:35 +00:00
Additional information:
2022-03-22 13:11:43 +00:00
* [Prometheus querying API usage ](https://docs.victoriametrics.com/#prometheus-querying-api-usage )
2022-06-29 08:57:35 +00:00
* [Finding series by label matchers ](https://prometheus.io/docs/prometheus/latest/querying/api/#finding-series-by-label-matchers )
* [URL format for VictoriaMetrics cluster ](https://docs.victoriametrics.com/Cluster-VictoriaMetrics.html#url-format )
2022-07-11 17:18:30 +00:00
VictoriaMetrics accepts `limit` query arg for `/api/v1/series` handlers for limiting the number of returned entries. For example, the query to `/api/v1/series?limit=5` returns a sample of up to 5 series, while ignoring the rest. If the provided `limit` value exceeds the corresponding `-search.maxSeries` command-line flag values, then limits specified in the command-line flags are used.
2022-03-22 13:11:43 +00:00
2023-11-07 08:54:32 +00:00
### /api/v1/status/tsdb
2022-03-22 13:11:43 +00:00
2022-06-29 08:57:35 +00:00
**Cardinality statistics**
2022-03-22 13:11:43 +00:00
2022-06-29 08:57:35 +00:00
Single-node VictoriaMetrics:
2022-03-22 13:11:43 +00:00
< div class = "with-copy" markdown = "1" >
2022-06-19 19:57:53 +00:00
```console
2022-06-29 08:57:35 +00:00
curl http://localhost:8428/prometheus/api/v1/status/tsdb
2022-03-22 13:11:43 +00:00
```
< / div >
2022-06-29 08:57:35 +00:00
Cluster version of VictoriaMetrics:
2022-03-22 13:11:43 +00:00
< div class = "with-copy" markdown = "1" >
2022-06-19 19:57:53 +00:00
```console
2022-06-29 08:57:35 +00:00
curl http://< vmselect > :8481/select/0/prometheus/api/v1/status/tsdb
2022-03-22 13:11:43 +00:00
```
< / div >
2022-06-29 08:57:35 +00:00
Additional information:
2022-03-22 13:11:43 +00:00
* [Prometheus querying API usage ](https://docs.victoriametrics.com/#prometheus-querying-api-usage )
2022-06-29 08:57:35 +00:00
* [TSDB Stats ](https://prometheus.io/docs/prometheus/latest/querying/api/#tsdb-stats )
* [URL format for VictoriaMetrics cluster ](https://docs.victoriametrics.com/Cluster-VictoriaMetrics.html#url-format )
2022-03-22 13:11:43 +00:00
2023-11-07 08:54:32 +00:00
### /datadog
2022-10-03 09:45:05 +00:00
**DataDog URL for Single-node VictoriaMetrics**
< div class = "with-copy" markdown = "1" >
```
http://victoriametrics:8428/datadog
```
< / div >
**DataDog URL for Cluster version of VictoriaMetrics**
< div class = "with-copy" markdown = "1" >
```
http://vminsert:8480/insert/0/datadog
```
< / div >
2023-11-07 08:54:32 +00:00
### /datadog/api/v1/series
2022-02-15 14:19:55 +00:00
2022-06-29 08:57:35 +00:00
**Imports data in DataDog format into VictoriaMetrics**
2022-03-22 11:40:55 +00:00
2022-06-29 08:57:35 +00:00
Single-node VictoriaMetrics:
2022-02-22 18:08:35 +00:00
< div class = "with-copy" markdown = "1" >
2022-06-19 19:57:53 +00:00
```console
2022-02-15 14:19:55 +00:00
echo '
{
"series": [
{
"host": "test.example.com",
"interval": 20,
"metric": "system.load.1",
"points": [[
0,
0.5
]],
"tags": [
"environment:test"
],
"type": "rate"
}
]
}
2023-06-21 04:04:17 +00:00
' | curl -X POST -H 'Content-Type: application/json' --data-binary @- http://localhost:8428/datadog/api/v1/series
2022-02-15 14:19:55 +00:00
```
2022-02-22 18:08:35 +00:00
< / div >
2022-06-29 08:57:35 +00:00
Cluster version of VictoriaMetrics:
2022-02-22 18:08:35 +00:00
< div class = "with-copy" markdown = "1" >
2022-06-19 19:57:53 +00:00
```console
2022-02-15 14:19:55 +00:00
echo '
{
"series": [
{
"host": "test.example.com",
"interval": 20,
"metric": "system.load.1",
"points": [[
0,
0.5
]],
"tags": [
"environment:test"
],
"type": "rate"
}
]
}
2023-06-21 04:04:17 +00:00
' | curl -X POST -H 'Content-Type: application/json' --data-binary @- 'http://< vminsert > :8480/insert/0/datadog/api/v1/series'
2022-02-15 14:19:55 +00:00
```
2022-02-22 18:08:35 +00:00
< / div >
2023-11-28 13:52:29 +00:00
### /datadog/api/v2/series
**Imports data in DataDog format into VictoriaMetrics**
Single-node VictoriaMetrics:
< div class = "with-copy" markdown = "1" >
```console
echo '
{
"series": [
{
"interval": 20,
"metric": "system.load.1",
"resources": [
{
"name": "test.example.com",
"type": "host"
}
],
"points": [
{
"timestamp": 1699152159,
"value": 0
},
{
"timestamp": 1699152160,
"value": 0.5
}
],
"tags": [
"environment:test"
],
"type": "rate"
}
]
}
' | curl -X POST -H 'Content-Type: application/json' --data-binary @- http://localhost:8428/datadog/api/v2/series
```
< / div >
Cluster version of VictoriaMetrics:
< div class = "with-copy" markdown = "1" >
```console
echo '
{
"series": [
{
"interval": 20,
"metric": "system.load.1",
"resources": [
{
"name": "test.example.com",
"type": "host"
}
],
"points": [
{
"timestamp": 1699152159,
"value": 0
},
{
"timestamp": 1699152160,
"value": 0.5
}
],
"tags": [
"environment:test"
],
"type": "rate"
}
]
}
' | curl -X POST -H 'Content-Type: application/json' --data-binary @- 'http://< vminsert > :8480/insert/0/datadog/api/v2/series
< / div >
2022-02-15 14:19:55 +00:00
Additional information:
2022-03-22 11:40:55 +00:00
* [How to send data from datadog agent ](https://docs.victoriametrics.com/#how-to-send-data-from-datadog-agent )
2022-06-29 08:57:35 +00:00
* [URL format for VictoriaMetrics cluster ](https://docs.victoriametrics.com/Cluster-VictoriaMetrics.html#url-format )
2022-02-15 14:19:55 +00:00
2023-11-07 08:54:32 +00:00
### /federate
2022-03-24 09:53:28 +00:00
**Returns federated metrics**
2022-06-29 08:57:35 +00:00
Single-node VictoriaMetrics:
2022-03-24 09:53:28 +00:00
< div class = "with-copy" markdown = "1" >
2022-06-19 19:57:53 +00:00
```console
2022-06-29 08:57:35 +00:00
curl http://localhost:8428/federate -d 'match[]=vm_http_request_errors_total'
2022-03-24 09:53:28 +00:00
```
< / div >
2022-06-29 08:57:35 +00:00
Cluster version of VictoriaMetrics:
2022-03-24 09:53:28 +00:00
< div class = "with-copy" markdown = "1" >
2022-06-19 19:57:53 +00:00
```console
2022-06-29 08:57:35 +00:00
curl http://< vmselect > :8481/select/0/prometheus/federate -d 'match[]=vm_http_request_errors_total'
2022-03-24 09:53:28 +00:00
```
< / div >
Additional information:
* [Federation ](https://docs.victoriametrics.com/#federation )
* [Prometheus-compatible federation data ](https://prometheus.io/docs/prometheus/latest/federation/#configuring-federation )
2022-06-29 08:57:35 +00:00
* [URL format for VictoriaMetrics cluster ](https://docs.victoriametrics.com/Cluster-VictoriaMetrics.html#url-format )
2022-03-24 09:53:28 +00:00
2023-11-07 08:54:32 +00:00
### /graphite/metrics/find
2022-02-15 14:19:55 +00:00
2022-02-15 19:24:49 +00:00
**Searches Graphite metrics in VictoriaMetrics**
2022-02-15 14:19:55 +00:00
2022-06-29 08:57:35 +00:00
Single-node VictoriaMetrics:
2022-02-22 18:08:35 +00:00
< div class = "with-copy" markdown = "1" >
2022-06-19 19:57:53 +00:00
```console
2022-06-29 08:57:35 +00:00
curl http://localhost:8428/graphite/metrics/find -d 'query=vm_http_request_errors_total'
2022-02-15 14:19:55 +00:00
```
2022-02-22 18:08:35 +00:00
< / div >
2022-03-22 11:40:55 +00:00
2022-06-29 08:57:35 +00:00
Cluster version of VictoriaMetrics:
2022-02-22 18:08:35 +00:00
< div class = "with-copy" markdown = "1" >
2022-06-19 19:57:53 +00:00
```console
2022-06-29 08:57:35 +00:00
curl http://< vmselect > :8481/select/0/graphite/metrics/find -d 'query=vm_http_request_errors_total'
2022-02-15 14:19:55 +00:00
```
2022-02-22 18:08:35 +00:00
< / div >
2022-03-22 11:40:55 +00:00
2022-02-15 14:19:55 +00:00
Additional information:
2022-03-22 11:40:55 +00:00
2022-06-29 08:57:35 +00:00
* [Metrics find API in Graphite ](https://graphite-api.readthedocs.io/en/latest/api.html#metrics-find )
* [Graphite API in VictoriaMetrics ](https://docs.victoriametrics.com/#graphite-api-usage )
* [How to send Graphite data to VictoriaMetrics ](https://docs.victoriametrics.com/Single-server-VictoriaMetrics.html#how-to-send-data-from-graphite-compatible-agents-such-as-statsd )
2022-02-15 19:24:49 +00:00
* [URL Format ](https://docs.victoriametrics.com/Cluster-VictoriaMetrics.html#url-format )
2022-02-15 14:19:55 +00:00
2023-11-07 08:54:32 +00:00
### /influx/write
2022-02-15 14:19:55 +00:00
2022-02-15 19:24:49 +00:00
**Writes data with InfluxDB line protocol to VictoriaMetrics**
2022-02-15 14:19:55 +00:00
2022-06-29 08:57:35 +00:00
Single-node VictoriaMetrics:
2022-02-22 18:08:35 +00:00
< div class = "with-copy" markdown = "1" >
2022-06-19 19:57:53 +00:00
```console
2022-06-29 08:57:35 +00:00
curl -d 'measurement,tag1=value1,tag2=value2 field1=123,field2=1.23' -X POST http://localhost:8428/write
2022-02-15 14:19:55 +00:00
```
2022-02-22 18:08:35 +00:00
< / div >
2022-03-22 11:40:55 +00:00
2022-06-29 08:57:35 +00:00
Cluster version of VictoriaMetrics:
2022-02-22 18:08:35 +00:00
< div class = "with-copy" markdown = "1" >
2022-06-19 19:57:53 +00:00
```console
2022-06-29 08:57:35 +00:00
curl -d 'measurement,tag1=value1,tag2=value2 field1=123,field2=1.23' -X POST http://< vminsert > :8480/insert/0/influx/write
2022-02-15 14:19:55 +00:00
```
2022-02-22 18:08:35 +00:00
< / div >
2022-03-22 11:40:55 +00:00
2022-02-15 14:19:55 +00:00
Additional information:
2022-06-29 08:57:35 +00:00
* [How to send Influx data to VictoriaMetrics ](https://docs.victoriametrics.com/#how-to-send-data-from-influxdb-compatible-agents-such-as-telegraf )
* [URL Format ](https://docs.victoriametrics.com/Cluster-VictoriaMetrics.html#url-format )
2022-02-15 14:19:55 +00:00
2023-11-07 08:54:32 +00:00
### /internal/resetRollupResultCache
2023-07-05 07:43:12 +00:00
**Resets the response cache for previously served queries. It is recommended to invoke after [backfilling ](https://docs.victoriametrics.com/#backfilling ) procedure.**
Single-node VictoriaMetrics:
< div class = "with-copy" markdown = "1" >
```console
curl -Is http://localhost:8428/internal/resetRollupResultCache
```
< / div >
2023-11-28 08:38:19 +00:00
Cluster version of VictoriaMetrics:
2023-07-05 07:43:12 +00:00
< div class = "with-copy" markdown = "1" >
```console
curl -Is http://< vmselect > :8481/select/internal/resetRollupResultCache
```
2023-11-28 08:38:19 +00:00
vmselect will propagate this call to the rest of the vmselects listed in its `-selectNode` cmd-line flag. If this
flag isn't set, then cache need to be purged from each vmselect individually.
2023-07-05 07:43:12 +00:00
< / div >
2023-11-07 08:54:32 +00:00
### TCP and UDP
2022-02-15 14:19:55 +00:00
2023-11-07 08:54:32 +00:00
#### How to send data from OpenTSDB-compatible agents to VictoriaMetrics
2022-02-15 14:19:55 +00:00
2022-02-15 19:24:49 +00:00
Turned off by default. Enable OpenTSDB receiver in VictoriaMetrics by setting `-opentsdbListenAddr` command-line flag.
2022-02-15 14:19:55 +00:00
*If run from docker, '-opentsdbListenAddr' port should be exposed*
2022-06-29 08:57:35 +00:00
Single-node VictoriaMetrics:
2022-02-22 18:08:35 +00:00
< div class = "with-copy" markdown = "1" >
2022-06-19 19:57:53 +00:00
```console
2022-02-15 14:19:55 +00:00
echo "put foo.bar.baz `date +%s` 123 tag1=value1 tag2=value2" | nc -N localhost 4242
```
2022-02-22 18:08:35 +00:00
< / div >
2022-03-22 11:40:55 +00:00
2022-06-29 08:57:35 +00:00
Cluster version of VictoriaMetrics:
2022-02-22 18:08:35 +00:00
< div class = "with-copy" markdown = "1" >
2022-06-19 19:57:53 +00:00
```console
2022-09-30 15:04:48 +00:00
echo "put foo.bar.baz `date +%s` 123 tag1=value1 tag2=value2" | nc -N http://< vminsert > 4242
2022-02-15 14:19:55 +00:00
```
2022-02-22 18:08:35 +00:00
< / div >
2022-03-22 11:40:55 +00:00
2022-02-15 19:24:49 +00:00
Enable HTTP server for OpenTSDB /api/put requests by setting `-opentsdbHTTPListenAddr` command-line flag.
2022-03-22 11:40:55 +00:00
2022-06-29 08:57:35 +00:00
Single-node VictoriaMetrics:
2022-02-22 18:08:35 +00:00
< div class = "with-copy" markdown = "1" >
2022-06-19 19:57:53 +00:00
```console
2022-02-15 14:19:55 +00:00
curl -H 'Content-Type: application/json' -d '[{"metric":"foo","value":45.34},{"metric":"bar","value":43}]' http://localhost:4242/api/put
```
2022-02-22 18:08:35 +00:00
< / div >
2022-03-22 11:40:55 +00:00
2022-06-29 08:57:35 +00:00
Cluster version of VictoriaMetrics:
2022-02-22 18:08:35 +00:00
< div class = "with-copy" markdown = "1" >
2022-06-19 19:57:53 +00:00
```console
2022-06-29 08:57:35 +00:00
curl -H 'Content-Type: application/json' -d '[{"metric":"foo","value":45.34},{"metric":"bar","value":43}]' http://< vminsert > :8480/insert/42/opentsdb/api/put
2022-02-15 14:19:55 +00:00
```
2022-02-22 18:08:35 +00:00
< / div >
2022-03-22 11:40:55 +00:00
2022-02-15 14:19:55 +00:00
Additional information:
2022-03-22 11:40:55 +00:00
2022-06-29 08:57:35 +00:00
* [OpenTSDB http put API ](http://opentsdb.net/docs/build/html/api_http/put.html )
* [How to send data OpenTSDB data to VictoriaMetrics ](https://docs.victoriametrics.com/Single-server-VictoriaMetrics.html#how-to-send-data-from-opentsdb-compatible-agents )
2022-02-15 14:19:55 +00:00
2023-11-07 08:54:32 +00:00
#### How to send Graphite data to VictoriaMetrics
2022-02-15 14:19:55 +00:00
2022-02-15 19:24:49 +00:00
Enable Graphite receiver in VictoriaMetrics by setting `-graphiteListenAddr` command-line flag.
2022-03-22 11:40:55 +00:00
2022-06-29 08:57:35 +00:00
Single-node VictoriaMetrics:
2022-02-22 18:08:35 +00:00
< div class = "with-copy" markdown = "1" >
2022-06-19 19:57:53 +00:00
```console
2022-06-29 08:57:35 +00:00
echo "foo.bar.baz;tag1=value1;tag2=value2 123 `date +%s` " | nc -N localhost 2003
2022-02-15 14:19:55 +00:00
```
2022-02-22 18:08:35 +00:00
< / div >
2022-03-22 11:40:55 +00:00
2022-06-29 08:57:35 +00:00
Cluster version of VictoriaMetrics:
2022-02-22 18:08:35 +00:00
< div class = "with-copy" markdown = "1" >
2022-06-19 19:57:53 +00:00
```console
2022-09-30 15:04:48 +00:00
echo "foo.bar.baz;tag1=value1;tag2=value2 123 `date +%s` " | nc -N http://< vminsert > 2003
2022-02-15 14:19:55 +00:00
```
2022-02-22 18:08:35 +00:00
< / div >
2022-02-15 14:19:55 +00:00
Additional information:
2022-06-29 08:57:35 +00:00
* [How to send Graphite data to VictoriaMetrics ](https://docs.victoriametrics.com/Single-server-VictoriaMetrics.html#how-to-send-data-from-graphite-compatible-agents-such-as-statsd )
* [Multitenancy in cluster version of VictoriaMetrics ](https://docs.victoriametrics.com/Cluster-VictoriaMetrics.html#multitenancy )