VictoriaMetrics

VictoriaMetrics -- 快速、低成本、可扩展的时间序列数据库。「VictoriaMetrics - fast, cost-effective and scalable time series database」

Github stars Tracking Chart

VictoriaMetrics

VictoriaMetrics 是一个快速、经济、可扩展的时间序列数据库。

它有 二进制版本docker 映像源代码。只需下载 VictoriaMetrics 并查看如何启动它。

集群版本在 这里 提供。

请参阅我们的 Wiki 了解更多文档。

如果您需要 VictoriaMetrics 的付费企业支持,请联系我们。查看 企业客户可用的功能

案例研究和讲座

突出特点

Operation

(恕删略。请参阅自述文件)


(The first version translated by vz on 2020.10.07)

Overview

Name With OwnerVictoriaMetrics/VictoriaMetrics
Primary LanguageGo
Program languageMakefile (Language Count: 11)
PlatformDocker, Kubernetes, Linux
License:Apache License 2.0
Release Count657
Last Release Namepmm-6401-v1.101.0 (Posted on 2024-04-26 13:30:50)
First Release Namev1.2.1 (Posted on )
Created At2018-09-30 09:58:01
Pushed At2024-05-09 16:51:32
Last Commit At2024-05-09 20:22:03
Stargazers Count10.9k
Watchers Count137
Fork Count1.1k
Commits Count8.3k
Has Issues Enabled
Issues Count3272
Issue Open Count804
Pull Requests Count2312
Pull Requests Open Count48
Pull Requests Close Count597
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private

Latest Release
Docker Pulls
Slack
GitHub license
Go Report
Build Status
codecov

VictoriaMetrics

VictoriaMetrics is fast, cost-effective and scalable time-series database. It can be used as long-term remote storage for Prometheus.
It is available in binary releases,
docker images and
in source code. Just download VictoriaMetrics and see how to start it.

Cluster version is available here.

Case studies and talks

Prominent features

Operation

Table of contents

How to start VictoriaMetrics

Just start VictoriaMetrics executable
or docker image with the desired command-line flags.

The following command-line flags are used the most:

  • -storageDataPath - path to data directory. VictoriaMetrics stores all the data in this directory. Default path is victoria-metrics-data in current working directory.
  • -retentionPeriod - retention period in months for the data. Older data is automatically deleted. Default period is 1 month.
  • -httpListenAddr - TCP address to listen to for http requests. By default, it listens port 8428 on all the network interfaces.
  • -graphiteListenAddr - TCP and UDP address to listen to for Graphite data. By default, it is disabled.
  • -opentsdbListenAddr - TCP and UDP address to listen to for OpenTSDB data over telnet protocol. By default, it is disabled.
  • -opentsdbHTTPListenAddr - TCP address to listen to for HTTP OpenTSDB data over /api/put. By default, it is disabled.

Pass -help to see all the available flags with description and default values.

It is recommended setting up monitoring for VictoriaMetrics.

Prometheus setup

Prometheus must be configured with remote_write
in order to send data to VictoriaMetrics. Add the following lines
to Prometheus config file (it is usually located at /etc/prometheus/prometheus.yml):

remote_write:
  - url: http://<victoriametrics-addr>:8428/api/v1/write

Substitute <victoriametrics-addr> with the hostname or IP address of VictoriaMetrics.
Then apply the new config via the following command:

kill -HUP `pidof prometheus`

Prometheus writes incoming data to local storage and replicates it to remote storage in parallel.
This means the data remains available in local storage for --storage.tsdb.retention.time duration
even if remote storage is unavailable.

If you plan to send data to VictoriaMetrics from multiple Prometheus instances, then add the following lines into global section
of Prometheus config:

global:
  external_labels:
    datacenter: dc-123

This instructs Prometheus to add datacenter=dc-123 label to each time series sent to remote storage.
The label name may be arbitrary - datacenter is just an example. The label value must be unique
across Prometheus instances, so those time series may be filtered and grouped by this label.

For highly loaded Prometheus instances (400k+ samples per second)
the following tuning may be applied:

remote_write:
  - url: http://<victoriametrics-addr>:8428/api/v1/write
    queue_config:
      max_samples_per_send: 10000
      capacity: 20000
      max_shards: 30

