Migrate application logs from a self-hosted ELK stack to Grafana Loki. How do you do it without losing logs?

IntermediateScenarioMigrations
Answer

Situation read → ELK is usually being replaced because of cost and operational load (JVM heap, shard tuning). The risk is a gap in logs during the switch, and dashboards and alerts that silently stop working.

What I'd do →

  1. Inventory what depends on Elasticsearch: Kibana dashboards, saved searches, alert rules, and anyone querying the API directly.
  2. Dual-ship first. Point the collector (Fluent Bit, Vector or Grafana Alloy) at both outputs so Loki fills up while ELK stays the source of truth.
[OUTPUT]
    Name   loki
    Match  kube.*
    Host   loki-gateway.monitoring.svc
    Port   80
    Labels job=fluent-bit, namespace=$kubernetes['namespace_name'], app=$kubernetes['labels']['app']
  1. Design labels carefully: low cardinality only (namespace, app, env). Never put request IDs or user IDs in labels; Loki indexes labels, not content.
  2. Rebuild the top dashboards and alerts in LogQL, and have each team sign off on theirs.
  3. Run both for one full retention window, then stop shipping to ELK and keep a snapshot of the old indices in S3 for compliance.

Why → Dual-shipping removes the "gap" risk and lets you compare query results side by side before cutting over.

Interview tip → Say "Loki indexes labels, not log lines", and explain that high-cardinality labels are the most common way to break it.

All Real-World Interview questions Roadmap: Interview readiness

More on Migrations