2021-04-14 09:14:51 +00:00
---
2023-10-13 11:54:33 +00:00
sort: 31
weight: 31
2023-04-30 10:31:45 +00:00
title: VictoriaMetrics Cluster Per Tenant Statistic
menu:
docs:
2023-10-13 11:54:33 +00:00
parent: 'victoriametrics'
weight: 31
2023-04-30 10:31:45 +00:00
aliases:
- /PerTenantStatistic.html
2021-04-14 09:14:51 +00:00
---
2021-04-25 08:34:28 +00:00
# VictoriaMetrics Cluster Per Tenant Statistic
2021-04-14 08:17:52 +00:00
2023-10-18 18:06:23 +00:00
***The per-tenant statistic is a part of [enterprise package ](https://docs.victoriametrics.com/enterprise.html ). It is available for download and evaluation at [releases page ](https://github.com/VictoriaMetrics/VictoriaMetrics/releases/latest ). You need to request a [free trial license ](https://victoriametrics.com/products/enterprise/trial/ ) for evaluation.***
2021-06-22 09:43:01 +00:00
2023-11-22 16:22:41 +00:00
< img alt = "cluster-per-tenant-stat" src = "PerTenantStatistic-stats.webp" >
2021-04-14 08:17:52 +00:00
2021-04-25 08:34:28 +00:00
VictoriaMetrics cluster for enterprise provides various metrics and statistics usage per tenant:
2022-03-22 11:40:55 +00:00
2021-04-14 08:17:52 +00:00
- `vminsert`
2022-03-22 11:40:55 +00:00
- `vm_tenant_inserted_rows_total` - total number of inserted rows. Find out which tenant
puts the most of the pressure on the storage.
2021-04-14 08:17:52 +00:00
- `vmselect`
2022-03-22 11:40:55 +00:00
- `vm_tenant_select_requests_duration_ms_total` - query latency.
2021-04-25 08:34:28 +00:00
Helps to identify tenants with the heaviest queries.
2022-03-22 11:40:55 +00:00
- `vm_tenant_select_requests_total` - total number of requests.
2021-04-25 08:34:28 +00:00
Discover which tenant sends the most of the queries and how it changes with time.
2021-04-14 08:17:52 +00:00
- `vmstorage`
2022-03-22 11:40:55 +00:00
- `vm_tenant_active_timeseries` - number of active time series.
This metric correlates with memory usage, so can be used to find the most expensive
tenant in terms of memory.
- `vm_tenant_used_tenant_bytes` - disk space usage. Helps to track disk space usage
2021-04-25 08:34:28 +00:00
per tenant.
2022-03-22 11:40:55 +00:00
- `vm_tenant_timeseries_created_total` - number of new time series created. Helps to track
2021-04-25 08:34:28 +00:00
the churn rate per tenant, or identify inefficient usage of the system.
2021-04-14 08:17:52 +00:00
2022-03-22 11:40:55 +00:00
Collect the metrics by any scrape agent you like (`vmagent`, `victoriametrics` , Prometheus, etc) and put into TSDB.
2021-04-25 08:34:28 +00:00
It is ok to use existing cluster for storing such metrics, but make sure to use a different tenant for it to avoid collisions.
2023-05-10 07:50:41 +00:00
Or just run a separate TSDB (VM single, Prometheus, etc.) to keep the data isolated from the main cluster.
2021-04-14 08:17:52 +00:00
2022-03-22 11:40:55 +00:00
Example of the scraping configuration for statistic is the following:
2021-04-14 08:17:52 +00:00
```yaml
scrape_configs:
- job_name: cluster
scrape_interval: 10s
static_configs:
- targets: ['vmselect:8481','vmstorage:8482','vminsert:8480']
```
2021-04-25 08:34:28 +00:00
## Visualization
2021-04-14 08:17:52 +00:00
2024-01-21 22:09:19 +00:00
Use [this dashboard ](https://grafana.com/grafana/dashboards/16399 ) for visualizing per-tenant statistics in Grafana.
2021-04-14 08:17:52 +00:00
2021-04-25 08:34:28 +00:00
## Integration with vmgateway
2021-04-14 08:17:52 +00:00
2022-03-22 11:40:55 +00:00
`vmgateway` supports integration with Per Tenant Statistics data for rate limiting purposes.
2021-04-25 08:34:28 +00:00
More information can be found [here ](https://docs.victoriametrics.com/vmgateway.html )
2021-04-14 08:17:52 +00:00
2021-04-25 08:34:28 +00:00
## Integration with vmalert
2021-04-14 08:17:52 +00:00
2022-03-22 11:40:55 +00:00
You can generate alerts based on each tenant's resource usage and send notifications
2021-04-25 08:34:28 +00:00
to prevent limits exhaustion.
2021-04-14 08:17:52 +00:00
2021-04-25 08:34:28 +00:00
Here is an alert example for high churn rate by the tenant:
2021-04-14 08:17:52 +00:00
2022-05-16 07:27:19 +00:00
{% raw %}
2021-04-14 08:17:52 +00:00
```yaml
- alert: TooHighChurnRate
expr: |
(
sum(rate(vm_tenant_timeseries_created_total[5m])) by(accountID,projectID)
/
sum(rate(vm_tenant_inserted_rows_total[5m])) by(accountID,projectID)
) > 0.1
for: 15m
labels:
severity: warning
annotations:
summary: "Churn rate is more than 10% for the last 15m"
2021-04-14 15:44:24 +00:00
description: "VM constantly creates new time series in the tenant: {{ $labels.accountID }}:{{ $labels.projectID }}.\n
2021-04-14 08:17:52 +00:00
This effect is known as Churn Rate.\n
2021-04-14 15:44:24 +00:00
High Churn Rate is tightly connected with database performance and may
2021-04-14 08:17:52 +00:00
result in unexpected OOM's or slow queries."
```
2022-05-16 07:27:19 +00:00
{% endraw %}