Skip to main content
This guide walks you through building a complete observability stack with Prometheus for metrics, Loki for logs, Grafana for visualization, and Alertmanager for notifications.

Building a Monitoring Stack on Ankra

AI Prompts

Use these prompts with the AI Assistant (⌘+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)

Step 1: Create the Stack

1

Open Stack Builder

Navigate to your cluster → StacksCreate Stack.
2

Name Your Stack

Name it 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.
1

Add the Chart

Click + Add → search for kube-prometheus-stack from the Prometheus Community repository.
2

Configure Prometheus

Click the component and set these values:
3

Configure Grafana

4

Configure Alertmanager for Slack

Encrypt sensitive values with SOPS: In the manifest edit view, click the SOPS button to encrypt secrets like grafana.adminPassword and slack_api_url. This ensures sensitive values are stored encrypted in your GitOps repository. See SOPS Encryption for setup instructions.

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.
1

Add Loki

Click + Add → search for loki from the Grafana repository.Use the loki chart (not loki-distributed for simpler setups).
2

Configure Loki

3

Connect Dependency

In the Stack Builder, draw a connection from loki to kube-prometheus-stack to ensure Loki deploys first (so Grafana can connect to it).

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.
1

Add Promtail

Click + Add → search for promtail from the Grafana repository.
2

Configure Promtail

3

Connect Dependency

Draw a connection from promtail to loki-Promtail needs Loki running to ship logs.

Step 5: Deploy

1

Review the Stack

Your Stack Builder should show:
This ensures correct deployment order.
2

Save and Deploy

Click Save, then Deploy. Watch progress in Operations.
3

Verify Deployment

After 3-5 minutes, all pods should be running:
  • prometheus-*
  • grafana-*
  • alertmanager-*
  • loki-*
  • promtail-* (one per node)

Step 6: Explore in Grafana

1

Access Grafana

Port-forward to access locally:
Or configure an ingress in the values.
2

Log In

  • Username: admin
  • Password: The value you set in grafana.adminPassword
3

Query Metrics

Go to Explore → Select Prometheus → Try:
4

Query Logs

Go to Explore → Select Loki → Try:
5

Correlate Metrics and Logs

The power of this stack: when you see a spike in metrics, click through to see logs from that exact time range.

Production Considerations

For clusters generating >100GB/day of logs, use distributed mode:
Pre-compute expensive queries:
Set how long Loki keeps logs:

Adding Custom Alerts


Troubleshooting

  1. Check Promtail pods are running on all nodes:
  2. Check Promtail logs for errors:
  3. Verify Loki is reachable from Promtail:
  1. Verify the Loki data source URL matches your service name
  2. Check Loki gateway is running:
  3. Test from Grafana pod:
  • 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 pipelineStages to drop verbose logs
  1. Add more labels in Promtail for better filtering
  2. Use time range filters in queries
  3. 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:
The AI provides recommendations for components, dependencies, and values. Just describe what you need, build based on the guidance, and deploy.

Next Steps

Configure Ankra Alerts

Set up Ankra alerts alongside Prometheus Alertmanager.

GitOps Sync

Store your observability stack configuration in Git.

Add Tracing

Complete the observability trifecta with Tempo for distributed tracing.

Explore with AI

Use the AI to query your logs and metrics in natural language.