WSO2 MI + New Relic Monitoring

Isuru Liyanage
CodeBlog
Published in
3 min readMay 26, 2022

Hi Guys! In this blog i’m going to show you how to connect New Relic Dashboard with WSO2 Micro Integrator. Trust me its very simple.

There are two ways of configuring New relic with Prometheus

  1. Prometheus remote write integration
  2. Prometheus OpenMetrics integrations (New Relic’s Prometheus OpenMetrics integrations for Docker and Kubernetes)

So in this post we are going to check Prometheus remote write integration method.

Overview Diagram :

overview

Lets see what we need before we start

Prerequisite :

  • WSO2 MI server (will be using the latest MI 4.1.0 )[1]
  • Prometheus [2]
  • New Relic Account[3]

1st Enable Observability In MI

We need to enable the observability in MI server.
To enable observability for the Micro Integrator servers, add the following Synapse handler to the deployment.toml file (stored in the <MI_HOME>/conf/ folder).

[[synapse_handlers]]
name="CustomObservabilityHandler"
class="org.wso2.micro.integrator.observability.metric.handler.MetricHandler"

After applying the above change, you can start the Micro Integrator with the following JVM property:

-DenablePrometheusApi=true

2 nd Step : Lets Setup Prometheus

We are using Prometheus to scrape the metric from WSO2 MI server and from Prometheus it will push the metrics to New Relic Dashboard.

  1. Download Prometheus from the Prometheus site.
  2. Extract the downloaded file and navigate to that directory.
  3. Open the <PROMETHEUS_HOME>/prometheus.yml file, and in the scrape_configs section, add a configuration as follows:
global:
scrape_interval: 15s
evaluation_interval: 15s

scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['localhost:9090']
- job_name: esb_stats
metrics_path: /metric-service/metrics
static_configs:
- targets: ['localhost:9201']

4. Start the Prometheus server using below command

./prometheus --config.file=prometheus.yml

5. Now access the Prometheus dashboard using http://localhost:9090/targets
You will see your MI server in the target list as below

Prometheus Dashboard

3rd Step : Create a New Relic Account and Connect to Prometheus

Lets create a New Relic account from here.
After creating a New Relic account you just need to follow the steps given by New relic to generate a token for your Prometheus. You can find the steps here.

You will get a page as below. Follow the steps mentioned in the page

New Relic connect with Prometheus

They will give you the bearer_token config to add it to the Prometheus configuration file “prometheus.yml”.
Add it to the prometheus.yml file and restart the Prometheus server with below command again.

./prometheus --config.file=prometheus.yml

Now go back to the New Relic page and press Check your data. You will get below message saying data received successfully from the Prometheus server.

Now lets press Explore your data :).

You will see a nice dashboard showing all the scraped metrics from the WSO2 MI server by the Prometheus server.

Heap Object Diagram

See its simple only 3 steps :D.
I hope y’all learn something from this post.
Happy Coding !!

[1].https://wso2.com/integration/micro-integrator/

[2].https://prometheus.io/download/

[3].https://newrelic.com/

--

--