Monitoring Coherence in Docker with Grafana

Coherence provides the ability to expose Metrics via HTTP in a number of formats, Prometheus being the default. With this feature it is very easy to monitor a Coherence using Grafana.

In this post I will show you how to run the Coherence Docker image and view metrics via Grafana using docker-compose to start the following images:

  • Coherence Community Edition (CE) version 20.12
  • Grafana
  • Prometheus

The Docker images will expose the following ports:

  • Coherence
    • 1408 – gRPC Proxy port
    • 9612 – Coherence metrics endpoint to be scraped by Prometheus
    • 20000 – Coherence*Extend port
    • 30000 – Management over REST port
  • Grafana
    • 3000 – Grafana UI
  • Prometheus
    • 9090 – Prometheus UI

For more information please see https://github.com/tmiddlet2666/coherence-docker-metrics

What will you need?

  • Docker Desktop for Mac or the equivalent Docker environment for you O/S.
  • docker-compose
  • Git

Clone the example repository

git clone https://github.com/tmiddlet2666/coherence-docker-metrics.git
cd coherence-docker-metrics

Download the Grafana Dashboards

For Linux or Mac run the following to download the dashboards from the Coherence Operator GithHub page.

cd coherence-docker-metrics/grafana
./download-dashboard.sh
cd ..

For Windows:

  1. Clone the Coherence Operator repository – https://github.com/oracle/coherence-operator.git
  2. Copy all the *.json files from coherence-operator\dashboards\grafana to the directory grafana\dashboards under cloned coherence-docker-metrics repository.

Start the Docker Containers

from the coherence-docker-metrics directory run:

docker-compose up -d
Creating coherence-docker-metrics_grafana_1    ... done
Creating coherence-docker-metrics_coherence_1  ... done
Creating coherence-docker-metrics_prometheus_1 ... done

docker ps --format '{{ .ID }}\t{{.Image}}\t{{ .Names }}'

8067f3e38f61	grafana/grafana	coherence-docker-metrics_grafana_1
7bef8a89862f	prom/prometheus	coherence-docker-metrics_prometheus_1
07aeb39eb036	oraclecoherence/coherence-ce:20.12	coherence-docker-metrics_coherence_1

Note: I have included abbreviated output above but you can use docker ps to show the full output.

Access Grafana

Access the Grafana Dashboard using the following URL: http://localhost:3000/d/coh-main/coherence-dashboard-main

Default username/password is admin/admin

Main Dashboard

You can now explore the metrics exposes via Coherence.

How it Works

If you take a look at the docker-compose.yaml file you will see a number of sections for each of the Docker Images.

Coherence

The Coherence image exposes metrics via setting the coherence.metrics.http.enabled=true and ensures that the default metrics port, 9612 is exposed amongst other ports 30000 for management over REST, 20000 for Coherence*Extend and 1408 for gRPC proxy.

coherence:
  image: oraclecoherence/coherence-ce:20.12
  environment:
    - coherence.member=storage
    - coherence.machine=localhost
    - coherence.metrics.http.enabled=true
  ports:
    - 30000:30000
    - 20000:10000
    - 1408:1408
    - 9612:9612

Prometheus

The Prometheus image includes the /prometheus/prometheus.yaml file and exposes the 9090 port.

prometheus:
  image: prom/prometheus
  volumes:
    - ./prometheus/prometheus.yaml:/etc/prometheus/prometheus.yaml
  command:
    - '--config.file=/etc/prometheus/prometheus.yaml'
  ports:
    - 9090:9090

The prometheus.yaml file contains the following to scrape the default Coherence metrics port every 15s:


global:
  scrape_interval: 15s

scrape_configs:
  - job_name: 'Prometheus'
    static_configs:
      - targets: ["localhost:9090"]
  - job_name: 'coherence_cluster'
    static_configs:
      - targets: ["172.17.0.1:9612"]

Grafana

Finally, the Grafana image creates a Prometheus datasource and loads the Dashboards:

grafana:
  image: grafana/grafana
  volumes:
    - ./grafana/grafana.ini:/etc/grafana/grafana.ini
    - ./grafana/datasources.yaml:/etc/grafana/provisioning/datasources/datasources.yaml
    - ./grafana/dashboards.yaml:/etc/grafana/provisioning/dashboards/dashboards.yaml
    - ./grafana/dashboards:/etc/grafana/provisioning/dashboards/dashboards
  ports:
    - 3000:3000

Conclusion

You can see from the above that it is very easy to expose and captures the metrics from a Coherence Cluster. For more information see the following:

Enjoy!

This entry was posted in Examples and tagged , , , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s