The VictoriaMetrics datasource plugin allows to query and visualize data from VictoriaMetrics in Grafana.
- Motivation
- Capabilities
- Installation
- How to use WITH templates
- How to make new release
- Frequently Asked Questions
- License
Motivation #
Thanks to VictoriaMetrics compatibility with Prometheus API most users can use Prometheus datasource for Grafana to query data from VictoriaMetrics. But with time, Prometheus and VictoriaMetrics diverge more and more. The benefits of using VictoriaMetrics plugin are the following:
- MetricsQL functions support;
- Supports query tracing in Explore mode or right in panel’s expressions;
- Supports WITH expressions;
- Plugin fixes label names validation issue;
- Integration with vmui.
Capabilities #
- Use MetricsQL to query metrics in Grafana.
- Use Explore mode with Grafana.
- Build dashboards and setup alerts.
- Use Ad Hoc filters.
- Template queries and expressions.
- Get insights about query execution bottlenecks via tracing.
- Automatically format queries via
Prettify
button.
Try it at VictoriaMetrics playground!
Installation #
For detailed instructions on how to install the plugin on Grafana Cloud or locally, please checkout the Plugin installation docs.
Install via Docker #
VictoriaMetrics repo provides a complete docker-compose environment to spin-up all required components via Docker.
To begin, clone VictoriaMetrics repository and follow steps described in the README.
Grafana Provisioning #
Provision of Grafana plugin requires to create datasource config file.
Example of config file for provisioning VictoriaMetrics datasource is the following:
|
|
Please find the example of provisioning Grafana instance with VictoriaMetrics datasource below:
Create a file at
./provisioning/datasources/vm.yml
with datasource example file.Define Grafana installation via docker-compose:
1 2 3 4 5 6 7 8 9 10
version: '3.0' services: grafana: image: grafana/grafana:11.0.0 environment: - GF_INSTALL_PLUGINS=victoriametrics-metrics-datasource ports: - 3000:3000/tcp volumes: - ./provisioning:/etc/grafana/provisioning
Run docker-compose file:
|
|
When Grafana starts successfully datasources should be present on the datasources tab

Install in Kubernetes #
Grafana helm chart #
Example with Grafana helm chart:
Option 1. Using Grafana provisioning:
|
|
Option 2. Using Grafana plugins section in values.yaml
:
|
|
Option 3. Using init container:
|
|
For grafana-operator
users, the above configuration should be done for the part /spec/deployment/spec/template/spec/initContainers
of your kind=Grafana
resource.
This example uses init container to download and install plugin. To allow Grafana using this container as a sidecar set the following config:
|
|
See more about chart settings here
Option 4 would be to build custom Grafana image with plugin based on same installation instructions.
Grafana operator #
Example with Grafana operator:
|
|
See Grafana operator reference to find more about Grafana operator. This example uses init container to download and install plugin.
It is also possible to request plugin at GrafanaDatasource
or GrafanaDashboard
CRDs.
For example:
|
|
Dev release installation #
To download plugin build and move contents into Grafana plugins directory:
1 2 3 4
ver=$(curl -s https://api.github.com/repos/VictoriaMetrics/victoriametrics-datasource/releases/latest | grep -oE 'v[0-9]+\.[0-9]+\.[0-9]+' | head -1) curl -L https://github.com/VictoriaMetrics/victoriametrics-datasource/releases/download/$ver/victoriametrics-metrics-datasource-$ver.tar.gz -o /var/lib/grafana/plugins/vm-plugin.tar.gz tar -xf /var/lib/grafana/plugins/vm-plugin.tar.gz -C /var/lib/grafana/plugins/ rm /var/lib/grafana/plugins/vm-plugin.tar.gz
Restart Grafana
Getting started development #
1. Configure Grafana #
Installing dev version of Grafana plugin requires to change grafana.ini
config to allow loading unsigned plugins:
|
|
2. Run the plugin #
In the project directory, you can run:
|
|
3. How to build backend plugin #
From the root folder of the project run the following command:
|
|
This command will build executable multi-platform files to the dist
folder for the following platforms:
- linux/amd64
- linux/arm64
- linux/arm
- linux/386
- amd64
- arm64
- windows
4.How to build frontend plugin #
From the root folder of the project run the following command:
|
|
This command will build all frontend app into dist
folder.
5. How to build frontend and backend parts of the plugin: #
When frontend and backend parts of the plugin is required, run the following command from the root folder of the project:
|
|
This command will build frontend part and backend part or the plugin and locate both parts into dist
folder.
How to use WITH templates #
The WITH
templates feature simplifies the construction and management of complex queries. You can try this feature in the WITH templates playground.
The “WITH templates” section allows you to create expressions with templates that can be used in dashboards.
WITH expressions are stored in the datasource object. If the dashboard gets exported, the associated WITH templates will not be included in the resulting JSON (due to technical limitations) and need to be migrated separately.
Defining WITH Expressions #
Navigate to the dashboard where you want to add a template.
Note: templates are available within the dashboard scope.Click the
WITH templates
button.Enter the expression in the input field. Once done, press the
Save
button to apply the changes. For example:1 2 3 4 5 6 7
commonFilters = {instance=~"$node:$port",job=~"$job"}, # `cpuCount` is the number of CPUs on the node cpuCount = count(count(node_cpu_seconds_total{commonFilters}) by (cpu)), # `cpuIdle` is the sum of idle CPU cores cpuIdle = sum(rate(node_cpu_seconds_total{mode='idle',commonFilters}[5m]))
You can specify a comment before the variable and use markdown in it. The comment will be displayed as a hint during auto-completion. The comment can span multiple lines.
Using WITH Expressions #
After saving the template, you can enter it into the query editor field:
|
|
Thus, the entire query will look as follows:
|
|
To view the raw query in the interface, enable the Raw
toggle.
How to make new release #
- Make sure there are no open security issues.
- Change version in
package.json
in amain
branch - Push changes to the github repository and be shure that the
main
branch is up to date. - Trigger release pipeline.
- Go to releases page once pipeline is finished and verify release with the name
TAG
has been created and has all the needed binaries and checksums attached.
FAQ #
How to convert dashboard from Prometheus to VictoriaMetrics datasource? #
Make sure that VictoriaMetrics datasource plugin is installed, and a new datasource is created from the plugin.
Each panel in Grafana dashboard has a datasource dropdown when in Edit mode. Just choose the VictoriaMetrics datasource instead of Prometheus datasource in dropdown.
If datasource is configured via Grafana variable, then change variable to VictoriaMetrics datasource type.
Why VictoriaMetrics datasource doesn’t support alerting? #
Grafana doesn’t allow forwarding Alert requests to alerting API /api/v1/rules for plugins which are not of Prometheus or Loki type. See more details here.
License #
This project is licensed under the AGPL-3.0-only.