Building a Monitoring Stack on Ankra
AI Prompts
⌘+J) to get recommendations for building your stack.What You’ll Build
A production-ready observability stack:Prerequisites
- A cluster imported into Ankra with the agent connected
- Helm registries added for:
- Prometheus Community (
https://prometheus-community.github.io/helm-charts) - Grafana (
https://grafana.github.io/helm-charts)
- Prometheus Community (
Step 1: Create the Stack
Open Stack Builder
Name Your Stack
observability or monitoring-and-logging.Step 2: Add kube-prometheus-stack
This chart bundles everything you need for metrics: Prometheus, Grafana, Alertmanager, node-exporter, and kube-state-metrics.Add the Chart
kube-prometheus-stack from the Prometheus Community repository.Configure Prometheus
Configure Grafana
Configure Alertmanager for Slack
Step 3: Add Loki for Logs
Loki is a log aggregation system designed to work seamlessly with Grafana. It’s lightweight because it only indexes metadata, not the full log content.Add Loki
loki from the Grafana repository.Use the loki chart (not loki-distributed for simpler setups).Configure Loki
Connect Dependency
Step 4: Add Promtail for Log Collection
Promtail runs as a DaemonSet on every node, collecting logs from all pods and shipping them to Loki.Add Promtail
promtail from the Grafana repository.Configure Promtail
Connect Dependency
Step 5: Deploy
Review the Stack
Save and Deploy
Verify Deployment
prometheus-*grafana-*alertmanager-*loki-*promtail-*(one per node)
Step 6: Explore in Grafana
Access Grafana
Log In
- Username:
admin - Password: The value you set in
grafana.adminPassword
Query Metrics
Query Logs
Correlate Metrics and Logs
Production Considerations
Scale Loki for High Volume
Scale Loki for High Volume
Increase Prometheus Retention
Increase Prometheus Retention
Add Recording Rules
Add Recording Rules
Configure Log Retention
Configure Log Retention
Adding Custom Alerts
Pod Restart Alert
Pod Restart Alert
High Error Rate Alert
High Error Rate Alert
Disk Space Alert
Disk Space Alert
Troubleshooting
Logs Not Appearing in Loki
Logs Not Appearing in Loki
- Check Promtail pods are running on all nodes:
- Check Promtail logs for errors:
- Verify Loki is reachable from Promtail:
Grafana Can't Connect to Loki
Grafana Can't Connect to Loki
- Verify the Loki data source URL matches your service name
- Check Loki gateway is running:
- Test from Grafana pod:
High Memory Usage
High Memory Usage
- Prometheus: Reduce scrape frequency, shorten retention, drop unused metrics
- Loki: Reduce retention period, use object storage instead of filesystem
- Promtail: Limit which logs are collected using
pipelineStagesto drop verbose logs
Slow Log Queries
Slow Log Queries
- Add more labels in Promtail for better filtering
- Use time range filters in queries
- For production, use Loki distributed mode with more queriers
AI Prompts
Press⌘+J to open the AI Assistant and use these prompts to get recommendations for your stack:
Complete Observability Stack
Complete Observability Stack
Production Stack with Object Storage
Production Stack with Object Storage
Lightweight Stack for Dev Clusters
Lightweight Stack for Dev Clusters
Add Logging to Existing Prometheus
Add Logging to Existing Prometheus
Debug Log Collection Issues
Debug Log Collection Issues