Skip to main content

๐Ÿš€ Spring Boot Actuator Explained: Health ๐Ÿฉบ, Metrics ๐Ÿ“Š & Info โ„น️ Endpoints with Examples!

๐ŸŒŸ Exploring Spring Boot Actuator Endpoints: health, metrics & info ๐Ÿš€

Spring Boot Actuator exposes many useful endpoints for monitoring your app. Among the most popular are health, metrics, and info. Let's break them down with simple examples and understand why each is like the superhero of your app's backstage! ๐Ÿฆธ‍♂️๐Ÿฆธ‍♀️


1️⃣ Health Endpoint ๐Ÿฉบ

The /actuator/health endpoint tells you whether your app is UP and running fine or if something is DOWN and broken. Think of it as your app's doctor giving you a quick check-up.

{

  "status": "UP",

  "components": {

    "db": {

      "status": "UP",

      "details": {

        "database": "PostgreSQL",

        "result": 1

      }

    },

    "diskSpace": {

      "status": "UP",

      "details": {

        "total": 499963174912,

        "free": 389963174912,

        "threshold": 10485760

      }

    }

  }

}

Joke time: Why don’t programmers like nature? It has too many bugs! ๐Ÿž๐Ÿ˜†


2️⃣ Metrics Endpoint ๐Ÿ“Š

The /actuator/metrics endpoint is like your app’s fitness tracker. It records tons of numbers about your app’s performance — CPU usage, memory, HTTP requests, garbage collection stats, and more.

Example output for JVM memory metrics:

{

  "name": "jvm.memory.used",

  "measurements": [

    { "statistic": "COUNT", "value": 120 },

    { "statistic": "TOTAL", "value": 12345678 },

    { "statistic": "MAX", "value": 9876543 }

  ],

  "availableTags": [

    { "tag": "area", "values": ["heap", "nonheap"] },

    { "tag": "id", "values": ["PS Eden Space", "Code Cache"] }

  ]

}

Fun fact: Java developers love metrics so much, they measure their coffee intake too ☕๐Ÿ“ˆ!


3️⃣ Info Endpoint โ„น️

The /actuator/info endpoint provides static or dynamic information about your application — version number, description, build time, or any custom info you want to expose.

Here’s a simple example configured via application.properties or application.yml:

{

  "app": {

    "name": "MyAwesomeApp",

    "version": "1.2.3",

    "description": "The coolest Spring Boot app in town!"

  }

}

Quick tip: Use info.app.version from your CI/CD pipeline to track deployments!

Joke break: Why did the Java developer go broke? Because he used up all his cache! ๐Ÿ’ธ๐Ÿ˜‚


๐Ÿ› ️ Creating Your Own Custom Health Endpoint

Spring Boot Actuator lets you create custom health checks to monitor anything important for your app — like an external API, cache, or custom service.

How to do it? Simply implement the HealthIndicator interface and override health() method.

import org.springframework.boot.actuate.health.Health;

import org.springframework.boot.actuate.health.HealthIndicator;

import org.springframework.stereotype.Component;

@Component

public class ExternalApiHealthIndicator implements HealthIndicator {

    @Override

    public Health health() {

        boolean apiIsUp = checkExternalApi();

        if (apiIsUp) {

            return Health.up().withDetail("External API", "Available").build();

        } else {

            return Health.down().withDetail("External API", "Not reachable").build();

        }

    }

    private boolean checkExternalApi() {

        // Replace with real API ping check

        return true; // assuming API is up

    }

}

When you call /actuator/health, your custom health status will appear like this:

{

  "status": "UP",

  "components": {

    "externalApiHealthIndicator": {

      "status": "UP",

      "details": {

        "External API": "Available"

      }

    },

    ...

  }

}

Joke break: Why did the health check fail? Because it forgot to ping the coffee machine ☕๐Ÿ’ฅ!


๐ŸŽฏ Wrapping Up

To sum up:

  • Health = The app's heartbeat ๐Ÿซ€
  • Metrics = The app's workout stats ๐Ÿ‹️‍♂️
  • Info = The app's ID card ๐Ÿ†”
They work together to help you keep your app running smoothly and make your life as a developer or operator easier!

Start using these actuator endpoints today and feel like a superhero in your own production world! ๐Ÿฆธ‍♂️๐Ÿฆธ‍♀️

Comments

Popular posts from this blog

๐Ÿ” Is final Really Final in Java? The Truth May Surprise You ๐Ÿ˜ฒ

๐Ÿ’ฌ “When I was exploring what to do and what not to do in Java, one small keyword caught my eye — final . I thought it meant: locked, sealed, frozen — like my fridge when I forget to defrost it.”   But guess what? Java has its own meaning of final… and it’s not always what you expect! ๐Ÿ˜… Let’s break it down together — with code, questions, confusion, jokes, and everything in between. ๐ŸŽฏ The Confusing Case: You Said It's Final... Then It Changed?! ๐Ÿซ  final List<String> names = new ArrayList <>(); names.add( "Anand" ); names.add( "Rahul" ); System.out.println(names); // [Anand, Rahul] ๐Ÿคฏ Hold on... that’s final , right?! So how on earth is it still changing ? Time to dive deeper... ๐Ÿง  Why Is It Designed Like This? Here’s the key secret: In Java, final applies to the reference , not the object it points to . Let’s decode this like a spy mission ๐Ÿ•ต️‍♂️: Imagine This: final List<String> names = new ArrayList <>(); Be...

๐ŸŒŸ My Journey – From Zero to Senior Java Tech Lead ๐ŸŒŸ

 There’s one thing I truly believe… If I can become a Java developer, then anyone in the world can. ๐Ÿ’ฏ Sounds crazy? Let me take you back. ๐Ÿ•“ Back in 2015… I had zero coding knowledge . Not just that — I had no interest in coding either. But life has its own plans. In 2016, I got a chance to move to Bangalore and joined a Java course at a training center. That’s where it all started — Every day, every session made me feel like: "Ohhh! Even I can be a developer!" That course didn’t just teach Java — it gave me confidence . ๐Ÿงช Two Life-Changing Incidents 1️⃣ The Interview That Wasn't Planned Halfway through my course, I had to urgently travel to Chennai to donate blood to a family member. After that emotional rollercoaster, I found myself reflecting on my skills and the future. The next day, as I was preparing for my move to Bangalore to complete the remaining four months of my course, I randomly thought — "Let me test my skills... let me just see...

๐ŸŽข Java Loops: Fun, Fear, and ForEach() Fails

๐ŸŒ€ Oops, I Looped It Again! — The Ultimate Java Loop Guide You Won't Forget “I remember this question from one of my early interviews — I was just 2 years into Java and the interviewer asked, ‘Which loop do you prefer and why?’” At first, I thought, “Duh! for-each is cleaner.” But then he grilled me with cases where it fails. ๐Ÿ˜ต That led me to explore all loop types, their powers, and their pitfalls. Let’s deep-dive into every major Java loop with examples &  real-world guidance so you'll never forget again. ๐Ÿ” Loop Type #1: Classic For Loop — “The Old Reliable” ✅ When to Use: You need an index You want to iterate in reverse You want full control over loop mechanics ✅ Good Example: List<String> names = List.of("A", "B", "C"); for (int i = 0; i < names.size(); i++) { System.out.println(i + ": " + names.get(i)); } ๐Ÿ”ฅ Reverse + Removal Example: List<String> item...