Giter Site home page Giter Site logo

victoriametrics / victoriametrics-datasource Goto Github PK

View Code? Open in Web Editor NEW
102.0 10.0 13.0 296.83 MB

Grafana datasource for VictoriaMetrics

License: GNU Affero General Public License v3.0

JavaScript 0.55% Dockerfile 0.19% TypeScript 91.56% Go 6.72% Makefile 0.92% Shell 0.06%

victoriametrics-datasource's Introduction

VictoriaMetrics datasource for Grafana

The VictoriaMetrics datasource plugin allows to query and visualize data from VictoriaMetrics in Grafana.

Motivation

Thanks to VictoriaMetrics compatibility with Prometheus API users can use Prometheus datasource for Grafana to query data from VictoriaMetrics. But with time, Prometheus and VictoriaMetrics diverge more and more. After some unexpected changes to Prometheus datasource we decided to create a datasource plugin specifically for VictoriaMetrics. The benefits of using VictoriaMetrics plugin are the following:

Installation

Installing VictoriaMetrics Grafana datasource requires the following changes to Grafana's grafana.ini config:

[plugins]
allow_loading_unsigned_plugins = victoriametrics-datasource

For grafana-operator users, please adjust config: section in your kind=Grafana resource as below

  config:
    plugins:
      allow_loading_unsigned_plugins: "victoriametrics-datasource"

See why VictoriaMetrics datasource is unsigned.

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:

apiVersion: 1

# List of data sources to insert/update depending on what's
# available in the database.
datasources:
  # <string, required> Name of the VictoriaMetrics datasource
  # displayed in Grafana panels and queries.
  - name: VictoriaMetrics
    # <string, required> Sets the data source type.
    type: victoriametrics-datasource
      # <string, required> Sets the access mode, either
      # proxy or direct (Server or Browser in the UI).
      # Some data sources are incompatible with any setting
    # but proxy (Server).
    access: proxy
    # <string> Sets default URL of the single node version of VictoriaMetrics
    url: http://victoriametrics:8428
    # <string> Sets the pre-selected datasource for new panels.
    # You can set only one default data source per organization.
    isDefault: true

    # <string, required> Name of the VictoriaMetrics datasource
    # displayed in Grafana panels and queries.
  - name: VictoriaMetrics - cluster
    # <string, required> Sets the data source type.
    type: victoriametrics-datasource
    # <string, required> Sets the access mode, either
    # proxy or direct (Server or Browser in the UI).
    # Some data sources are incompatible with any setting
    # but proxy (Server).
    access: proxy
    # <string> Sets default URL of the cluster version of VictoriaMetrics
    url: http://vmselect:8481/select/0/prometheus
    # <string> Sets the pre-selected datasource for new panels.
    # You can set only one default data source per organization.
    isDefault: false

Please find the example of provisioning Grafana instance with VictoriaMetrics datasource below:

  1. Create a file at ./provisioning/datasources/vm.yml with datasource example file.

  2. Define Grafana installation via docker-compose:

      version: '3.0'
      services:
        grafana:
          image: grafana/grafana:11.0.0
          environment:
          - GF_INSTALL_PLUGINS=https://github.com/VictoriaMetrics/victoriametrics-datasource/releases/download/v0.8.2/victoriametrics-datasource-v0.8.2.zip;victoriametrics-datasource
          - GF_PLUGINS_ALLOW_LOADING_UNSIGNED_PLUGINS=victoriametrics-datasource
          ports:
          - 3000:3000/tcp
          volumes:
          - ./provisioning:/etc/grafana/provisioning
  3. Run docker-compose file:

docker-compose -f docker-compose.yaml up

When Grafana starts successfully datasources should be present on the datasources tab

Configuration

Install in Kubernetes

Grafana helm chart

Example with Grafana helm chart:

Option 1. Using Grafana provisioning:

env:
  GF_INSTALL_PLUGINS: "https://github.com/VictoriaMetrics/victoriametrics-datasource/releases/download/v0.8.2/victoriametrics-datasource-v0.8.2.zip;victoriametrics-datasource"

Option 2. Using Grafana plugins section in values.yaml:

