VictoriaMetrics/docs/url-examples.md
Dima Lazerka 1fa0f3ec89
VMAnomaly docs fixes (#2361)
* Added docs for vmanomaly

* Add example images

* Stylistic fixes

* Move images to root

* Update docs/vmanomaly.md

* Update docs/vmanomaly.md

Co-authored-by: Roman Khavronenko <roman@victoriametrics.com>

* Squeeze vmanomaly after vmbackupmanager before Case Studies

Co-authored-by: Aliaksandr Valialkin <valyala@victoriametrics.com>
Co-authored-by: Roman Khavronenko <roman@victoriametrics.com>
2022-03-25 12:08:17 +02:00

13 KiB

sort
21

VictoriaMetrics API examples

/api/v1/admin/tsdb/delete_series

Deletes time series from VictoriaMetrics

Single:

curl 'http://<victoriametrics-addr>:8428/api/v1/admin/tsdb/delete_series?match[]=vm_http_request_errors_total'

Cluster:

curl 'http://<vmselect>:8481/delete/0/prometheus/api/v1/admin/tsdb/delete_series?match[]=vm_http_request_errors_total'

Additional information:

/api/v1/export/csv

Exports CSV data from VictoriaMetrics

Single:

curl 'http://<victoriametrics-addr>:8428/api/v1/export/csv?format=__name__,__value__,__timestamp__:unix_s&match=vm_http_request_errors_total' > filename.txt

Cluster:

curl -G 'http://<vmselect>:8481/select/0/prometheus/api/v1/export/csv?format=__name__,__value__,__timestamp__:unix_s&match=vm_http_request_errors_total' > filename.txt

Additional information:

/api/v1/export/native

Exports data from VictoriaMetrics in native format

Single:

curl -G 'http://<victoriametrics-addr>:8428/api/v1/export/native?match[]=vm_http_request_errors_total' > filename.txt

Cluster:

curl -G 'http://<vmselect>:8481/select/0/prometheus/api/v1/export/native?match=vm_http_request_errors_total' > filename.txt

More information:

/api/v1/import

Imports data obtained via /api/v1/export

Single:

curl --data-binary "@import.txt" -X POST 'http://destination-victoriametrics:8428/api/v1/import'

Cluster:

curl --data-binary "@import.txt" -X POST 'http://<vminsert>:8480/insert/prometheus/api/v1/import'

Additional information:

/api/v1/import/csv

Imports CSV data to VictoriaMetrics

Single:

curl --data-binary "@import.txt" -X POST 'http://localhost:8428/api/v1/import/prometheus'
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'

Cluster:

curl --data-binary "@import.txt" -X POST  'http://<vminsert>:8480/insert/0/prometheus/api/v1/import/csv'
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'

Additional information:

/api/v1/labels

Get a list of label names

Single:

curl -G 'http://localhost:8428/prometheus/api/v1/labels'

Cluster:

curl -G 'http://<vmselect>:8481/select/0/prometheus/api/v1/labels'

Additional information:

/api/v1/label/<label_name>/values

Querying label values

Single:

curl -G 'http://localhost:8428/prometheus/api/v1/label/job/values'

Cluster:

curl -G 'http://<vmselect>:8481/select/0/prometheus/api/v1/label/job/values'

Additional information:

/api/v1/query

Performs PromQL/MetricsQL instant query

Single:

curl -G 'http://localhost:8428/prometheus/api/v1/query?query=vm_http_request_errors_total&time=2021-02-22T19:10:30.781Z'

Cluster:

curl -G 'http://<vmselect>:8481/select/0/prometheus/api/v1/query?query=vm_http_request_errors_total&time=2021-02-22T19:10:30.781Z'

Additional information:

/api/v1/query_range

Performs PromQL/MetricsQL range_query

Single:

curl -G 'http://localhost:8428/prometheus/api/v1/query_range?query=vm_http_request_errors_total&start=2021-02-22T19:10:30.781Z&step=20m'

Cluster:

curl -G 'http://<vmselect>:8481/select/0/prometheus/api/v1/query_range?query=vm_http_request_errors_total&start=2021-02-22T19:10:30.781Z&step=20m'
curl -G 'http://<vmselect>:8481/select/0/prometheus/api/v1/query_range?query=vm_http_request_errors_total&start=-1h&step=10m'
curl -G http://<vmselect>:8481/select/0/prometheus/api/v1/query_range --data-urlencode 'query=sum(increase(vm_http_request_errors_total{status=""}[5m])) by (status)'

Additional information:

/api/v1/series

Finding series by label matchers

Single:

curl -G 'http://localhost:8428/prometheus/api/v1/series?match[]=vm_http_request_errors_total&start=-1h'

Cluster:

curl -G 'http://<vmselect>:8481/select/0/prometheus/api/v1/series?match[]=vm_http_request_errors_total&start=-1h'

Additional information:

/api/v1/status/tsdb

Cardinality statistics

Single:

curl -G 'http://localhost:8428/prometheus/api/v1/status/tsdb'

Cluster:

curl -G 'http://<vmselect>:8481/select/0/prometheus/api/v1/status/tsdb'

Additional information:

/api/v1/targets

Checking targets

Should be sent to vmagent/VMsingle

Single:

curl -G 'http://<vmsingle>:8428/api/v1/targets' 

cluster:

curl -G 'http://<vmagent>:8429/api/v1/targets' 

Additional information:

/datadog/api/v1/series

Sends data from DataDog agent to VM

Single:

echo '
{
  "series": [
    {
      "host": "test.example.com",
      "interval": 20,
      "metric": "system.load.1",
      "points": [[
        0,
        0.5
      ]],
      "tags": [
        "environment:test"
      ],
      "type": "rate"
    }
  ]
}
' | curl -X POST --data-binary @- http://localhost:8428/datadog/api/v1/series

Cluster:

echo '
{
  "series": [
    {
      "host": "test.example.com",
      "interval": 20,
      "metric": "system.load.1",
      "points": [[
        0,
        0.5
      ]],
      "tags": [
        "environment:test"
      ],
      "type": "rate"
    }
  ]
}
' | curl -X POST --data-binary @- 'http://<vminsert>:8480/insert/0/datadog/api/v1/series'

Additional information:

/federate

Returns federated metrics

Single:

curl -G 'http://localhost:8428/federate?match[]=vm_http_request_errors_total&start=2021-02-22T19:10:30.781Z'

Cluster:

curl -G 'http://<vmselect>:8481/select/0/prometheus/federate?match[]=vm_http_request_errors_total&start=2021-02-22T19:10:30.781Z'

Additional information:

/graphite/metrics/find

Searches Graphite metrics in VictoriaMetrics

Single:

curl -G 'http://localhost:8428/graphite/metrics/find?query=vm_http_request_errors_total'

Cluster:

curl -G 'http://<vmselect>:8481/select/0/graphite/metrics/find?query=vm_http_request_errors_total'

Additional information:

/influx/write

Writes data with InfluxDB line protocol to VictoriaMetrics

Single:

curl -d 'measurement,tag1=value1,tag2=value2 field1=123,field2=1.23' -X POST 'http://localhost:8428/write'

Cluster:

curl -d 'measurement,tag1=value1,tag2=value2 field1=123,field2=1.23' -X POST 'http://<vminsert>:8480/insert/0/influx/write'

Additional information:

TCP and UDP

How to send data from OpenTSDB-compatible agents to VictoriaMetrics

Turned off by default. Enable OpenTSDB receiver in VictoriaMetrics by setting -opentsdbListenAddr command-line flag. If run from docker, '-opentsdbListenAddr' port should be exposed

Single:

echo "put foo.bar.baz `date +%s` 123 tag1=value1 tag2=value2" | nc -N localhost 4242

Cluster:

echo "put foo.bar.baz `date +%s` 123  tag1=value1 tag2=value2 VictoriaMetrics_AccountID=0" | nc -N http://<vminsert> 4242

Enable HTTP server for OpenTSDB /api/put requests by setting -opentsdbHTTPListenAddr command-line flag.

Single:

curl -H 'Content-Type: application/json' -d '[{"metric":"foo","value":45.34},{"metric":"bar","value":43}]' http://localhost:4242/api/put

Cluster:

curl -H 'Content-Type: application/json' -d '[{"metric":"foo","value":45.34},{"metric":"bar","value":43}]'
 'http://<vminsert>:8480/insert/42/opentsdb/api/put'

Additional information:

How to write data with Graphite plaintext protocol to VictoriaMetrics

Enable Graphite receiver in VictoriaMetrics by setting -graphiteListenAddr command-line flag.

Single:

echo "foo.bar.baz;tag1=value1;tag2=value2 123 `date +%s`" |
 nc -N localhost 2003

Cluster:

echo "foo.bar.baz;tag1=value1;tag2=value2;VictoriaMetrics_AccountID=42 123 `date +%s`" | nc -N http://<vminsert> 2003

Additional information:

VictoriaMetrics_AccountID=42 - tag that indicated tenant ID.