此内容没有您所选择的语言版本。

Part III. Accessing Prometheus


Note

For this release, Prometheus is only supported for Fuse on OpenShift. For documentation about Prometheus on OpenShift Container Platform, go to: https://access.redhat.com/documentation/en-us/openshift_container_platform/3.9/html/installation_and_configuration/install-config-cluster-metrics#openshift-prometheus

Important

Prometheus on OpenShift Container Platform is a Technology Preview feature only. Technology Preview features are not supported with Red Hat production service level agreements (SLAs), might not be functionally complete, and Red Hat does not recommend to use them for production. These features provide early access to upcoming product features, enabling customers to test functionality and provide feedback during the development process.

For more information on Red Hat Technology Preview features support scope, see https://access.redhat.com/support/offerings/techpreview/.

You can use Prometheus to monitor and store Fuse on OpenShift data by exposing an endpoint with your Fuse application’s data to Prometheus format. Prometheus stores the data so that you can use a graphical tool, such as Grafana, to visualize and run queries on the data.

1. OpenShift setup

To use Prometheus to monitor Fuse on OpenShift you must:

  • Install the Ansible Service Broker (ASB), which requires OpenShift v3.9 or later. To install the Ansible Service Broker, follow the instructions here: https://github.com/openshift/ansible-service-broker
  • When you start OpenShift, use the --service-catalog option.

2. Installing Prometheus

The Ansible Playbook Bundle uses an image of Prometheus: https://github.com/ansibleplaybookbundle/prometheus-apb

  1. To install the Ansible Playbook Bundle (APB), run these commands:

    wget https://raw.githubusercontent.com/openshift/ansible-service-broker/master/
               scripts/run_latest_build.sh
    
    chmod +x run_latest_build.sh
    
    ./run_latest_build.sh
    Copy to Clipboard Toggle word wrap
  2. To give the developer account permissions to install, run the following commands:

    oc create -n ansible-service-broker -f https://raw.githubusercontent.com/ansibleplaybookbundle/ansible-playbook-bundle/apb-1.1.6-1/templates/openshift-permissions.template.yaml
    Copy to Clipboard Toggle word wrap
    oc export cm/broker-config -n ansible-service-broker | sed 's/sandbox_role: .*/sandbox_role: \"admin\"/' | oc replace -f - cm/broker-config -n ansible-service-broker
    Copy to Clipboard Toggle word wrap

    The Prometheus APB should appear.

  3. Follow the provided instructions. Optionally, you can install Grafana.

For information about getting started with Prometheus, go to: https://prometheus.io/docs/prometheus/latest/getting_started/

3. Configuring Prometheus

You can set the following environment variables in OpenShift in order to configure your application’s Prometheus agent:

Expand
Table 3. Prometheus Environment Variables
Environment VariableDescriptionDefault

AB_PROMETHEUS_HOST

The host address to bind.

0.0.0.0

AB_PROMETHEUS_OFF

If set, disables the activation of Prometheus (echoes an empty value).

Prometheus is enabled.

AB_PROMETHEUS_PORT

The Port to use.

9779

AB_JMX_EXPORTER_CONFIG

Uses the file (including path) as the Prometheus configuration file.

The /opt/prometheus/prometheus-config.yml file with Camel metrics

AB_JMX_EXPORTER_OPTS

Additional options to append to the JMX exporter configuration.

Not applicable.

By default, Prometheus uses a configuration file ( https://raw.githubusercontent.com/jboss-fuse/application-templates/master/prometheus/prometheus-config.yml) that includes all possible metrics exposed by Camel.

If you have custom metrics within your application that you want Prometheus to monitor and collect (for example, the number of orders that your application processes), you can use your own configuration file. Note that the metrics that you can identify are limited to those supplied in JMX.

To use a custom configuration file to expose JMX beans that are not covered by the default configuration, follow these steps:

  1. Create a custom Prometheus configuration file. You can use the contents of the default file (prometheus-config.yml https://raw.githubusercontent.com/jboss-fuse/application-templates/master/prometheus/prometheus-config.yml) as a guide for the format.

    You can use any name for the custom configuration file, for example: my-prometheus-config.yml

  2. Add your prometheus configuration file (for example, my-prometheus-config.yml) to your application’s src/main/fabric8-includes directory.
  3. Create a src/main/fabric8/deployment.xml file within your application and add an entry for the AB_JMX_EXPORTER_CONFIG environment variable with its value set to your configuration file. For example:

    env:
        name: AB_JMX_EXPORTER_CONFIG
    value: “my-prometheus-config.yml”
    Copy to Clipboard Toggle word wrap

    This environment variable applies to your application at the pod level.

  4. Rebuild and deploy your application.

5. Viewing Prometheus metrics with Grafana

Grafana is an analytics platform that allows you to query, visualize, alert on and understand your metrics using dashboards.

To view Prometheus metrics with Grafana, you need to:

6. Generating alerts

For an example of using Prometheus for OpenShift to generate alerts, see the Red Hat Cloud Forms Monitoring, Alerts, and Reporting guide:

https://access.redhat.com/documentation/en-us/red_hat_cloudforms/4.6/html/monitoring_alerts_and_reporting/integrating_prometheus_alerts

返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat