VictoriaMetrics components like vmagent, vminsert or single-node can receive inserts via telnet put protocol and HTTP /api/put requests for ingesting OpenTSDB data. The same protocol is used for ingesting data in KairosDB.

See full list of OpenTSDB-related configuration flags by running:

      /path/to/victoria-metrics-prod --help | grep opentsdb
    

Sending data via telnet #

Enable OpenTSDB receiver in VictoriaMetrics by setting -opentsdbListenAddr command line flag:

      /path/to/victoria-metrics-prod -opentsdbListenAddr=:4242
    

Send data to the given address from OpenTSDB-compatible agents.

Example for writing data with OpenTSDB protocol to local VictoriaMetrics using nc:

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

An arbitrary number of lines delimited by \n (aka newline char) can be sent in one go. After that the data may be read via /api/v1/export endpoint:

      curl -G 'http://localhost:8428/api/v1/export' -d 'match=foo.bar.baz'
    

The /api/v1/export endpoint should return the following response:

      {"metric":{"__name__":"foo.bar.baz","tag1":"value1","tag2":"value2"},"values":[123],"timestamps":[1560277292000]}
    

Sending data via HTTP #

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

      /path/to/victoria-metrics-prod -opentsdbHTTPListenAddr=:4242
    

Send data to the given address from OpenTSDB-compatible agents.

Example for writing a single data point:

      curl -H 'Content-Type: application/json' -d '{"metric":"x.y.z","value":45.34,"tags":{"t1":"v1","t2":"v2"}}' http://localhost:4242/api/put
    

Example for writing multiple data points in a single request:

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

After that the data may be read via /api/v1/export endpoint:

      curl -G 'http://localhost:8428/api/v1/export' -d 'match[]=x.y.z' -d 'match[]=foo' -d 'match[]=bar'
    

The /api/v1/export endpoint should return the following response:

      {"metric":{"__name__":"foo"},"values":[45.34],"timestamps":[1566464846000]}
{"metric":{"__name__":"bar"},"values":[43],"timestamps":[1566464846000]}
{"metric":{"__name__":"x.y.z","t1":"v1","t2":"v2"},"values":[45.34],"timestamps":[1566464763000]}
    

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.