plugins:
  - https://github.com/VictoriaMetrics/victoriametrics-datasource/releases/download/v0.8.2/victoriametrics-datasource-v0.8.2.zip;victoriametrics-datasource

Option 3. Using init container:

extraInitContainers:
  - name: "load-vm-ds-plugin"
    image: "curlimages/curl:7.85.0"
    command: [ "/bin/sh" ]
    workingDir: "/var/lib/grafana"
    securityContext:
      runAsUser: 472
      runAsNonRoot: true
      runAsGroup: 472
    args:
     - "-c"
     - |
       set -ex
       mkdir -p /var/lib/grafana/plugins/
       ver=$(curl -s -L 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-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
    volumeMounts:
      # For grafana-operator users, change `name: storage` to `name: grafana-data`
      - name: storage
        mountPath: /var/lib/grafana

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:

sidecar:
  datasources:
    initDatasources: true
    enabled: true

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:

apiVersion: grafana.integreatly.org/v1beta1
kind: Grafana
metadata:
  name: grafana-vm
spec:
  persistentVolumeClaim:
    spec:
      accessModes:
        - ReadWriteOnce
      resources:
        requests:
          storage: 200Mi
  deployment:
    spec:
      template:
        spec:
          initContainers:
            - name: "load-vm-ds-plugin"
              image: "curlimages/curl:7.85.0"
              command: [ "/bin/sh" ]
              workingDir: "/var/lib/grafana"
              securityContext:
                runAsUser: 472
                runAsNonRoot: true
                runAsGroup: 472
              args:
                - "-c"
                - |
                  set -ex
                  mkdir -p /var/lib/grafana/plugins/
                  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-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
              volumeMounts:
                - name: grafana-data
                  mountPath: /var/lib/grafana
  config:
    plugins:
      allow_loading_unsigned_plugins: victoriametrics-datasource

See Grafana operator reference to find more about Grafana operator. This example uses init container to download and install plugin.

Dev release installation

  1. To download plugin build and move contents into Grafana plugins directory:

    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-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
  2. 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:

# Directory where Grafana will automatically scan and look for plugins
plugins = {{path to directory with plugin}}
[plugins]
allow_loading_unsigned_plugins = victoriametrics-datasource

2. Run the plugin

In the project directory, you can run:

# install dependencies
yarn install

# run the app in the development mode
yarn dev

# build the plugin for production to the `dist` folder and zip build
yarn build:zip

3. How to build backend plugin

From the root folder of the project run the following command:

make victoriametrics-backend-plugin-build

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:

make victorimetrics-frontend-plugin-build

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:

make victoriametrics-datasource-plugin-build

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

  1. Navigate to the dashboard where you want to add a template.
    Note: templates are available within the dashboard scope.

  2. Click the WITH templates button.

  3. Enter the expression in the input field. Once done, press the Save button to apply the changes. For example:

    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:

((cpuCount - cpuIdle) * 100) / cpuCount

Thus, the entire query will look as follows:

WITH (
 commonFilters = {instance=~"$node:$port",job=~"$job"},
 cpuCount = count(count(node_cpu_seconds_total{commonFilters}) by (cpu)),
 cpuIdle = sum(rate(node_cpu_seconds_total{mode='idle',commonFilters}[5m]))
)
((cpuCount - cpuIdle) * 100) / cpuCount

To view the raw query in the interface, enable the Raw toggle.

How to make new release

  1. Make sure there are no open security issues.
  2. Create a release tag:
    • git tag -s v1.xx.y in master branch
  3. Run TAG=v1.xx.y make build-release to build and package binaries in *.tar.gz release archives.
  4. Run git push origin v1.xx.y to push the tag created v1.xx.y at step 2 to public GitHub repository
  5. Go to https://github.com/VictoriaMetrics/victoriametrics-datasource/releases and verify that draft release with the name TAG has been created and this release contains all the needed binaries and checksums.
  6. Remove the draft checkbox for the TAG release and manually publish it.

FAQ

Why VictoriaMetrics datasource is unsigned?

Based on our previous experience of developing Grafana plugins the signing procedure was a formal act. But when we tried to sign the plugin we were told by GrafanaLabs representative the plugin falls into a Commercial signature level. It matters not if plugin or VictoriaMetrics itself are opensource. The announced cost of Commercial signature level was much higher than expected, so we interrupted the procedure.

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.

victoriametrics-datasource's People

Contributors

andrewchubatiuk avatar dg-nvm avatar dima-vm avatar dmitryk-dk avatar f41gh7 avatar hagen1778 avatar loori-r avatar meklick avatar sqljames avatar tenmozes avatar yincongcyincong avatar zarnovican avatar zekker6 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

victoriametrics-datasource's Issues

Proper release procedure

Please, follow the default release procedure using semver versioning.
The release procedure will help tracking the changes and fixes to the project, as well as understand in which version bugs were fixed.

Legend Auto doesn't drop common labels

As I understand, Auto legend mode should drop common labels and leave only unique. In this example, "host" is common label, but it's present in each timeseries legend.

image (1)

Builder mode's Metric Dropdown Shows "No Options Found" When Custom Query Parameters Are Configured

Exploring a VictoriaMetrics data source in Builder mode within Grafana shows "No Options Found" in the Metric dropdown when "Custom query parameters" are configured. This prevents using the Builder mode to construct queries. However, switching to Code mode and entering a MetricsQL query works.

Steps to reproduce -

  1. Add VictoriaMetrics data source to Grafana
  2. Configure "Custom query parameters" such as the following -
    extra_filters[]={cluster_name="mycluster"}
  3. Save
  4. Explore the data source
  5. Notice that the query is in Builder mode by default.
  6. The Metric dropdown shows "No Options Found" when you click on it. The expectation is that It should list metrics available similar to how it would work if "Custom query parameters" weren't configured.
  7. Switch to Code mode
  8. Enter a MetricsQL query and click "Run query".
  9. Results are returned as expected.

I'm using Grafana 10.1.5 and victoriametrics datasource plugin 0.4.0.

Add links to VMUI from the query panel

Would be nice if we can add a button to open the current query but in VMUI:
image

Since we know the datasource address, generating a VMUI link with variables replaced, step and time range should be easy.

Show query trace right in Grafana

Query panel has a toggler named Explain which doesn't seem very useful so far:
image

What if we replace this toggler with Trace functionality, which would send a trace request to VictoriaMetrics and render the output next to the query panel?

Alternatively, we can try using QueryInspector panel for showing query trace.

Support WITH templates

WITH templates in VictoriaMetrics help to simplify complex queries. Would be nice to introduce an option to define global or per-panel expressions, so users can define WITH templates once and then re-use them when needed.

Feature: Query Raw data

We are using victoria-metric for event logs.
event{eventType="1",deviceId="abcd"} 1
Data are spare.
We need display all raw sample for deviceId="abcd" and keep original timestamp. If query return too much data, we need to truncate result instead of grouping.
query_range round timestamp and group date according interval.
Would it be possible to do query on /export api as alternative to query_range?
I'm aware that export api use different syntax and is more limited.

Dashboard's JSON model inconsistency

Hello!

JSON for the freshly created dashboard, which has only 1 VictoriaMetrics data source has some inconsistencies.
Datasource is mentioned in JSON data twice, but with different types:

  1. $.panels[0].datasource.type = "victoriametrics-datasource"
  2. $.panels[0].targets.datasource.type = "prometheus"

This could potentially make any automations harder.

Dashboard example

{
  "annotations": {
    "list": [
        ///
  },
  "editable": true,
  "fiscalYearStartMonth": 0,
  "graphTooltip": 0,
  "links": [],
  "liveNow": false,
  "panels": [
    {
      "datasource": {
        "type": "victoriametrics-datasource",
        "uid": "000032369"
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisCenteredZero": false,
            "axisColorMode": "text",
            "axisLabel": "",
            "axisPlacement": "auto",
            "barAlignment": 0,
            "drawStyle": "line",
            "fillOpacity": 0,
            "gradientMode": "none",
            "hideFrom": {
              "legend": false,
              "tooltip": false,
              "viz": false
            },
            "lineInterpolation": "linear",
            "lineWidth": 1,
            "pointSize": 5,
            "scaleDistribution": {
              "type": "linear"
            },
            "showPoints": "auto",
            "spanNulls": false,
            "stacking": {
              "group": "A",
              "mode": "none"
            },
            "thresholdsStyle": {
              "mode": "off"
            }
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          }
        },
        "overrides": []
      },
      "gridPos": {
        "h": 11,
        "w": 24,
        "x": 0,
        "y": 0
      },
      "id": 2,
      "options": {
        "legend": {
          "calcs": [],
          "displayMode": "list",
          "placement": "bottom",
          "showLegend": true
        },
        "tooltip": {
          "mode": "single",
          "sort": "none"
        }
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "000032369"
          },
          "editorMode": "code",
          "expr": "emsv2_stats_open_alerts_count{}",
          "legendFormat": "__auto",
          "range": true,
          "refId": "A"
        }
      ],
      "title": "Open Alerts Count",
      "type": "timeseries"
    }
  ],
  "schemaVersion": 37,
  "style": "dark",
  "tags": [],
  "templating": {
    "list": []
  },
  "time": {
    "from": "now-6h",
    "to": "now"
  },
  "timepicker": {},
  "timezone": "",
  "title": "New dashboard",
  "version": 0,
  "weekStart": ""
}