Using remote write increases memory usage for Prometheus up to ~25%
and depends on the shape of data. If you are experiencing issues with
too high memory consumption try to lower max_samples_per_send
and capacity params (keep in mind that these two params are tightly connected).
Read more about tuning remote write for Prometheus here.

It is recommended upgrading Prometheus to v2.12.0 or newer,
since the previous versions may have issues with remote_write.

Grafana setup

Create Prometheus datasource in Grafana with the following Url:

http://<victoriametrics-addr>:8428

Substitute <victoriametrics-addr> with the hostname or IP address of VictoriaMetrics.

Then build graphs with the created datasource using Prometheus query language.
VictoriaMetrics supports native PromQL and extends it with useful features.

How to upgrade VictoriaMetrics?

It is safe upgrading VictoriaMetrics to new versions unless release notes
say otherwise. It is recommended performing regular upgrades to the latest version,
since it may contain important bug fixes, performance optimizations or new features.

Follow the following steps during the upgrade:

  1. Send SIGINT signal to VictoriaMetrics process in order to gracefully stop it.
  2. Wait until the process stops. This can take a few seconds.
  3. Start the upgraded VictoriaMetrics.

Prometheus doesn't drop data during VictoriaMetrics restart.
See this article for details.

How to apply new config to VictoriaMetrics?

VictoriaMetrics must be restarted for applying new config:

  1. Send SIGINT signal to VictoriaMetrics process in order to gracefully stop it.
  2. Wait until the process stops. This can take a few seconds.
  3. Start VictoriaMetrics with the new config.

Prometheus doesn't drop data during VictoriaMetrics restart.
See this article for details.

How to send data from InfluxDB-compatible agents such as Telegraf?

Just use http://<victoriametric-addr>:8428 url instead of InfluxDB url in agents' configs.
For instance, put the following lines into Telegraf config, so it sends data to VictoriaMetrics instead of InfluxDB:


  urls = ["http://<victoriametrics-addr>:8428"]

Do not forget substituting <victoriametrics-addr> with the real address where VictoriaMetrics runs.

VictoriaMetrics maps Influx data using the following rules:

  • db query arg is mapped into db label value
    unless db tag exists in the Influx line.
  • Field names are mapped to time series names prefixed with {measurement}{separator} value,
    where {separator} equals to _ by default. It can be changed with -influxMeasurementFieldSeparator command-line flag.
    See also -influxSkipSingleField command-line flag. If {measurement} is empty, then time series names correspond to field names.
  • Field values are mapped to time series values.
  • Tags are mapped to Prometheus labels as-is.

For example, the following Influx line:

foo,tag1=value1,tag2=value2 field1=12,field2=40

is converted into the following Prometheus data points:

foo_field1{tag1="value1", tag2="value2"} 12
foo_field2{tag1="value1", tag2="value2"} 40

Example for writing data with Influx line protocol
to local VictoriaMetrics using curl:

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

An arbitrary number of lines delimited by '\n' may be sent in a single request.
After that the data may be read via /api/v1/export endpoint:

curl -G 'http://localhost:8428/api/v1/export' -d 'match={__name__=~"measurement_.*"}'

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

{"metric":{"__name__":"measurement_field1","tag1":"value1","tag2":"value2"},"values":[123],"timestamps":[1560272508147]}
{"metric":{"__name__":"measurement_field2","tag1":"value1","tag2":"value2"},"values":[1.23],"timestamps":[1560272508147]}

Note that Influx line protocol expects timestamps in nanoseconds by default,
while VictoriaMetrics stores them with milliseconds precision.

How to send data from Graphite-compatible agents such as StatsD?

  1. Enable Graphite receiver in VictoriaMetrics by setting -graphiteListenAddr command line flag. For instance,
    the following command will enable Graphite receiver in VictoriaMetrics on TCP and UDP port 2003:
/path/to/victoria-metrics-prod -graphiteListenAddr=:2003
  1. Use the configured address in Graphite-compatible agents. For instance, set graphiteHost
    to the VictoriaMetrics host in StatsD configs.

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

echo "foo.bar.baz;tag1=value1;tag2=value2 123 `date +%s`"
To the top