第 11 章 Red Hat Decision Manager 中的 Prometheus 指标监控
Prometheus 是一个开源系统监控工具包,您可以与红帽决策管理器一起使用并存储与执行业务规则、流程、决策模型和 Notation (DMN)模型相关的指标,以及其他红帽决策管理器资产。您可以通过 REST API 调用 KIE Server、Prometheus 表达式浏览器或使用 Grafana 等数据图形工具访问存储的指标。
您可以为内部 KIE 服务器实例、Spring Boot 上的 KIE Server 或 Red Hat OpenShift Container Platform 上的 KIE Server 部署配置 Prometheus 指标监控。
有关 KIE 服务器与 Prometheus 公开的可用指标列表,请从红帽客户门户网站下载 Red Hat Decision Manager 7.12.0 Source Distribution /kie-server-services-prometheus/src/main/7.12.0- sources/src/droolsjbpm-integration-$VERSION/kie-server-parent/kie-server-services/kie-server-services-prometheus/src/main/java/org/kie/server/services/prometheus
。https://access.redhat.com/jbossnetwork/restricted/listSoftware.html
红帽对 Prometheus 的支持仅限于红帽产品文档中提供的设置和配置建议。
11.1. 为 KIE 服务器配置 Prometheus 指标监控 复制链接链接已复制到粘贴板!
您可以将 KIE 服务器实例配置为使用 Prometheus 来收集和存储与红帽决策管理器中业务资产活动相关的指标。有关 KIE 服务器与 Prometheus 公开的可用指标列表,请从红帽客户门户网站下载 Red Hat Decision Manager 7.12.0 Source Distribution /kie-server-services-prometheus/src/main/7.12.0- sources/src/droolsjbpm-integration-$VERSION/kie-server-parent/kie-server-services/kie-server-services-prometheus/src/main/java/org/kie/server/services/prometheus
。https://access.redhat.com/jbossnetwork/restricted/listSoftware.html
先决条件
- KIE 服务器已安装。
-
您有
kie-server
用户角色对 KIE 服务器的访问权限。 - 已安装 Prometheus。有关下载和使用 Prometheus 的详情,请参考 Prometheus 文档页面。
流程
-
在 KIE 服务器实例中,将
org.kie.prometheus.server.ext.disabled
系统属性设置为false
来启用 Prometheus 扩展。当您启动 KIE Server 或 Red Hat Decision Manager 发行版本的standalone.xml
或standalone-full.xml
文件中,您可以定义此属性。 如果您在 Spring Boot 上运行 Red Hat Decision Manager,请在
application.properties
系统属性中配置所需的密钥:Red Hat Decision Manager 和 Prometheus 的 Spring Boot application.properties 键
kieserver.drools.enabled=true kieserver.dmn.enabled=true kieserver.prometheus.enabled=true
kieserver.drools.enabled=true kieserver.dmn.enabled=true kieserver.prometheus.enabled=true
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 在 Prometheus 发行版本的
prometheus.yaml
文件中,在scrape_configs
部分添加以下设置,将 Prometheus 配置为从 KIE Server 中提取指标:在 prometheus.yaml 文件中提取配置
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Spring Boot 的 prometheus.yaml 文件中的提取配置(如果适用)
scrape_configs: - job_name: 'kie' metrics_path: /rest/metrics static_configs: - targets: ["HOST:PORT"]
scrape_configs: - job_name: 'kie' metrics_path: /rest/metrics static_configs: - targets: ["HOST:PORT"]
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 根据您的 KIE 服务器位置和设置替换值。
启动 KIE 服务器实例。
Red Hat JBoss EAP 上 Red Hat Decision Manager 的 start 命令示例
cd ~/EAP_HOME/bin ./standalone.sh --c standalone-full.xml
$ cd ~/EAP_HOME/bin $ ./standalone.sh --c standalone-full.xml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 启动配置的 KIE Server 实例后,Prometheus 开始收集指标和 KIE 服务器将指标发布到 REST API 端点
http://HOST:PORT/SERVER/services/rest/metrics
(或者在 Spring Boot 中)。在 REST 客户端或 curl 工具中,发送带有以下组件的 REST API 请求,以验证 KIE 服务器是否在发布指标:
对于 REST 客户端:
-
身份验证 :使用
kie-server
角色输入 KIE Server 用户的用户名和密码。 HTTP Headers :设置以下标头:
-
接受
:application/json
-
-
HTTP 方法 :设置为
GET
。 -
URL :输入 KIE Server REST API 基础 URL 和指标端点,如
http://localhost:8080/kie-server/services/rest/metrics
(或者在 Spring Boot,http://localhost:8080/rest/metrics
上)。
对于 curl 工具:
-
-u
:使用kie-server
角色输入 KIE Server 用户的用户名和密码。 -
h : 设置以下标头:-
接受
:application/json
-
-
-x
:设置为GET
。 -
URL :输入 KIE Server REST API 基础 URL 和指标端点,如
http://localhost:8080/kie-server/services/rest/metrics
(或者在 Spring Boot,http://localhost:8080/rest/metrics
上)。
Red Hat JBoss EAP 上 Red Hat Decision Manager 的 curl 命令示例
curl -u 'baAdmin:password@1' -X GET "http://localhost:8080/kie-server/services/rest/metrics"
curl -u 'baAdmin:password@1' -X GET "http://localhost:8080/kie-server/services/rest/metrics"
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Spring Boot 上 Red Hat Decision Manager 的 curl 命令示例
curl -u 'baAdmin:password@1' -X GET "http://localhost:8080/rest/metrics"
curl -u 'baAdmin:password@1' -X GET "http://localhost:8080/rest/metrics"
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 服务器响应示例
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 如果 KIE 服务器中没有指标,请检查并验证本节中的 KIE 服务器和 Prometheus 配置。
您还可以在
http://HOST:PORT/graph
的 Prometheus 表达式浏览器中与收集的指标交互,或者将 Prometheus 数据源与 Grafana 等数据工具集成:图 11.1. 带有 KIE 服务器指标的 Prometheus 表达式浏览器
图 11.2. 带有 KIE Server 目标的 Prometheus 表达式浏览器
图 11.3. 带有 DMN 模型的 KIE 服务器指标的 Grafana 仪表板
图 11.4. 带有 KIE 服务器指标的 Grafana 仪表板
-
身份验证 :使用