2021-04-14 09:14:51 +00:00
---
sort: 10
---
2021-04-14 15:44:24 +00:00
## VictoriaMetrics Cluster Per Tenant Statistic
2021-04-14 08:17:52 +00:00
< img alt = "cluster-per-tenant-stat" src = "per-tenant-stats.jpg" >
2021-04-14 15:44:24 +00:00
The enterprise version of VictoriaMetrics cluster exposes the usage statistics for each tenant.
2021-04-14 08:17:52 +00:00
2021-04-14 15:44:24 +00:00
When the next statistic is exposed:
2021-04-14 08:17:52 +00:00
- `vminsert`
* `vm_tenant_inserted_rows_total` - the ingestion rate by tenant
- `vmselect`
2021-04-14 15:44:24 +00:00
* `vm_tenant_select_requests_duration_ms_total` - query latency by tenant. It can be useful to identify the tenant with the heaviest queries
* `vm_tenant_select_requests_total` - total requests. You can calculate request rate (qps) with this metric
2021-04-14 08:17:52 +00:00
- `vmstorage`
* `vm_tenant_active_timeseries` - the number of active timeseries
2021-04-14 15:44:24 +00:00
* `vm_tenant_used_tenant_bytes` - the disk space consumed by the metrics for a particular tenant
2021-04-14 08:17:52 +00:00
* `vm_tenant_timeseries_created_total` - the total number for timeseries by tenant
2021-04-14 15:44:24 +00:00
The information should be scraped by the agent (`vmagent`, `victoriametrics` , prometheus, etc) and stored in the TSDB. This can be the same cluster but a different tenant however, we encourage the use of one more instance of TSDB (more lightweight, eg. VM single) for the monitoring of monitoring.
2021-04-14 08:17:52 +00:00
2021-04-14 15:44:24 +00:00
the config example for statistic scraping
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']
```
### Visualization
2021-04-14 15:44:24 +00:00
Visualisation of statistics can be done in Grafana using this dashboard [link ](https://github.com/VictoriaMetrics/VictoriaMetrics/tree/cluster/dashboards/clusterbytenant.json )
2021-04-14 08:17:52 +00:00
2021-04-14 09:14:51 +00:00
### Integration with vmgateway
2021-04-14 08:17:52 +00:00
2021-04-14 15:44:24 +00:00
Per Tenant Statistics are the source data for the `vmgateway` rate limiter. More information can be found [here ](https://victoriametrics.github.io/vmgateway.html )
2021-04-14 08:17:52 +00:00
2021-04-14 09:14:51 +00:00
### Integration with vmalert
2021-04-14 08:17:52 +00:00
2021-04-14 15:44:24 +00:00
You can generate alerts based on each tenants' resource usage and notify the system/users that they are reaching the limits.
2021-04-14 08:17:52 +00:00
2021-04-14 15:44:24 +00:00
Here is an example of an alert for high churn rate by the tenant
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."
```