第 13 章 Red Hat Process Automation Manager Kogito Operator 与 Prometheus 和 Grafana 交互
Red Hat Decision Manager 中的 Red Hat build of Kogito 提供了一个 monitoring-prometheus-addon 附加组件,它为红帽构建的 Kogito 微服务启用 Prometheus metrics 监控,并生成 Grafana 仪表板,它消耗附加组件导出的默认指标。RHPAM Kogito Operator 使用 Prometheus Operator 来公开项目的指标,以便 Prometheus 提取。由于这个依赖项,Prometheus Operator 必须安装到与项目相同的命名空间中。
如果要为 Red Hat build of Kogito 微服务启用 Prometheus 指标数据监控,根据您的项目中的 pom.xml 文件添加以下依赖关系,具体取决于您使用的框架:
Prometheus Red Hat build of Quarkus 附加组件的依赖项
<dependency>
<groupId>org.kie.kogito</groupId>
<artifactId>monitoring-prometheus-quarkus-addon</artifactId>
</dependency>
<dependency>
<groupId>org.kie.kogito</groupId>
<artifactId>monitoring-prometheus-quarkus-addon</artifactId>
</dependency>
Prometheus Spring Boot 附加组件的依赖关系
<dependency>
<groupId>org.kie.kogito</groupId>
<artifactId>monitoring-prometheus-springboot-addon</artifactId>
</dependency>
<dependency>
<groupId>org.kie.kogito</groupId>
<artifactId>monitoring-prometheus-springboot-addon</artifactId>
</dependency>
当您部署使用 monitoring-prometheus-addon 附加组件和 Prometheus Operator 的 Red Hat build 的 Red Hat build 时,Red Hat Process Automation Manager Kogito Operator 会创建一个 ServiceMonitor 自定义资源来公开 Prometheus 的指标,如下例所示:
Prometheus 的 ServiceMonitor 资源示例
您必须手动配置由 Prometheus Operator 管理的 Prometheus 自定义资源,以选择 ServiceMonitor 资源:
Prometheus 资源示例
使用 ServiceMonitor 资源配置 Prometheus 资源后,您可以在 Prometheus web 控制台的 Targets 页面中看到 Prometheus 提取的端点。Red Hat Decision Manager 服务公开的指标会出现在 Graph 视图中。
RHPAM Kogito Operator 还会为附加组件生成的每个 Grafana 仪表板创建一个 GrafanaDashboard 自定义资源。https://operatorhub.io/operator/grafana-operator仪表板 的应用程序标签是部署的红帽构建 Kogito 微服务的名称。您必须根据相关的红帽构建 Kogito 微服务来设置 Grafana 自定义资源的 dashboardLabelSelector 属性。
Grafana 资源示例