Skip to content

Latest commit

 

History

History

livelessons-operations-cloud-monitoring

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Lesson 3: Creating Operations-Friendly Microservices (Monitoring)

Introduction

This sample shows how you can monitor your Spring Boot microservice when it is deployed to the cloud.

Prerequisites

You will need a Cloud Foundry account and the cf command line tool installed.

Building and Pushing

To build an push the application to Cloud Foundry use the following commands:

$ mvn clean package
cf push ll-cloud-monitoring -p target/livelessons-operations-cloud-monitoring-1.0.0-SNAPSHOT.jar

Updating the Health status

The /health status can be manipulated using the /up and /down request mappings in ExampleController. For example:

$ curl ll-cloud-monitoring.cfapps.io/down
$ curl ll-cloud-monitoring.cfapps.io/health

will return the status

{"status":"DOWN"}

and

$ curl ll-cloud-monitoring.cfapps.io/up
$ curl ll-cloud-monitoring.cfapps.io/health

will restore it to

{"status":"UP"}

Monitoring with pingdom.com

Pingdom is an online monitoring service that provides alerts whenever a service goes down. That also provide historical graphs for uptime information. A free “starter” account is available.

To configure pingdom, signup and login to the service then from main dashboard click the “monitoring” tab.

Click add new and use the following details:

Once added the service will take a minute or so to perform the first check. You can simulate down time to trigger alerts.

Monitoring with uptimerobot.com

UptimeRobot is another online monitoring tool that offers a free account. To get started signup then login and navigate to the dashboard. To add a monitor click “Add New Monitor” then enter the following:

You can use /down to simulate down time and trigger alerts.

New Relic

New Relic provides deep insight monitoring for your application. It’s available as a service on Cloud Foundry.

To add the service use the dashboard from run.pivotal.io or add it using the CLI:

$ cf create-service newrelic standard ll-new-relic

You now need to bind the service to your application then restage it:

$ cf bind-service ll-cloud-monitoring ll-new-relic
$ cf restage ll-cloud-monitoring

Once restaged you can click "manage" on the ll-new-relic service at run.pivotal.io to monitor the application.