# Metrics

Detailed guide to understanding and using metrics for monitoring your DanubeData resources.

## Overview

Metrics provide quantitative measurements of resource performance and health over time.

## VPS Metrics

### CPU Metrics

**CPU Usage %**
- Current CPU utilization
- Range: 0-100%
- Alert: > 80% sustained

**CPU Load Average**
- System load over 1, 5, 15 minutes
- Varies by CPU count
- Alert: > CPU count

**CPU Steal**
- CPU time stolen by hypervisor (should be near 0)
- Alert: > 5%

### Memory Metrics

**Memory Usage %**
- RAM utilization
- Range: 0-100%
- Alert: > 85%

**Memory Available**
- Free memory plus cache/buffers
- Alert: < 10% of total

**Swap Usage**
- Swap space used
- Alert: > 0 (indicates memory pressure)

### Disk Metrics

**Disk I/O**
- Read/write MB/s
- IOPS (operations per second)

**Disk Usage %**
- Storage consumption
- Alert: > 85%

### Network Metrics

**Network In/Out**
- Bandwidth usage (MB/s)
- Track against allocation

**Network Packets**
- Packets per second
- Useful for diagnosing issues

## Database Metrics

### Performance Metrics

**Query Time**
- Average query execution time
- Alert: > 100ms average

**Slow Queries**
- Queries exceeding threshold
- Alert: > 10/minute

**Throughput**
- Queries per second
- Monitor for capacity planning

### Connection Metrics

**Active Connections**
- Current client connections
- Alert: > 80% of max_connections

**Connection Rate**
- New connections per second
- Alert: Sudden spikes

### Cache Metrics

**Buffer Cache Hit Rate**
- Percentage of queries served from cache
- Target: > 99%
- Alert: < 95%

**Cache Size**
- Memory used for query cache
- Monitor for sizing

### Replication Metrics

**Replication Lag**
- Delay between primary and replica
- Alert: > 5 seconds

**Replication Status**
- Connected/Disconnected status
- Alert: Disconnected

## Cache Metrics

Applies to Redis, Valkey, and Dragonfly instances.

### Memory Metrics

**Memory Usage**
- Current RAM consumption
- Alert: > 90% of allocated

**Memory Fragmentation**
- Ratio of RSS to used memory
- Alert: > 1.5 (consider restart)

**Evicted Keys**
- Keys removed due to memory pressure
- Alert: > 100/second

### Performance Metrics

**Hit Rate**
- Cache hit percentage
- Target: > 90%
- Alert: < 80%

**Operations/Sec**
- Commands processed per second
- Monitor for capacity

**Latency**
- Average command execution time
- Alert: > 10ms

### Connection Metrics

**Connected Clients**
- Active connections
- Alert: > 80% of max

**Blocked Clients**
- Clients waiting on blocking operations
- Alert: Sustained blocked clients

## Metric History

Metrics history is available for up to **7 days** per instance. The chart resolution adjusts to the range you pick — finer detail for recent windows, coarser for the full 7 days. Object storage buckets keep longer per-bucket trends of their own; see the [Object Storage](https://docs.danubedata.ro/object-storage) docs.

## API Access

Cache and database metrics are also available over the public API, so you can pull them into your own dashboards or scripts. See the [API Reference](https://docs.danubedata.ro/api-overview) for authentication and available endpoints.

## Best Practices

1. **Regular Monitoring**: Check metrics daily
2. **Set Baselines**: Know normal values
3. **Correlate Metrics**: Look at multiple metrics together
4. **Trend Analysis**: Watch for gradual changes
5. **Alert Configuration**: Set meaningful thresholds

## Related Documentation

- [Monitoring Overview](https://docs.danubedata.ro/monitoring-overview)
- [Alerting](https://docs.danubedata.ro/monitoring-alerting)
- [Logs](https://docs.danubedata.ro/monitoring-logs)
- [Uptime Checks](https://docs.danubedata.ro/monitoring-uptime)
- [Cache Monitoring](https://docs.danubedata.ro/cache-monitoring)