Grafana version: 9.2.4

Redirect link for `Run in VMUI`

Hi. I would like to ask if it's possible to configure url in Run in VMUI button as in the screenshot? As a default it link to http://vm-select-cluster-victoria-metrics-cluster-vmselect:8481
image

Variable requests do not respect the time range filter

When loading Grafana dash with VM DS I notice that requests to /api/v1/series used by dashboard variable requests do not respect the selected time range:
image

When refreshing the dash I see the following requests in console:
image
image

Note the difference in start/end params for both queries.

Going from code mode in Grafana to builder mode fails to parse the query correctly

On editing queries with the query editor for dashboard panels. See screenshots.

(The below problem does not show if using a Promethes data source in Grafana, but is showing when using a VM Grafana Plugin Datasouce.)

Grafana version: Grafana v10.1.5 (849c612fcb) on Docker
Grafana datasource plugin version: 0.4.0

Expected behavior:
Putting the following query in the editor (code mode)
rate(diskio_read_bytes{host="Hostname", name=~"sd[a-z]|nvm.*"}[$__rate_interval])
and then switching to build mode. Buildmode then fails to parse the query correctly and the Rate/range drop down should be populated with the following: $__rate_interval

Actual behavior:
Putting the following query in the editor (code mode)
rate(diskio_read_bytes{host="Hostname", name=~"sd[a-z]|nvm.*"}[$__rate_interval])
and then switching to build mode. Buildmode then fails to parse the query correctly and the Rate/range drop down is populated with the following: a-z]|nvm.*"}[$__rate_interval

