検索

このコンテンツは選択した言語では利用できません。

Chapter 14. Accessing Prometheus

download PDF
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.10/html-single/configuring_clusters/#openshift-prometheus

Important

Prometheus on OpenShift 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.

You can use Prometheus to monitor Fuse applications on an installed and running single-node OpenShift cluster such as Minishift or the Red Hat Container Development Kit. A single-node OpenShift cluster provides you with access to a cloud environment that is similar to a production environment.

For information on installing and developing with Red Hat Fuse on OpenShift, see the Fuse on OpenShift Guide.

14.1. Setting up Prometheus to access Fuse applications on Minishift

Follow these steps to add Prometheus and Grafana to your Fuse on OpenShift project:

At the command line, follow these steps:

  1. Start Minishift with the following options:

    MINISHIFT_ENABLE_EXPERIMENTAL=y minishift start --ocp-tag v3.10.14 --extra-clusterup-flags "--enable=*,service-catalog"
  2. At the prompt, login as the system admin user:

    oc login -u system:admin
  3. Download and install the Ansible Service Broker:

    curl https://raw.githubusercontent.com/openshift/ansible-service-broker/release-1.2/apb/install.yaml | oc create -f -
  4. Get a list of the installed projects:

    oc get projects -w

    This command returns a constantly updating list of projects:

    NAME                           DISPLAY NAME   STATUS
    automation-broker-apb                         Active
    default                                       Active
    kube-dns                                      Active
    kube-proxy                                    Active
    kube-public                                   Active
    kube-service-catalog                          Active
    kube-system                                   Active
    myproject                      My Project     Active
    openshift                                     Active
    openshift-apiserver                           Active
    openshift-controller-manager                  Active
    openshift-core-operators                      Active
    openshift-infra                               Active
    openshift-node                                Active
    openshift-web-console                         Active
  5. Monitor this list to see when the automation-broker is active. It can take some time (approximately two minutes) for automation-broker-apb to install the automation broker:

    automation-broker             Active
  6. When the list of projects indicates that the automation-broker is active, press CTRL + C to cancel the oc get projects -w command.
  7. Run the following command:

    oc export cm/broker-config -n automation-broker  | sed 's/sandbox_role: .*/sandbox_role: \"admin\"/' | oc replace -f - cm/broker-config -n automation-broker

    The command returns this message:

    configmap "broker-config" replaced

    It then takes some time to retrieve the Ansible Playbook catalog. (Now is a good time for you to take a coffee or tea break.)

    Note

    You can use the following command to monitor the status of the automation-broker:

    oc get pods -n automation-broker -w
  8. Wait several minutes and then run this command:

    oc rollout latest dc/automation-broker -n automation-broker

    If the following message is returned, you must wait longer and then rerun the oc rollout command:

    Error from server (NotFound): deploymentconfigs.apps.openshift.io "automation-broker" not found

    When the following message is returned by the oc rollout command, the command was successful and you can move to the next step:

    error: #1 is already in progress (Running).
  9. Open the OpenShift web console:

    minishift console

    Your web browser opens:

    mf os console

Follow these steps in the OpenShift web console:

  1. Log into the web console with your developer credentials (for example, developer/developer).

    Note

    If you are already logged into the web console, clear the web browser cache so that you can find the Prometheus (APB) item in the next step.

  2. In the catalog search field, type Prometheus, and then select the Prometheus (APB) item:

    mf catalog prometheus

    The Prometheus (APB) wizard opens:

    mf prometheus apb p1
  3. Click Next.

    Page 2 of the wizard opens:

    mf prometheus apb p2
  4. Select Ephemeral or Persistent. If you select Ephemeral, OpenShift stores the Prometheus metrics and data only for the duration of the current session. If you select Persistent, OpenShift writes the Prometheus metrics and data to disk and stores it until the Minishift VM is deleted.
  5. Click Next.

    Page 3 of the wizard opens:

    mf prometheus apb p3
  6. Specify the project that contains the Fuse application.
  7. If you want to require OpenShift login to access the Prometheus and Grafana dashboards, check the Deploy Prometheus with Oauth-Proxy sidecar option.
  8. Scroll down to see the Grafana config section and then check the Deploy Grafana server with Prometheus as datasource option.

    mf prometheus apb p3b
  9. Click Create.

    mf prometheus apb p4
  10. Click the Continue to the project overview link.
  11. Wait until OpenShift provisions the Prometheus (APB) service.

    mf prometheus provision

To open the Prometheus dashboard:

  1. When the Prometheus application is ready (as shown in the following screen capture), click the provided URL (for example, https://prometheus-proxy-myproject.192.168.64.27.nip.io):

    mf prometheus deployed
  2. If you selected the Deploy Prometheus with Oauth-Proxy sidecar option, you must login using your OpenShift user name and password (for example, developer/developer).
  3. In the Authorize Access page, leave the user:info and user:check-access options checked and click Allow selected permissions.

    The Prometheus dashboard opens.

To open the Grafana dashboard:

  1. In the project Overview page of the OpenShift console, expand the prometheus-grafana-proxy configuration:

    mf grafana config
  2. Click the provided URL (for example, https://prometheus-grafana-proxy-myproject.192.168.64.27.nip.io/` )
  3. If you selected the Deploy Prometheus with Oauth-Proxy sidecar option, you must login using your OpenShift user name and password (for example, developer/developer).
  4. In the Authorize Access page, leave the user:info and user:check-access options checked and click Allow selected permissions.

    mf grafana access

    The Grafana Home Dashboard appears:

    mf grafana home

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

14.2. Configuring Prometheus

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

Table 14.1. 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.

14.3. Controlling the metrics that Prometheus monitors and collects

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:

    spec:
      template:
        spec:
          containers:
            -
              resources:
                requests:
                  cpu: "0.2"
                limits:
                  cpu: "1.0"
              env:
              - name: SPRING_APPLICATION_JSON
                value: '{"server":{"tomcat":{"max-threads":1}}}'
              - name: AB_JMX_EXPORTER_CONFIG
                value: "my-prometheus-config.yml"

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

  4. Rebuild and deploy your application.

14.4. 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

詳細情報

試用、購入および販売

コミュニティー

Red Hat ドキュメントについて

Red Hat をお使いのお客様が、信頼できるコンテンツが含まれている製品やサービスを活用することで、イノベーションを行い、目標を達成できるようにします。

多様性を受け入れるオープンソースの強化

Red Hat では、コード、ドキュメント、Web プロパティーにおける配慮に欠ける用語の置き換えに取り組んでいます。このような変更は、段階的に実施される予定です。詳細情報: Red Hat ブログ.

会社概要

Red Hat は、企業がコアとなるデータセンターからネットワークエッジに至るまで、各種プラットフォームや環境全体で作業を簡素化できるように、強化されたソリューションを提供しています。

© 2024 Red Hat, Inc.