TSDB & RAM Tuning
Controlling Label Cardinality in Grafana Alloy & Promtail
Drop high-cardinality labels before HTTP push to keep active TSDB streams under 15,000 and prevent ingester heap bloat.
<10k Streams = Healthy · >50k Streams = OOM Risk
Every Extra Label Value Multiplies Streams
Each unique combination of label key=value pairs spawns an independent chunk stream in Loki RAM. Five apps x 3 envs x 1,000 ephemeral pod names equals 15,000 streams immediately.
Batching 1 MB Snappy Payloads
Configure batchwait: 1s and batchsize: 1048576 in Alloy/Promtail so agents compress 1,000+ log lines per HTTP POST instead of hammering Loki per line.
Measured Thresholds & Loki TSDB Parameters
| Field Type | Correct Placement | Memory Impact |
|---|---|---|
| env, cluster, namespace, app | Indexed Stream Labels | Low cardinality (< 5,000 streams) |
| trace_id, pod_uid, node_ip | structured_metadata (Loki 3.x) | Zero stream multiplication in ingester |
| http_path, query_string | Parse at Query Time (LogQL) | Zero upfront index/RAM overhead |