Steps to reproduce:

  1. Navigate to a dashboard.
  2. Add new panel.
  3. Select a Victoria Metrics datasource using the VM Datasource plugin.
  4. Make sure that the query editor is in code mode.
  5. Enter a query with an rate operation. Example rate(diskio_read_bytes{host="Hostname", name=~"sd[a-z]|nvm.*"}[$__rate_interval])
  6. Enter "builder mode" for the query editor.
image

Grafana's query builder doesn't have MetricsQL funcs

Grafana allows to use query builder for compiling the query. In the builder user can choose which functions to apply. It is expected that builder would have MetricsQL functions available for search and in list:
image

Grafana Legacy Alerting is not working

Grafana version: 9.2.4

I created 2 similar data sources but with different types (VictoriaMetrics and Prometheus).
Both are used on the same dashboards, on different panels.
Trying to create/test exactly the same alerts for each of the panels and getting the following:

Prometheus:
image

VictoriaMetrics:
image

The same errors in the logs:

logger=alerting.evalContext t=2022-11-30T11:10:13.00350573Z level=error msg="Alert Rule Result Error" ruleId=1973 name="Test alert" error="request handler error: [plugin.unavailable] plugin unavailable" changingstateto=alerting

bad gateway?

Hi
I a prometheus+grafana user and want to give this a try. But the documentation is still not good enough. I still can't query anything from Grafana.

