Sunday, July 25, 2021

Liferay Portal Monitoring with Prometheus

Prometheus is popular opensource monitoring tool. It can monitor applications with help of JMX Exporter Java agent.

This Article demonstrate the Liferay Portal Server Monitoring with Prometheus.


Install Liferay Cluster


  • Download JMX Exporter
  • Configure JMX Exporter for Liferay Portal Servers
  • Start Liferay Portal with JMX Exporter Agent
  • Install Prometheus
  • Configure Prometheus scrape for Liferay Portal Servers
  • Verify Liferay Cluster in Prometheus



Download JMX Exporter

Download JMX Exporter jar file from following location.

Direct link for latest JMX Exporter JAR




Download and get the jar to local directory.



Configure JMX Exporter for Liferay Portal Server

We need to configure the exporter configuration for Liferay Portal Server such a way JMX agent exports the required metrics from Liferay Portal Server.

Get the following JMX Exporter configuration file from below location and place it in local drive.




We can use below one too.



lowercaseOutputLabelNames: true

lowercaseOutputName: true


- pattern: 'Catalina<type=GlobalRequestProcessor, name=\"(\w+-\w+)-(\d+)\"><>(\w+):'

  name: tomcat_$3_total


    port: "$2"

    protocol: "$1"

  help: Tomcat global $3

  type: COUNTER

- pattern: 'Catalina<j2eeType=Servlet, WebModule=//([-a-zA-Z0-9+&@#/%?=~_|!:.,;]*[-a-zA-Z0-9+&@#/%=~_|]), name=([-a-zA-Z0-9+/$%~_-|!.]*), J2EEApplication=none, J2EEServer=none><>(requestCount|maxTime|processingTime|errorCount):'

  name: tomcat_servlet_$3_total


    module: "$1"

    servlet: "$2"

  help: Tomcat servlet $3 total

  type: COUNTER

- pattern: 'Catalina<type=ThreadPool, name="(\w+-\w+)-(\d+)"><>(currentThreadCount|currentThreadsBusy|keepAliveCount|pollerThreadCount|connectionCount):'

  name: tomcat_threadpool_$3


    port: "$2"

    protocol: "$1"

  help: Tomcat threadpool $3

  type: GAUGE

- pattern: 'Catalina<type=Manager, host=([-a-zA-Z0-9+&@#/%?=~_|!:.,;]*[-a-zA-Z0-9+&@#/%=~_|]), context=([-a-zA-Z0-9+/$%~_-|!.]*)><>(processingTime|sessionCounter|rejectedSessions|expiredSessions):'

  name: tomcat_session_$3_total


    context: "$2"

    host: "$1"

  help: Tomcat session $3 total

  type: COUNTER




Start Liferay Portal with JMX Exporter Agent

It’s required to start JMX Exporter agent with Liferay Portal. Set JMX Exporter java agent in JAVA_OPTS in setenv.bat file of Liferay Portal.

JAVA agent syntax




Set JAVA_OPTS in Liferay setenv.bat file. Locate to tomcat bin directory and update setenv.bat file with following JAVA_OPTS. This need to be update in All Liferay Portal Servers in the cluster.


Liferay Portal Node1



set "JAVA_OPTS=%JAVA_OPTS% -javaagent:C:/kafka-workspace/kafka-monitoring/jmx_prometheus_javaagent-0.16.1.jar=7171:C:/kafka-workspace/kafka-monitoring/tomcat.yml"





Liferay Portal Node2




set "JAVA_OPTS=%JAVA_OPTS% -javaagent:C:/kafka-workspace/kafka-monitoring/jmx_prometheus_javaagent-0.16.1.jar=7272:C:/kafka-workspace/kafka-monitoring/tomcat.yml"



Start Liferay Node1

Open command prompt and locate Liferay Portal Tomcat bin directory and use following commands.


cd C:\Liferay\Liferay74\liferay-ce-portal-7.4.1-ga2-node1\tomcat-9.0.43\bin




Start Liferay Node2

Open command prompt and locate Liferay Portal Tomcat bin directory and use following commands.



cd C:\Liferay\Liferay74\liferay-ce-portal-7.4.1-ga2-node2\tomcat-9.0.43\bin





Now Liferay Portal servers started with JMX Exporter agent.


Make sure all JMX Exporter are started successfully and we can access metrics with following URL’s. We are running all java agents in same machine, its required to change ports accordingly.









Install Prometheus


Follow the below URL and Install Prometheus.


Configure Prometheus scrape for Liferay Portal Servers


Locate to Prometheus directory and update “prometheus.yml” file with following Liferay Portal Server scrape.


Find the file from following location




- job_name: 'liferay'


    - targets: ['localhost:7171','localhost:7272']


          env: "liferay-dev"


Targets should be JMX Exporter java agent host:port.


Complete “prometheus.yml” file


# my global config


  scrape_interval:     15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.

  evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.

  # scrape_timeout is set to the global default (10s).


# Alertmanager configuration



  - static_configs:

    - targets:

      # - alertmanager:9093


# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.


  # - "first_rules.yml"

  # - "second_rules.yml"


# A scrape configuration containing exactly one endpoint to scrape:

# Here it's Prometheus itself.


  # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.

  - job_name: 'prometheus'


    # metrics_path defaults to '/metrics'

    # scheme defaults to 'http'.



    - targets: ['localhost:9090']


  - job_name: 'liferay'


    - targets: ['localhost:7171','localhost:7272']


          env: "liferay-dev"





Start “Prometheus”

Open command prompt and locate to “Prometheus” root directory. Use the following start command and pass web listen address and config file as options.


prometheus.exe --config.file prometheus.yml --web.listen-address ":9090" --storage.tsdb.path "data"




Verify Liferay Cluster in Prometheus

Access “Prometheus” web interface with following URL and its running on 9090 port.







Targets Status

Go to Status menu and click on targets so we can see Liferay cluster health for each Node.


We can see Liferay Portal Cluster health in the Prometheus.















  1. Hi this is a wonderful article. I’m going to share this to my friends. I came on this while browsing on google I’ll be sure to come back. thanks for sharing. We are Please Visit us letter pads

  2. Dating remedies will definitely allow consumers to develop an account in addition to uncover appropriate 'matches' to engage with visit here. Messages will absolutely be traded quickly, cheaply, as well as additionally safely, without the security problems of seminars in the real world.


Recent Posts

Recent Posts Widget

Popular Posts