📦 Logs, Lies & Elasticsearch: My First ELK Stack Attempt

📦 Logs, Lies & Elasticsearch: My First ELK Stack Attempt

I was knee-deep in someone else’s codebase, the kind of situation where you’re not sure if you're building features or just playing therapist to broken APIs.

The task? Log every error like your life depends on it.
The problem? MongoDB was barely holding it together.

🐛 So Many Errors, So Little Insight

The project was a Node.js backend, stitched together with Cursor, Clerk, and vibes. Most of the APIs were AI-generated (thanks, Cursor), but thankfully not in full alien tongue — I could follow the flow.

I was logging errors straight into MongoDB, thinking, “Great, job done.”

Wrong.

Mongo was storing logs, sure — but retrieving, visualizing, or doing literally anything with them felt like asking a brick wall to sing.

🔎 Enter ELK: The Fancy Acronym That Changed Everything

I stumbled upon ELK StackElasticsearch, Logstash, and Kibana — and honestly, it felt like opening DevOps Narnia.

Here’s why ELK > MongoDB for logs:

  • Mongo is great at storing stuff. But logs? That’s not its calling.
  • ELK is built for search, structure, and storytelling.
    • Elasticsearch: real-time full-text search on logs.
    • Logstash: ingests logs like a beast, parses and transforms them.
    • Kibana: dashboards so sexy they make spreadsheets cry.

In short: Mongo stores logs. ELK makes them speak.

🪵 And Then There Was Pino

I replaced the usual suspect (console.log or whatever logger was duct-taped in) with Pino.js — and my log game instantly leveled up.

Why Pino?

  • It’s fast (like, fast fast).
  • It outputs logs in structured JSON — perfect for feeding into Logstash.
  • It doesn't clog your runtime like heavier loggers.

Basically, Pino + ELK = logging nirvana.

😤 The Setup Struggles Were Real

Setting up the ELK stack wasn’t exactly “npm install and chill.”
I spent more time than I’d like to admit trying to configure logstash.conf, only to realize my file paths were wrong by one character. Character development, I suppose.

Docker helped. Eventually, logs started flowing like poetry — structured, searchable, and dashboarded in Kibana like a proper grown-up system.


🎯 Why You Should Bother With This

If you:

  • Build anything that runs APIs
  • Ever say “I’ll check the logs”
  • Hate debugging without context

...then you need to try the ELK stack at least once.

You’ll learn more about how your system talks — and screams — than any console.log ever will.

✍️ Final Thought

Most of us treat logs like disposable notes. But when done right, logs tell you the story of your backend — the bugs, the flows, the stuff users don’t tell you.

Setting up ELK made me feel like I wasn’t just catching errors — I was listening to my code.

Now that’s powerful.