Viewing Metrics with Prometheus
The Liferay Helm chart is prepared to set up the Prometheus JMX Exporter project agent out-of-the-box. Set the JMX_AGENT_YAML
environment variable to the following value using the customEnv
property:
customEnv:
x-jmx_metrics:
- name: JMX_AGENT_YAML
value: |
includeObjectNames: ["com.liferay.users.admin:*"]
openTelemetry:
endpoint: http://prometheus-server.prometheus-system:9090/api/v1/otlp
interval: 1
protocol: http/protobuf
serviceName: $(POD_APP)
serviceInstanceId: $(POD_NAME)
serviceNamespace: $(POD_NAMESPACE)
timeoutSeconds: 60
rules:
- name: server_live_users
pattern: ^com.liferay.users.admin<classification=live_users, name=LiveUsers><>ServerLiveUsersCount
type: GAUGE
- pattern: ".*"
Configuring Prometheus
You can configure Prometheus using a few environment variables:
-
JMX_AGENT_PORT
enables HTTP mode for the chosen port. This can be useful to quickly configure troubleshooting and metrics scraping (HTTP mode is not enabled until a port is specified) -
JMX_AGENT_VERSION
sets the version of the agent (1.3.0
by default) -
JMX_AGENT_YAML
contains YAML configurations. The Prometheus JMX agent is only actived once this variable is defined.ImportantAlways place
JMX_AGENT_YAML
after any other environment variables it references.
If necessary, enable live user tracking in DXP using portal properties:
portalProperties: |
live.users.enabled=true
dependencies:
x-jmx_metrics:
portalProperties: |
live.users.enabled=true
source: external
Using the Prometheus UI
You can deploy Prometheus to use as the APM tool by setting the server
property to the following value:
server:
extraFlags:
- web.enable-lifecycle
- web.enable-otlp-receiver
service:
additionalPorts:
- name: otlp
port: 9090
targetPort: 9090
ingress:
enabled: true
hosts:
- prometheus.docker.localhost
pathType: ImplementationSpecific
Once your Liferay installation is configured to use Prometheus, you can install it by running the following commands:
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo update
helm upgrade -i prometheus \
prometheus-community/prometheus \
--create-namespace \
--namespace prometheus-system \
-f prometheus-values-basic.yaml
Now you should be able to access the Prometheus console at http://prometheus.docker.localhost
.