This is my provisioning/datasources/victoriametrics.yml file:

apiVersion: 1

# List of data sources to insert/update depending on what's
# available in the database.
datasources:
   # <string, required> Name of the VictoriaMetrics datasource 
   # displayed in Grafana panels and queries.
   - name: VictoriaMetrics
      # <string, required> Sets the data source type.
     type: victoriametrics-datasource
      # <string, required> Sets the access mode, either
      # proxy or direct (Server or Browser in the UI).
      # Some data sources are incompatible with any setting
      # but proxy (Server).
     access: proxy
     # <string> Sets default URL of the single node version of VictoriaMetrics
     url: http://localhost:8428
     # <string> Sets the pre-selected datasource for new panels. 
     # You can set only one default data source per organization.
     isDefault: true

     # <string, required> Name of the VictoriaMetrics datasource 
     # displayed in Grafana panels and queries.
   - name: VictoriaMetrics - cluster
     # <string, required> Sets the data source type.
     type: victoriametrics-datasource
     # <string, required> Sets the access mode, either
     # proxy or direct (Server or Browser in the UI).
     # Some data sources are incompatible with any setting
     # but proxy (Server).
     access: proxy
     # <string> Sets default URL of the cluster version of VictoriaMetrics
     url: http://localhost:8481/select/0/prometheus
     # <string> Sets the pre-selected datasource for new panels. 
     # You can set only one default data source per organization.
     isDefault: false

image

I went into Grafan Datasource and hit "Test" and got "bad gateway" error

image

[FEATURE]: missed version & help flags output for `victoriametrics_backend_plugin_linux_amd64`

./victoriametrics_backend_plugin_linux_amd64 -h
{"@level":"info","@message":"Starting VictoriaMetrics datasource backend ...","@timestamp":"2023-04-04T11:54:11.508891+03:00"}
{"@level":"info","@message":"Profiler","@timestamp":"2023-04-04T11:54:11.509006+03:00","enabled":false}
Usage of ./victoriametrics_backend_plugin_linux_amd64:
  -standalone
    	should this run standalone
    	
./victoriametrics_backend_plugin_linux_amd64 -v
{"@level":"info","@message":"Starting VictoriaMetrics datasource backend ...","@timestamp":"2023-04-04T11:56:56.782846+03:00"}
{"@level":"info","@message":"Profiler","@timestamp":"2023-04-04T11:56:56.782923+03:00","enabled":false}
flag provided but not defined: -v
Usage of ./victoriametrics_backend_plugin_linux_amd64:
  -standalone
    	should this run standalone

 ./victoriametrics_backend_plugin_linux_amd64 -version
{"@level":"info","@message":"Starting VictoriaMetrics datasource backend ...","@timestamp":"2023-04-04T11:57:04.635319+03:00"}
{"@level":"info","@message":"Profiler","@timestamp":"2023-04-04T11:57:04.635397+03:00","enabled":false}
flag provided but not defined: -version
Usage of ./victoriametrics_backend_plugin_linux_amd64:
  -standalone
    	should this run standalone

./victoriametrics_backend_plugin_linux_amd64 --version
{"@level":"info","@message":"Starting VictoriaMetrics datasource backend ...","@timestamp":"2023-04-04T11:57:06.658022+03:00"}
{"@level":"info","@message":"Profiler","@timestamp":"2023-04-04T11:57:06.658156+03:00","enabled":false}
flag provided but not defined: -version
Usage of ./victoriametrics_backend_plugin_linux_amd64:
  -standalone
    	should this run standalone

Would be great to have this flags output which help to recognized the version of executable file and how to use them as well.

License issue

This repo contains a lot of code borrowed from the Prometheus datasource implementation at https://github.com/grafana/grafana. This violates the license of the Grafana repo https://github.com/grafana/grafana/blob/main/LICENSE.

Workarounds are the following:

  1. Re-write the implementation of core functions copied from the Prometheus datasource. Despite both VictoriaMetrics and Prometheus are providing the same HTTP API code still need to be re-written to satisfy the licensing.
  2. Change this repo license to the same license as Grafana repo has and explicitly mention the source of copied files.

