> ## Documentation Index
> Fetch the complete documentation index at: https://docs.keephq.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Victoriametrics Provider

> The VictoriametricsProvider allows you to fetch alerts in Victoriametrics.

## Authentication

This provider requires authentication.

* **VMAlertHost**: The hostname or IP address where VMAlert is running (required: False, sensitive: False)
* **VMAlertPort**: The port number on which VMAlert is listening (required: False, sensitive: False)
* **VMAlertURL**: The full URL to the VMAlert instance. Alternative to Host/Port (required: False, sensitive: False)
* **VMBackendHost**: The hostname or IP address where VictoriaMetrics backend is running (required: False, sensitive: False)
* **VMBackendPort**: The port number on which VictoriaMetrics backend is listening (required: False, sensitive: False)
* **VMBackendURL**: The full URL to the VictoriaMetrics backend. Alternative to Host/Port (required: False, sensitive: False)
* **BasicAuthUsername**: Username for basic authentication (required: False, sensitive: False)
* **BasicAuthPassword**: Password for basic authentication (required: False, sensitive: True)
* **SkipValidation**: Enter 'true' to skip validation of authentication (required: False, sensitive: False)
* **insecure**: Skip TLS verification (required: False, sensitive: False)

Certain scopes may be required to perform specific actions or queries via the provider. Below is a summary of relevant scopes and their use cases:

* **connected**: The user can connect to the client (mandatory)

## In workflows

This provider can be used in workflows.

As "step" to query data, example:

```yaml theme={null}
steps:
    - name: Query victoriametrics
      provider: victoriametrics
      config: "{{ provider.my_provider_name }}"
      with:
        query: {value}  
        start: {value}  
        end: {value}  
        step: {value}  
        queryType: {value}  
```

Check the following workflow examples:

* [create\_alert\_from\_vm\_metric.yml](https://github.com/keephq/keep/blob/main/examples/workflows/create_alert_from_vm_metric.yml)
* [create\_multi\_alert\_from\_vm\_metric.yml](https://github.com/keephq/keep/blob/main/examples/workflows/create_multi_alert_from_vm_metric.yml)
* [query\_victoriametrics.yml](https://github.com/keephq/keep/blob/main/examples/workflows/query_victoriametrics.yml)

## Connecting via Webhook (omnidirectional)

This provider takes advantage of configurable webhooks available with Prometheus Alertmanager. Use the following template to configure AlertManager:

```
route:
  receiver: "keep"
  group_by: ['alertname']
  group_wait:      15s
  group_interval:  15s
  repeat_interval: 1m
  continue: true

receivers:
- name: "keep"
  webhook_configs:
  - url: 'KEEP_BACKEND_URL/alerts/event/victoriametrics'
    send_resolved: true
    http_config:
      basic_auth:
        username: api_key
        password: {api_key}

```

## Connecting with the Provider

1. Ensure you have a running instance of VMAlert accessible by the host and port specified.
2. Include the host and port information in your Victoriametrics provider configuration when initializing the provider.

## Querying Victoriametrics

The Victoriametrics provider allows you to query from Victoriametrics through `query` and `query_range` types. The following are the parameters available for querying:

1. `query` type:

   * `query`: The query to execute on Victoriametrics. Example: `sum(rate(http_requests_total{job="api-server"}[5m]))`.
   * `start`: The time to query the data for. Example: `2024-01-01T00:00:00Z`

2. `query_range` type:
   * `query`: The query to execute on Victoriametrics. Example: `sum(rate(http_requests_total{job="api-server"}[5m]))`.
   * `start`: The start time to query the data for. Example: `2024-01-01T00:00:00Z`
   * `end`: The end time to query the data for. Example: `2024-01-01T00:00:00Z`
   * `step`: The step size to use for the query. Example: `15s`

## Useful Links

* [Victoriametrics](https://victoriametrics.com/docs/)
* [VMAlert](https://victoriametrics.github.io/vmalert.html)