"Unprocessable Entity" error for labels with dots in label_values query

Grafana Version 9.3.6 (commit: 978237e7cb, branch: HEAD)
victoriametrics-datasource @ 0.1.3

When I try to create a Grafana variable with the query label_values(my.label) or label_values(my\.label) I get the error "status": 422, "statusText": "Unprocessable Entity" in the browser console.

No data when passing label values with dot from variable

VM datasource version: 0.2.1
Grafana version: 10.0.2
VM cluster version: 1.91.3

If label's value has a dot symbol (for example, ip_address="10.0.0.1" or interface="GigabitEthernet0/1.1") and it is being passed to the dashboard from variable with label_values(), no data will be returned. At the same time, Inspect tab shows tag value with added \\\\ before the dot symbol (for example, ip_address=\"10\\\\.0\\\\.0\\\\.1\").

If you specify tag value without using variables, it is rendered in Inspect tab like ip_address=\"10.0.0.1\".

Grafana complains when plugin is loaded

WARN [12-07|11:34:02] Plugin missing module.js                 logger=plugin.loader pluginID=victoriametrics-datasource warning="Missing module.js, If you loaded this plugin from git, make sure to compile it." path=/Users/hagen/PhpstormProjects/VictoriaMetrics/grafana-datasource/dist/module.js

ERROR[12-07|11:34:12] Plugin file not found                    logger=context userId=1 orgId=1 uname=admin error="open /Users/hagen/PhpstormProjects/VictoriaMetrics/grafana-datasource/dist/img/vm_logo.svg: no such file or directory" traceID=

Grafna plugin not loading due to signature errors

Hey,
I am deploying Grafana using the helm charts. I followed the readme to add the plugin and now I am seeing this error:

grafana-85f9d7b445-lsbbc grafana logger=plugin.loader t=2023-07-25T07:08:19.151240781Z level=warn msg="Skipping loading plugin due to problem with signature" pluginID=victoriametrics-datasource status=unsigned

Grafana version: 7.85.0

I could find this thread but it seems a bit bad practice either running Grafana in dev mode or doing the allow unsigned. Have you encountered this issue before?

Default URL needs to be updated

Default URL is set to default Prometheus port.
image

Would be nice to change it to the default VM port :8428.
To the tooltip of this field would be nice to add tips&links how to setup for cluster VM - https://docs.victoriametrics.com/Cluster-VictoriaMetrics.html#url-format
Since our docs for cluster version do not contain the exact guide how to configure Grafana - we might need to add it as well. Similar to https://docs.victoriametrics.com/Single-server-VictoriaMetrics.html#grafana-setup

Label names duplicated in legend when expression is used in panel

This is a weird bug that so far, I've only been able to track down to the VictoriaMetrics datasource -- the issue disappears when using the Prometheus datasource, and does not occur if the panel doesn't contain an "expression".

This is the desired panel output, when using the Prometheus datasource:
image

However switching to the VictoriaMetrics datasource makes the legend look like this:
image
Every legend entry is duplicated!

Attempting to set the legends back to "auto" didn't work either, and I end up with __auto __auto
image

Support `limit` param for metrics discovery

Grafana's Prometheus datasource could return too many series on /api/v1/series or /api/v1/labels API and crash user's browser.
VictoriaMetrics supports limit param for these APIs - see https://docs.victoriametrics.com/#prometheus-querying-api-enhancements

VictoriaMetrics accepts limit query arg for /api/v1/labels and /api/v1/label//values handlers for limiting the number of returned entries. For example, the query to /api/v1/labels?limit=5 returns a sample of up to 5 unique labels, while ignoring the rest of labels. If the provided limit value exceeds the corresponding -search.maxTagKeys / -search.maxTagValues command-line flag values, then limits specified in the command-line flags are used.

By default, VictoriaMetrics returns time series for the last day starting at 00:00 UTC from /api/v1/series, /api/v1/labels and /api/v1/label//values, while the Prometheus API defaults to all time. Explicitly set start and end to select the desired time range. VictoriaMetrics rounds the specified start..end time range to day granularity because of performance optimization concerns. If you need the exact set of label names and label values on the given time range, then send queries to /api/v1/query or to /api/v1/query_range.

VictoriaMetrics accepts limit query arg at /api/v1/series 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 of series. If the provided limit value exceeds the corresponding -search.maxSeries command-line flag values, then limits specified in the command-line flags are used.

Would be nice if we had these limits configurable and preset in the datasource.

annotation queries do not respect `Custom query parameters`

To reproduce:
Configure VM datasource with custom query params:
image

All queries now supposed to filter metrics with job=vmalert.

Try plotting a panel to verify:
image

it works.

Add an annotation query:
image

Try plotting it on the panel:
image

It shows unflitered data.

JSON version of the trace

What do you think, can we add a button to copy JSON version of the trace into user's buffer or show a popup window with JSON representation like we do in VMUI? The purpose is to let users option to share the trace for the query.

Use label values in "Config from query results"

It would be so cool if I could write the unit for each metric into a label value and use it directly in a Grafana dashboard instead of setting the unit manually. This could also be used to set the min/max, color, and a ton of other config parameters.

Maybe I'm just stupid, but so far I could not make it work.

grafana datasource install issue

Error: container's runAsUser breaks non-root policy (pod: "grafana-6c94b9b575-whzqw_grafana(6ffc9589-d533-4064-a8b5-67ac4a6bf0aa)", container: load-vm-ds-plugin)

I added the following options to my values.yml in grafana's helm chart:

        extraInitContainers:
          - name: "load-vm-ds-plugin"
            image: "curlimages/curl:7.85.0"
            command: [ "/bin/sh" ]
            workingDir: "/var/lib/grafana/plugins"
            securityContext:
              runAsUser: 0
            args:
             - "-c"
             - |
               set -ex
               mkdir -p /var/lib/grafana/plugins/
               ver=$(curl -s https://api.github.com/repos/VictoriaMetrics/grafana-datasource/releases/latest | grep -oE 'v[0-9]+\.[0-9]+\.[0-9]+' | head -1)
               curl -L https://github.com/VictoriaMetrics/grafana-datasource/releases/download/$ver/victoriametrics-datasource-$ver.tar.gz -o /var/lib/grafana/plugins/plugin.tar.gz
               tar -xf /var/lib/grafana/plugins/plugin.tar.gz -C /var/lib/grafana/plugins/
               rm /var/lib/grafana/plugins/plugin.tar.gz
               chown -R 472:472 /var/lib/grafana/plugins/
            volumeMounts:
              - name: storage
                mountPath: /var/lib/grafana

Grafana chart version: 6.60.4

provisioning the plugin

Good evening! I have installed the plugin successfully, but not sure how to provision it correctly. previously, I was able to provision datasource using:
- name: VictoriaMetrics type: prometheus access: proxy url: http://victoriametrics:8428 isDefault: true
but it isn't configure the plugin and add another datasource. What I need to do to make the plugin works is to manually configure datasource in the plugin section and add the url, but then I got 2 datasources. Could you clarify what do I do wrong here, please?
image

Metrics browser "no metrics found"

Grafana Version 9.3.6 (commit: 978237e7cb, branch: HEAD)
victoriametrics-datasource @ 0.3.0

There is strange behavior with the metrics browser in Grafana Explore. It seems to be a bug in the VictoriaMetrics datasource plugin, as the Prometheus datasource plugin doesn't have this issue.

Steps to reproduce:

  1. Open Grafana Explore and select any VictoriaMetrics datasource. You will see "no metrics found" in the metrics browser. There are no errors in browser console.
    image
  2. Change the time interval twice, and now the metrics will be available in the metrics browser.
    image
    image

Error during data source configuration

Hello VIctoriaMetrics team.
Getting the error during the attempt of data source configuration.
Grafana version: 8.3.0.

Cannot read properties of undefined (reading 'Equal') Evaluating https://grafana-beta.some-domain.com/public/plugins/victoriametrics-datasource/module.js Loading plugins/victoriametrics-datasource/module

Screenshot 2022-11-08 at 17 30 58

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.