4.2. 监控 Camel Spring Boot 应用程序
为项目启用监控后,您可以部署和监控 Camel Spring Boot 应用程序。本节使用 Camel Spring Boot 示例中列出的 monitoring-micrometrics-grafana-prometheus 示例。
流程
-
将 openshift-maven-plugin 添加到
monitoring-micrometrics-grafana-prometheus示例的pom.xml文件中。在pom.xml中,添加一个 openshift 配置集,以允许通过 openshift-maven-plugin 部署到 openshift。 将 openshift-maven-plugin 添加到
monitoring-micrometrics-grafana-prometheus示例的pom.xml文件中。在pom.xml中,添加一个 openshift 配置集,以允许通过openshift-maven-plugin部署到 openshift。<profiles> <profile> <id>openshift</id> <build> <plugins> <plugin> <groupId>org.eclipse.jkube</groupId> <artifactId>openshift-maven-plugin</artifactId> <version>1.13.1</version> <executions> <execution> <goals> <goal>resource</goal> <goal>build</goal> </goals> </execution> </executions> </plugin> </plugins> </build> </profile> </profiles><profiles> <profile> <id>openshift</id> <build> <plugins> <plugin> <groupId>org.eclipse.jkube</groupId> <artifactId>openshift-maven-plugin</artifactId> <version>1.13.1</version> <executions> <execution> <goals> <goal>resource</goal> <goal>build</goal> </goals> </execution> </executions> </plugin> </plugins> </build> </profile> </profiles>Copy to Clipboard Copied! Toggle word wrap Toggle overflow 添加 Prometheus 支持。要在 Camel 应用程序中添加 Prometheus 支持,请在 actuator 端点上公开 Prometheus 统计信息。
-
编辑
src/main/resources/application.properties文件。 -
如果不存在,请添加
management.endpoints.web.exposure.include条目。 将 prometheus、metrics 和 health 添加到
management.endpoints.web.exposure.include条目:expose actuator endpoint via HTTP management.endpoints.web.exposure.include=mappings,metrics,health,shutdown,jolokia,prometheus
# expose actuator endpoint via HTTP management.endpoints.web.exposure.include=mappings,metrics,health,shutdown,jolokia,prometheusCopy to Clipboard Copied! Toggle word wrap Toggle overflow
-
编辑
将以下内容添加到 pom.xml 的
<dependencies/> 部分,为您的应用程序添加一些入门支持。<dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>6.1.8</version> </dependency> <dependency> <groupId>io.micrometer</groupId> <artifactId>micrometer-registry-prometheus</artifactId> <version>1.13.6</version> </dependency> <dependency> <groupId>org.jolokia</groupId> <artifactId>jolokia-core</artifactId> <version>2.1.0</version> </dependency> <dependency> <groupId>io.prometheus.jmx</groupId> <artifactId>collector</artifactId> <version>1.0.1</version> </dependency><dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>6.1.8</version> </dependency> <dependency> <groupId>io.micrometer</groupId> <artifactId>micrometer-registry-prometheus</artifactId> <version>1.13.6</version> </dependency> <dependency> <groupId>org.jolokia</groupId> <artifactId>jolokia-core</artifactId> <version>2.1.0</version> </dependency> <dependency> <groupId>io.prometheus.jmx</groupId> <artifactId>collector</artifactId> <version>1.0.1</version> </dependency>Copy to Clipboard Copied! Toggle word wrap Toggle overflow 创建文件
config/prometheus_exporter_config.yml:startDelaySecs: 5 ssl: false blacklistObjectNames: ["java.lang:*"] rules: # Context level - pattern: 'org.apache.camel<context=([^,]+), type=context, name=([^,]+)><>ExchangesCompleted' name: org.apache.camel.ExchangesCompleted help: Exchanges Completed type: COUNTER labels: context: $1 type: context - pattern: 'org.apache.camel<context=([^,]+), type=context, name=([^,]+)><>ExchangesFailed' name: org.apache.camel.ExchangesFailed help: Exchanges Failed type: COUNTER labels: context: $1 type: context - pattern: 'org.apache.camel<context=([^,]+), type=context, name=([^,]+)><>ExchangesInflight' name: org.apache.camel.ExchangesInflight help: Exchanges Inflight type: GAUGE labels: context: $1 type: context - pattern: 'org.apache.camel<context=([^,]+), type=context, name=([^,]+)><>ExchangesTotal' name: org.apache.camel.ExchangesTotal help: Exchanges Total type: COUNTER labels: context: $1 type: context - pattern: 'org.apache.camel<context=([^,]+), type=context, name=([^,]+)><>FailuresHandled' name: org.apache.camel.FailuresHandled help: Failures Handled labels: context: $1 type: context type: COUNTER - pattern: 'org.apache.camel<context=([^,]+), type=context, name=([^,]+)><>ExternalRedeliveries' name: org.apache.camel.ExternalRedeliveries help: External Redeliveries labels: context: $1 type: context type: COUNTER - pattern: 'org.apache.camel<context=([^,]+), type=context, name=([^,]+)><>MaxProcessingTime' name: org.apache.camel.MaxProcessingTime help: Maximum Processing Time labels: context: $1 type: context type: GAUGE - pattern: 'org.apache.camel<context=([^,]+), type=context, name=([^,]+)><>MeanProcessingTime' name: org.apache.camel.MeanProcessingTime help: Mean Processing Time labels: context: $1 type: context type: GAUGE - pattern: 'org.apache.camel<context=([^,]+), type=context, name=([^,]+)><>MinProcessingTime' name: org.apache.camel.MinProcessingTime help: Minimum Processing Time labels: context: $1 type: context type: GAUGE - pattern: 'org.apache.camel<context=([^,]+), type=context, name=([^,]+)><>LastProcessingTime' name: org.apache.camel.LastProcessingTime help: Last Processing Time labels: context: $1 type: context type: GAUGE - pattern: 'org.apache.camel<context=([^,]+), type=context, name=([^,]+)><>DeltaProcessingTime' name: org.apache.camel.DeltaProcessingTime help: Delta Processing Time labels: context: $1 type: context type: GAUGE - pattern: 'org.apache.camel<context=([^,]+), type=context, name=([^,]+)><>Redeliveries' name: org.apache.camel.Redeliveries help: Redeliveries labels: context: $1 type: context type: COUNTER - pattern: 'org.apache.camel<context=([^,]+), type=context, name=([^,]+)><>TotalProcessingTime' name: org.apache.camel.TotalProcessingTime help: Total Processing Time labels: context: $1 type: context type: GAUGE - pattern: 'org.apache.camel<context=([^,]+), type=consumers, name=([^,]+)><>InflightExchanges' name: org.apache.camel.InflightExchanges help: Inflight Exchanges labels: context: $1 type: context type: GAUGE # Route level - pattern: 'org.apache.camel<context=([^,]+), type=routes, name=([^,]+)><>ExchangesCompleted' name: org.apache.camel.ExchangesCompleted help: Exchanges Completed type: COUNTER labels: context: $1 route: $2 type: routes - pattern: 'org.apache.camel<context=([^,]+), type=routes, name=([^,]+)><>ExchangesFailed' name: org.apache.camel.ExchangesFailed help: Exchanges Failed type: COUNTER labels: context: $1 route: $2 type: routes - pattern: 'org.apache.camel<context=([^,]+), type=routes, name=([^,]+)><>ExchangesInflight' name: org.apache.camel.ExchangesInflight help: Exchanges Inflight type: GAUGE labels: context: $1 route: $2 type: routes - pattern: 'org.apache.camel<context=([^,]+), type=routes, name=([^,]+)><>ExchangesTotal' name: org.apache.camel.ExchangesTotal help: Exchanges Total type: COUNTER labels: context: $1 route: $2 type: routes - pattern: 'org.apache.camel<context=([^,]+), type=routes, name=([^,]+)><>FailuresHandled' name: org.apache.camel.FailuresHandled help: Failures Handled labels: context: $1 route: $2 type: routes type: COUNTER - pattern: 'org.apache.camel<context=([^,]+), type=routes, name=([^,]+)><>ExternalRedeliveries' name: org.apache.camel.ExternalRedeliveries help: External Redeliveries labels: context: $1 route: $2 type: routes type: COUNTER - pattern: 'org.apache.camel<context=([^,]+), type=routes, name=([^,]+)><>MaxProcessingTime' name: org.apache.camel.MaxProcessingTime help: Maximum Processing Time labels: context: $1 route: $2 type: routes type: GAUGE - pattern: 'org.apache.camel<context=([^,]+), type=routes, name=([^,]+)><>MeanProcessingTime' name: org.apache.camel.MeanProcessingTime help: Mean Processing Time labels: context: $1 route: $2 type: routes type: GAUGE - pattern: 'org.apache.camel<context=([^,]+), type=routes, name=([^,]+)><>MinProcessingTime' name: org.apache.camel.MinProcessingTime help: Minimum Processing Time labels: context: $1 route: $2 type: routes type: GAUGE - pattern: 'org.apache.camel<context=([^,]+), type=routes, name=([^,]+)><>LastProcessingTime' name: org.apache.camel.LastProcessingTime help: Last Processing Time labels: context: $1 route: $2 type: routes type: GAUGE - pattern: 'org.apache.camel<context=([^,]+), type=routes, name=([^,]+)><>DeltaProcessingTime' name: org.apache.camel.DeltaProcessingTime help: Delta Processing Time labels: context: $1 route: $2 type: routes type: GAUGE - pattern: 'org.apache.camel<context=([^,]+), type=routes, name=([^,]+)><>Redeliveries' name: org.apache.camel.Redeliveries help: Redeliveries labels: context: $1 route: $2 type: routes type: COUNTER - pattern: 'org.apache.camel<context=([^,]+), type=routes, name=([^,]+)><>TotalProcessingTime' name: org.apache.camel.TotalProcessingTime help: Total Processing Time labels: context: $1 route: $2 type: routes type: GAUGE - pattern: 'org.apache.camel<context=([^,]+), type=routes, name=([^,]+)><>InflightExchanges' name: org.apache.camel.InflightExchanges help: Inflight Exchanges labels: context: $1 route: $2 type: routes type: GAUGE # Processor level - pattern: 'org.apache.camel<context=([^,]+), type=processors, name=([^,]+)><>ExchangesCompleted' name: org.apache.camel.ExchangesCompleted help: Exchanges Completed type: COUNTER labels: context: $1 processor: $2 type: processors - pattern: 'org.apache.camel<context=([^,]+), type=processors, name=([^,]+)><>ExchangesFailed' name: org.apache.camel.ExchangesFailed help: Exchanges Failed type: COUNTER labels: context: $1 processor: $2 type: processors - pattern: 'org.apache.camel<context=([^,]+), type=processors, name=([^,]+)><>ExchangesInflight' name: org.apache.camel.ExchangesInflight help: Exchanges Inflight type: GAUGE labels: context: $1 processor: $2 type: processors - pattern: 'org.apache.camel<context=([^,]+), type=processors, name=([^,]+)><>ExchangesTotal' name: org.apache.camel.ExchangesTotal help: Exchanges Total type: COUNTER labels: context: $1 processor: $2 type: processors - pattern: 'org.apache.camel<context=([^,]+), type=processors, name=([^,]+)><>FailuresHandled' name: org.apache.camel.FailuresHandled help: Failures Handled labels: context: $1 processor: $2 type: processors type: COUNTER - pattern: 'org.apache.camel<context=([^,]+), type=processors, name=([^,]+)><>ExternalRedeliveries' name: org.apache.camel.ExternalRedeliveries help: External Redeliveries labels: context: $1 processor: $2 type: processors type: COUNTER - pattern: 'org.apache.camel<context=([^,]+), type=processors, name=([^,]+)><>MaxProcessingTime' name: org.apache.camel.MaxProcessingTime help: Maximum Processing Time labels: context: $1 processor: $2 type: processors type: GAUGE - pattern: 'org.apache.camel<context=([^,]+), type=processors, name=([^,]+)><>MeanProcessingTime' name: org.apache.camel.MeanProcessingTime help: Mean Processing Time labels: context: $1 processor: $2 type: processors type: GAUGE - pattern: 'org.apache.camel<context=([^,]+), type=processors, name=([^,]+)><>MinProcessingTime' name: org.apache.camel.MinProcessingTime help: Minimum Processing Time labels: context: $1 processor: $2 type: processors type: GAUGE - pattern: 'org.apache.camel<context=([^,]+), type=processors, name=([^,]+)><>LastProcessingTime' name: org.apache.camel.LastProcessingTime help: Last Processing Time labels: context: $1 processor: $2 type: processors type: GAUGE - pattern: 'org.apache.camel<context=([^,]+), type=processors, name=([^,]+)><>DeltaProcessingTime' name: org.apache.camel.DeltaProcessingTime help: Delta Processing Time labels: context: $1 processor: $2 type: processors type: GAUGE - pattern: 'org.apache.camel<context=([^,]+), type=processors, name=([^,]+)><>Redeliveries' name: org.apache.camel.Redeliveries help: Redeliveries labels: context: $1 processor: $2 type: processors type: COUNTER - pattern: 'org.apache.camel<context=([^,]+), type=processors, name=([^,]+)><>TotalProcessingTime' name: org.apache.camel.TotalProcessingTime help: Total Processing Time labels: context: $1 processor: $2 type: processors type: GAUGE - pattern: 'org.apache.camel<context=([^,]+), type=processors, name=([^,]+)><>InflightExchanges' name: org.apache.camel.InflightExchanges help: Inflight Exchanges labels: context: $1 processor: $2 type: processors type: COUNTER # Consumers - pattern: 'org.apache.camel<context=([^,]+), type=consumers, name=([^,]+)><>InflightExchanges' name: org.apache.camel.InflightExchanges help: Inflight Exchanges labels: context: $1 consumer: $2 type: consumers type: GAUGE # Services - pattern: 'org.apache.camel<context=([^,]+), type=services, name=([^,]+)><>MaxDuration' name: org.apache.camel.MaxDuration help: Maximum Duration labels: context: $1 service: $2 type: services type: GAUGE - pattern: 'org.apache.camel<context=([^,]+), type=services, name=([^,]+)><>MeanDuration' name: org.apache.camel.MeanDuration help: Mean Duration labels: context: $1 service: $2 type: services type: GAUGE - pattern: 'org.apache.camel<context=([^,]+), type=services, name=([^,]+)><>MinDuration' name: org.apache.camel.MinDuration help: Minimum Duration labels: context: $1 service: $2 type: services type: GAUGE - pattern: 'org.apache.camel<context=([^,]+), type=services, name=([^,]+)><>TotalDuration' name: org.apache.camel.TotalDuration help: Total Duration labels: context: $1 service: $2 type: services type: GAUGE - pattern: 'org.apache.camel<context=([^,]+), type=services, name=([^,]+)><>ThreadsBlocked' name: org.apache.camel.ThreadsBlocked help: Threads Blocked labels: context: $1 service: $2 type: services type: GAUGE - pattern: 'org.apache.camel<context=([^,]+), type=services, name=([^,]+)><>ThreadsInterrupted' name: org.apache.camel.ThreadsInterrupted help: Threads Interrupted labels: context: $1 service: $2 type: services type: GAUGE - pattern: 'org.apache.cxf<bus.id=([^,]+), type=([^,]+), service=([^,]+), port=([^,]+), operation=([^,]+)><>NumLogicalRuntimeFaults' name: org.apache.cxf.NumLogicalRuntimeFaults help: Number of logical runtime faults type: GAUGE labels: bus.id: $1 type: $2 service: $3 port: $4 operation: $5 - pattern: 'org.apache.cxf<bus.id=([^,]+), type=([^,]+), service=([^,]+), port=([^,]+)><>NumLogicalRuntimeFaults' name: org.apache.cxf.NumLogicalRuntimeFaults help: Number of logical runtime faults type: GAUGE labels: bus.id: $1 type: $2 service: $3 port: $4 - pattern: 'org.apache.cxf<bus.id=([^,]+), type=([^,]+), service=([^,]+), port=([^,]+), operation=([^,]+)><>AvgResponseTime' name: org.apache.cxf.AvgResponseTime help: Average Response Time type: GAUGE labels: bus.id: $1 type: $2 service: $3 port: $4 operation: $5 - pattern: 'org.apache.cxf<bus.id=([^,]+), type=([^,]+), service=([^,]+), port=([^,]+)><>AvgResponseTime' name: org.apache.cxf.AvgResponseTime help: Average Response Time type: GAUGE labels: bus.id: $1 type: $2 service: $3 port: $4 - pattern: 'org.apache.cxf<bus.id=([^,]+), type=([^,]+), service=([^,]+), port=([^,]+), operation=([^,]+)><>NumInvocations' name: org.apache.cxf.NumInvocations help: Number of invocations type: GAUGE labels: bus.id: $1 type: $2 service: $3 port: $4 operation: $5 - pattern: 'org.apache.cxf<bus.id=([^,]+), type=([^,]+), service=([^,]+), port=([^,]+)><>NumInvocations' name: org.apache.cxf.NumInvocations help: Number of invocations type: GAUGE labels: bus.id: $1 type: $2 service: $3 port: $4 - pattern: 'org.apache.cxf<bus.id=([^,]+), type=([^,]+), service=([^,]+), port=([^,]+), operation=([^,]+)><>MaxResponseTime' name: org.apache.cxf.MaxResponseTime help: Maximum Response Time type: GAUGE labels: bus.id: $1 type: $2 service: $3 port: $4 operation: $5 - pattern: 'org.apache.cxf<bus.id=([^,]+), type=([^,]+), service=([^,]+), port=([^,]+)><>MaxResponseTime' name: org.apache.cxf.MaxResponseTime help: Maximum Response Time type: GAUGE labels: bus.id: $1 type: $2 service: $3 port: $4 - pattern: 'org.apache.cxf<bus.id=([^,]+), type=([^,]+), service=([^,]+), port=([^,]+), operation=([^,]+)><>MinResponseTime' name: org.apache.cxf.MinResponseTime help: Minimum Response Time type: GAUGE labels: bus.id: $1 type: $2 service: $3 port: $4 operation: $5 - pattern: 'org.apache.cxf<bus.id=([^,]+), type=([^,]+), service=([^,]+), port=([^,]+), operation=([^,]+)><>MinResponseTime' name: org.apache.cxf.MinResponseTime help: Minimum Response Time type: GAUGE labels: bus.id: $1 type: $2 service: $3 port: $4 - pattern: 'org.apache.cxf<bus.id=([^,]+), type=([^,]+), service=([^,]+), port=([^,]+), operation=([^,]+)><>TotalHandlingTime' name: org.apache.cxf.TotalHandlingTime help: Total Handling Time type: GAUGE labels: bus.id: $1 type: $2 service: $3 port: $4 operation: $5 - pattern: 'org.apache.cxf<bus.id=([^,]+), type=([^,]+), service=([^,]+), port=([^,]+)><>TotalHandlingTime' name: org.apache.cxf.TotalHandlingTime help: Total Handling Time type: GAUGE labels: bus.id: $1 type: $2 service: $3 port: $4 - pattern: 'org.apache.cxf<bus.id=([^,]+), type=([^,]+), service=([^,]+), port=([^,]+), operation=([^,]+)><>NumRuntimeFaults' name: org.apache.cxf.NumRuntimeFaults help: Number of runtime faults type: GAUGE labels: bus.id: $1 type: $2 service: $3 port: $4 operation: $5 - pattern: 'org.apache.cxf<bus.id=([^,]+), type=([^,]+), service=([^,]+), port=([^,]+)><>NumRuntimeFaults' name: org.apache.cxf.NumRuntimeFaults help: Number of runtime faults type: GAUGE labels: bus.id: $1 type: $2 service: $3 port: $4 - pattern: 'org.apache.cxf<bus.id=([^,]+), type=([^,]+), service=([^,]+), port=([^,]+), operation=([^,]+)><>NumUnCheckedApplicationFaults' name: org.apache.cxf.NumUnCheckedApplicationFaults help: Number of unchecked application faults type: GAUGE labels: bus.id: $1 type: $2 service: $3 port: $4 operation: $5 - pattern: 'org.apache.cxf<bus.id=([^,]+), type=([^,]+), service=([^,]+), port=([^,]+)><>NumUnCheckedApplicationFaults' name: org.apache.cxf.NumUnCheckedApplicationFaults help: Number of unchecked application faults type: GAUGE labels: bus.id: $1 type: $2 service: $3 port: $4 - pattern: 'org.apache.cxf<bus.id=([^,]+), type=([^,]+), service=([^,]+), port=([^,]+), operation=([^,]+)><>NumCheckedApplicationFaults' name: org.apache.cxf.NumCheckedApplicationFaults help: Number of checked application faults type: GAUGE labels: bus.id: $1 type: $2 service: $3 port: $4 operation: $5 - pattern: 'org.apache.cxf<bus.id=([^,]+), type=([^,]+), service=([^,]+), port=([^,]+)><>NumCheckedApplicationFaults' name: org.apache.cxf.NumCheckedApplicationFaults help: Number of checked application faults type: GAUGE labels: bus.id: $1 type: $2 service: $3 port: $4startDelaySecs: 5 ssl: false blacklistObjectNames: ["java.lang:*"] rules: # Context level - pattern: 'org.apache.camel<context=([^,]+), type=context, name=([^,]+)><>ExchangesCompleted' name: org.apache.camel.ExchangesCompleted help: Exchanges Completed type: COUNTER labels: context: $1 type: context - pattern: 'org.apache.camel<context=([^,]+), type=context, name=([^,]+)><>ExchangesFailed' name: org.apache.camel.ExchangesFailed help: Exchanges Failed type: COUNTER labels: context: $1 type: context - pattern: 'org.apache.camel<context=([^,]+), type=context, name=([^,]+)><>ExchangesInflight' name: org.apache.camel.ExchangesInflight help: Exchanges Inflight type: GAUGE labels: context: $1 type: context - pattern: 'org.apache.camel<context=([^,]+), type=context, name=([^,]+)><>ExchangesTotal' name: org.apache.camel.ExchangesTotal help: Exchanges Total type: COUNTER labels: context: $1 type: context - pattern: 'org.apache.camel<context=([^,]+), type=context, name=([^,]+)><>FailuresHandled' name: org.apache.camel.FailuresHandled help: Failures Handled labels: context: $1 type: context type: COUNTER - pattern: 'org.apache.camel<context=([^,]+), type=context, name=([^,]+)><>ExternalRedeliveries' name: org.apache.camel.ExternalRedeliveries help: External Redeliveries labels: context: $1 type: context type: COUNTER - pattern: 'org.apache.camel<context=([^,]+), type=context, name=([^,]+)><>MaxProcessingTime' name: org.apache.camel.MaxProcessingTime help: Maximum Processing Time labels: context: $1 type: context type: GAUGE - pattern: 'org.apache.camel<context=([^,]+), type=context, name=([^,]+)><>MeanProcessingTime' name: org.apache.camel.MeanProcessingTime help: Mean Processing Time labels: context: $1 type: context type: GAUGE - pattern: 'org.apache.camel<context=([^,]+), type=context, name=([^,]+)><>MinProcessingTime' name: org.apache.camel.MinProcessingTime help: Minimum Processing Time labels: context: $1 type: context type: GAUGE - pattern: 'org.apache.camel<context=([^,]+), type=context, name=([^,]+)><>LastProcessingTime' name: org.apache.camel.LastProcessingTime help: Last Processing Time labels: context: $1 type: context type: GAUGE - pattern: 'org.apache.camel<context=([^,]+), type=context, name=([^,]+)><>DeltaProcessingTime' name: org.apache.camel.DeltaProcessingTime help: Delta Processing Time labels: context: $1 type: context type: GAUGE - pattern: 'org.apache.camel<context=([^,]+), type=context, name=([^,]+)><>Redeliveries' name: org.apache.camel.Redeliveries help: Redeliveries labels: context: $1 type: context type: COUNTER - pattern: 'org.apache.camel<context=([^,]+), type=context, name=([^,]+)><>TotalProcessingTime' name: org.apache.camel.TotalProcessingTime help: Total Processing Time labels: context: $1 type: context type: GAUGE - pattern: 'org.apache.camel<context=([^,]+), type=consumers, name=([^,]+)><>InflightExchanges' name: org.apache.camel.InflightExchanges help: Inflight Exchanges labels: context: $1 type: context type: GAUGE # Route level - pattern: 'org.apache.camel<context=([^,]+), type=routes, name=([^,]+)><>ExchangesCompleted' name: org.apache.camel.ExchangesCompleted help: Exchanges Completed type: COUNTER labels: context: $1 route: $2 type: routes - pattern: 'org.apache.camel<context=([^,]+), type=routes, name=([^,]+)><>ExchangesFailed' name: org.apache.camel.ExchangesFailed help: Exchanges Failed type: COUNTER labels: context: $1 route: $2 type: routes - pattern: 'org.apache.camel<context=([^,]+), type=routes, name=([^,]+)><>ExchangesInflight' name: org.apache.camel.ExchangesInflight help: Exchanges Inflight type: GAUGE labels: context: $1 route: $2 type: routes - pattern: 'org.apache.camel<context=([^,]+), type=routes, name=([^,]+)><>ExchangesTotal' name: org.apache.camel.ExchangesTotal help: Exchanges Total type: COUNTER labels: context: $1 route: $2 type: routes - pattern: 'org.apache.camel<context=([^,]+), type=routes, name=([^,]+)><>FailuresHandled' name: org.apache.camel.FailuresHandled help: Failures Handled labels: context: $1 route: $2 type: routes type: COUNTER - pattern: 'org.apache.camel<context=([^,]+), type=routes, name=([^,]+)><>ExternalRedeliveries' name: org.apache.camel.ExternalRedeliveries help: External Redeliveries labels: context: $1 route: $2 type: routes type: COUNTER - pattern: 'org.apache.camel<context=([^,]+), type=routes, name=([^,]+)><>MaxProcessingTime' name: org.apache.camel.MaxProcessingTime help: Maximum Processing Time labels: context: $1 route: $2 type: routes type: GAUGE - pattern: 'org.apache.camel<context=([^,]+), type=routes, name=([^,]+)><>MeanProcessingTime' name: org.apache.camel.MeanProcessingTime help: Mean Processing Time labels: context: $1 route: $2 type: routes type: GAUGE - pattern: 'org.apache.camel<context=([^,]+), type=routes, name=([^,]+)><>MinProcessingTime' name: org.apache.camel.MinProcessingTime help: Minimum Processing Time labels: context: $1 route: $2 type: routes type: GAUGE - pattern: 'org.apache.camel<context=([^,]+), type=routes, name=([^,]+)><>LastProcessingTime' name: org.apache.camel.LastProcessingTime help: Last Processing Time labels: context: $1 route: $2 type: routes type: GAUGE - pattern: 'org.apache.camel<context=([^,]+), type=routes, name=([^,]+)><>DeltaProcessingTime' name: org.apache.camel.DeltaProcessingTime help: Delta Processing Time labels: context: $1 route: $2 type: routes type: GAUGE - pattern: 'org.apache.camel<context=([^,]+), type=routes, name=([^,]+)><>Redeliveries' name: org.apache.camel.Redeliveries help: Redeliveries labels: context: $1 route: $2 type: routes type: COUNTER - pattern: 'org.apache.camel<context=([^,]+), type=routes, name=([^,]+)><>TotalProcessingTime' name: org.apache.camel.TotalProcessingTime help: Total Processing Time labels: context: $1 route: $2 type: routes type: GAUGE - pattern: 'org.apache.camel<context=([^,]+), type=routes, name=([^,]+)><>InflightExchanges' name: org.apache.camel.InflightExchanges help: Inflight Exchanges labels: context: $1 route: $2 type: routes type: GAUGE # Processor level - pattern: 'org.apache.camel<context=([^,]+), type=processors, name=([^,]+)><>ExchangesCompleted' name: org.apache.camel.ExchangesCompleted help: Exchanges Completed type: COUNTER labels: context: $1 processor: $2 type: processors - pattern: 'org.apache.camel<context=([^,]+), type=processors, name=([^,]+)><>ExchangesFailed' name: org.apache.camel.ExchangesFailed help: Exchanges Failed type: COUNTER labels: context: $1 processor: $2 type: processors - pattern: 'org.apache.camel<context=([^,]+), type=processors, name=([^,]+)><>ExchangesInflight' name: org.apache.camel.ExchangesInflight help: Exchanges Inflight type: GAUGE labels: context: $1 processor: $2 type: processors - pattern: 'org.apache.camel<context=([^,]+), type=processors, name=([^,]+)><>ExchangesTotal' name: org.apache.camel.ExchangesTotal help: Exchanges Total type: COUNTER labels: context: $1 processor: $2 type: processors - pattern: 'org.apache.camel<context=([^,]+), type=processors, name=([^,]+)><>FailuresHandled' name: org.apache.camel.FailuresHandled help: Failures Handled labels: context: $1 processor: $2 type: processors type: COUNTER - pattern: 'org.apache.camel<context=([^,]+), type=processors, name=([^,]+)><>ExternalRedeliveries' name: org.apache.camel.ExternalRedeliveries help: External Redeliveries labels: context: $1 processor: $2 type: processors type: COUNTER - pattern: 'org.apache.camel<context=([^,]+), type=processors, name=([^,]+)><>MaxProcessingTime' name: org.apache.camel.MaxProcessingTime help: Maximum Processing Time labels: context: $1 processor: $2 type: processors type: GAUGE - pattern: 'org.apache.camel<context=([^,]+), type=processors, name=([^,]+)><>MeanProcessingTime' name: org.apache.camel.MeanProcessingTime help: Mean Processing Time labels: context: $1 processor: $2 type: processors type: GAUGE - pattern: 'org.apache.camel<context=([^,]+), type=processors, name=([^,]+)><>MinProcessingTime' name: org.apache.camel.MinProcessingTime help: Minimum Processing Time labels: context: $1 processor: $2 type: processors type: GAUGE - pattern: 'org.apache.camel<context=([^,]+), type=processors, name=([^,]+)><>LastProcessingTime' name: org.apache.camel.LastProcessingTime help: Last Processing Time labels: context: $1 processor: $2 type: processors type: GAUGE - pattern: 'org.apache.camel<context=([^,]+), type=processors, name=([^,]+)><>DeltaProcessingTime' name: org.apache.camel.DeltaProcessingTime help: Delta Processing Time labels: context: $1 processor: $2 type: processors type: GAUGE - pattern: 'org.apache.camel<context=([^,]+), type=processors, name=([^,]+)><>Redeliveries' name: org.apache.camel.Redeliveries help: Redeliveries labels: context: $1 processor: $2 type: processors type: COUNTER - pattern: 'org.apache.camel<context=([^,]+), type=processors, name=([^,]+)><>TotalProcessingTime' name: org.apache.camel.TotalProcessingTime help: Total Processing Time labels: context: $1 processor: $2 type: processors type: GAUGE - pattern: 'org.apache.camel<context=([^,]+), type=processors, name=([^,]+)><>InflightExchanges' name: org.apache.camel.InflightExchanges help: Inflight Exchanges labels: context: $1 processor: $2 type: processors type: COUNTER # Consumers - pattern: 'org.apache.camel<context=([^,]+), type=consumers, name=([^,]+)><>InflightExchanges' name: org.apache.camel.InflightExchanges help: Inflight Exchanges labels: context: $1 consumer: $2 type: consumers type: GAUGE # Services - pattern: 'org.apache.camel<context=([^,]+), type=services, name=([^,]+)><>MaxDuration' name: org.apache.camel.MaxDuration help: Maximum Duration labels: context: $1 service: $2 type: services type: GAUGE - pattern: 'org.apache.camel<context=([^,]+), type=services, name=([^,]+)><>MeanDuration' name: org.apache.camel.MeanDuration help: Mean Duration labels: context: $1 service: $2 type: services type: GAUGE - pattern: 'org.apache.camel<context=([^,]+), type=services, name=([^,]+)><>MinDuration' name: org.apache.camel.MinDuration help: Minimum Duration labels: context: $1 service: $2 type: services type: GAUGE - pattern: 'org.apache.camel<context=([^,]+), type=services, name=([^,]+)><>TotalDuration' name: org.apache.camel.TotalDuration help: Total Duration labels: context: $1 service: $2 type: services type: GAUGE - pattern: 'org.apache.camel<context=([^,]+), type=services, name=([^,]+)><>ThreadsBlocked' name: org.apache.camel.ThreadsBlocked help: Threads Blocked labels: context: $1 service: $2 type: services type: GAUGE - pattern: 'org.apache.camel<context=([^,]+), type=services, name=([^,]+)><>ThreadsInterrupted' name: org.apache.camel.ThreadsInterrupted help: Threads Interrupted labels: context: $1 service: $2 type: services type: GAUGE - pattern: 'org.apache.cxf<bus.id=([^,]+), type=([^,]+), service=([^,]+), port=([^,]+), operation=([^,]+)><>NumLogicalRuntimeFaults' name: org.apache.cxf.NumLogicalRuntimeFaults help: Number of logical runtime faults type: GAUGE labels: bus.id: $1 type: $2 service: $3 port: $4 operation: $5 - pattern: 'org.apache.cxf<bus.id=([^,]+), type=([^,]+), service=([^,]+), port=([^,]+)><>NumLogicalRuntimeFaults' name: org.apache.cxf.NumLogicalRuntimeFaults help: Number of logical runtime faults type: GAUGE labels: bus.id: $1 type: $2 service: $3 port: $4 - pattern: 'org.apache.cxf<bus.id=([^,]+), type=([^,]+), service=([^,]+), port=([^,]+), operation=([^,]+)><>AvgResponseTime' name: org.apache.cxf.AvgResponseTime help: Average Response Time type: GAUGE labels: bus.id: $1 type: $2 service: $3 port: $4 operation: $5 - pattern: 'org.apache.cxf<bus.id=([^,]+), type=([^,]+), service=([^,]+), port=([^,]+)><>AvgResponseTime' name: org.apache.cxf.AvgResponseTime help: Average Response Time type: GAUGE labels: bus.id: $1 type: $2 service: $3 port: $4 - pattern: 'org.apache.cxf<bus.id=([^,]+), type=([^,]+), service=([^,]+), port=([^,]+), operation=([^,]+)><>NumInvocations' name: org.apache.cxf.NumInvocations help: Number of invocations type: GAUGE labels: bus.id: $1 type: $2 service: $3 port: $4 operation: $5 - pattern: 'org.apache.cxf<bus.id=([^,]+), type=([^,]+), service=([^,]+), port=([^,]+)><>NumInvocations' name: org.apache.cxf.NumInvocations help: Number of invocations type: GAUGE labels: bus.id: $1 type: $2 service: $3 port: $4 - pattern: 'org.apache.cxf<bus.id=([^,]+), type=([^,]+), service=([^,]+), port=([^,]+), operation=([^,]+)><>MaxResponseTime' name: org.apache.cxf.MaxResponseTime help: Maximum Response Time type: GAUGE labels: bus.id: $1 type: $2 service: $3 port: $4 operation: $5 - pattern: 'org.apache.cxf<bus.id=([^,]+), type=([^,]+), service=([^,]+), port=([^,]+)><>MaxResponseTime' name: org.apache.cxf.MaxResponseTime help: Maximum Response Time type: GAUGE labels: bus.id: $1 type: $2 service: $3 port: $4 - pattern: 'org.apache.cxf<bus.id=([^,]+), type=([^,]+), service=([^,]+), port=([^,]+), operation=([^,]+)><>MinResponseTime' name: org.apache.cxf.MinResponseTime help: Minimum Response Time type: GAUGE labels: bus.id: $1 type: $2 service: $3 port: $4 operation: $5 - pattern: 'org.apache.cxf<bus.id=([^,]+), type=([^,]+), service=([^,]+), port=([^,]+), operation=([^,]+)><>MinResponseTime' name: org.apache.cxf.MinResponseTime help: Minimum Response Time type: GAUGE labels: bus.id: $1 type: $2 service: $3 port: $4 - pattern: 'org.apache.cxf<bus.id=([^,]+), type=([^,]+), service=([^,]+), port=([^,]+), operation=([^,]+)><>TotalHandlingTime' name: org.apache.cxf.TotalHandlingTime help: Total Handling Time type: GAUGE labels: bus.id: $1 type: $2 service: $3 port: $4 operation: $5 - pattern: 'org.apache.cxf<bus.id=([^,]+), type=([^,]+), service=([^,]+), port=([^,]+)><>TotalHandlingTime' name: org.apache.cxf.TotalHandlingTime help: Total Handling Time type: GAUGE labels: bus.id: $1 type: $2 service: $3 port: $4 - pattern: 'org.apache.cxf<bus.id=([^,]+), type=([^,]+), service=([^,]+), port=([^,]+), operation=([^,]+)><>NumRuntimeFaults' name: org.apache.cxf.NumRuntimeFaults help: Number of runtime faults type: GAUGE labels: bus.id: $1 type: $2 service: $3 port: $4 operation: $5 - pattern: 'org.apache.cxf<bus.id=([^,]+), type=([^,]+), service=([^,]+), port=([^,]+)><>NumRuntimeFaults' name: org.apache.cxf.NumRuntimeFaults help: Number of runtime faults type: GAUGE labels: bus.id: $1 type: $2 service: $3 port: $4 - pattern: 'org.apache.cxf<bus.id=([^,]+), type=([^,]+), service=([^,]+), port=([^,]+), operation=([^,]+)><>NumUnCheckedApplicationFaults' name: org.apache.cxf.NumUnCheckedApplicationFaults help: Number of unchecked application faults type: GAUGE labels: bus.id: $1 type: $2 service: $3 port: $4 operation: $5 - pattern: 'org.apache.cxf<bus.id=([^,]+), type=([^,]+), service=([^,]+), port=([^,]+)><>NumUnCheckedApplicationFaults' name: org.apache.cxf.NumUnCheckedApplicationFaults help: Number of unchecked application faults type: GAUGE labels: bus.id: $1 type: $2 service: $3 port: $4 - pattern: 'org.apache.cxf<bus.id=([^,]+), type=([^,]+), service=([^,]+), port=([^,]+), operation=([^,]+)><>NumCheckedApplicationFaults' name: org.apache.cxf.NumCheckedApplicationFaults help: Number of checked application faults type: GAUGE labels: bus.id: $1 type: $2 service: $3 port: $4 operation: $5 - pattern: 'org.apache.cxf<bus.id=([^,]+), type=([^,]+), service=([^,]+), port=([^,]+)><>NumCheckedApplicationFaults' name: org.apache.cxf.NumCheckedApplicationFaults help: Number of checked application faults type: GAUGE labels: bus.id: $1 type: $2 service: $3 port: $4Copy to Clipboard Copied! Toggle word wrap Toggle overflow 将以下内容添加到 Camel 应用程序的
Application.java中:import java.io.InputStream; import io.micrometer.core.instrument.Clock; import org.apache.camel.CamelContext; import org.apache.camel.spring.boot.CamelContextConfiguration; import org.springframework.context.annotation.Bean; import org.apache.camel.component.micrometer.MicrometerConstants; import org.apache.camel.component.micrometer.eventnotifier.MicrometerExchangeEventNotifier; import org.apache.camel.component.micrometer.eventnotifier.MicrometerRouteEventNotifier; import org.apache.camel.component.micrometer.messagehistory.MicrometerMessageHistoryFactory; import org.apache.camel.component.micrometer.routepolicy.MicrometerRoutePolicyFactory;
import java.io.InputStream; import io.micrometer.core.instrument.Clock; import org.apache.camel.CamelContext; import org.apache.camel.spring.boot.CamelContextConfiguration; import org.springframework.context.annotation.Bean; import org.apache.camel.component.micrometer.MicrometerConstants; import org.apache.camel.component.micrometer.eventnotifier.MicrometerExchangeEventNotifier; import org.apache.camel.component.micrometer.eventnotifier.MicrometerRouteEventNotifier; import org.apache.camel.component.micrometer.messagehistory.MicrometerMessageHistoryFactory; import org.apache.camel.component.micrometer.routepolicy.MicrometerRoutePolicyFactory;Copy to Clipboard Copied! Toggle word wrap Toggle overflow 更新的
Application.java如下所示:@SpringBootApplication public class SampleCamelApplication { @Bean(name = {MicrometerConstants.METRICS_REGISTRY_NAME, "prometheusMeterRegistry"}) public PrometheusMeterRegistry prometheusMeterRegistry( PrometheusConfig prometheusConfig, CollectorRegistry collectorRegistry, Clock clock) throws MalformedObjectNameException, IOException { InputStream resource = new ClassPathResource("config/prometheus_exporter_config.yml").getInputStream(); new JmxCollector(resource).register(collectorRegistry); new BuildInfoCollector().register(collectorRegistry); return new PrometheusMeterRegistry(prometheusConfig, collectorRegistry, clock); } @Bean public CamelContextConfiguration camelContextConfiguration(@Autowired PrometheusMeterRegistry registry) { return new CamelContextConfiguration() { @Override public void beforeApplicationStart(CamelContext camelContext) { MicrometerRoutePolicyFactory micrometerRoutePolicyFactory = new MicrometerRoutePolicyFactory(); micrometerRoutePolicyFactory.setMeterRegistry(registry); camelContext.addRoutePolicyFactory(micrometerRoutePolicyFactory); MicrometerMessageHistoryFactory micrometerMessageHistoryFactory = new MicrometerMessageHistoryFactory(); micrometerMessageHistoryFactory.setMeterRegistry(registry); camelContext.setMessageHistoryFactory(micrometerMessageHistoryFactory); MicrometerExchangeEventNotifier micrometerExchangeEventNotifier = new MicrometerExchangeEventNotifier(); micrometerExchangeEventNotifier.setMeterRegistry(registry); camelContext.getManagementStrategy().addEventNotifier(micrometerExchangeEventNotifier); MicrometerRouteEventNotifier micrometerRouteEventNotifier = new MicrometerRouteEventNotifier(); micrometerRouteEventNotifier.setMeterRegistry(registry); camelContext.getManagementStrategy().addEventNotifier(micrometerRouteEventNotifier); } @Override public void afterApplicationStart(CamelContext camelContext) { } }; }@SpringBootApplication public class SampleCamelApplication { @Bean(name = {MicrometerConstants.METRICS_REGISTRY_NAME, "prometheusMeterRegistry"}) public PrometheusMeterRegistry prometheusMeterRegistry( PrometheusConfig prometheusConfig, CollectorRegistry collectorRegistry, Clock clock) throws MalformedObjectNameException, IOException { InputStream resource = new ClassPathResource("config/prometheus_exporter_config.yml").getInputStream(); new JmxCollector(resource).register(collectorRegistry); new BuildInfoCollector().register(collectorRegistry); return new PrometheusMeterRegistry(prometheusConfig, collectorRegistry, clock); } @Bean public CamelContextConfiguration camelContextConfiguration(@Autowired PrometheusMeterRegistry registry) { return new CamelContextConfiguration() { @Override public void beforeApplicationStart(CamelContext camelContext) { MicrometerRoutePolicyFactory micrometerRoutePolicyFactory = new MicrometerRoutePolicyFactory(); micrometerRoutePolicyFactory.setMeterRegistry(registry); camelContext.addRoutePolicyFactory(micrometerRoutePolicyFactory); MicrometerMessageHistoryFactory micrometerMessageHistoryFactory = new MicrometerMessageHistoryFactory(); micrometerMessageHistoryFactory.setMeterRegistry(registry); camelContext.setMessageHistoryFactory(micrometerMessageHistoryFactory); MicrometerExchangeEventNotifier micrometerExchangeEventNotifier = new MicrometerExchangeEventNotifier(); micrometerExchangeEventNotifier.setMeterRegistry(registry); camelContext.getManagementStrategy().addEventNotifier(micrometerExchangeEventNotifier); MicrometerRouteEventNotifier micrometerRouteEventNotifier = new MicrometerRouteEventNotifier(); micrometerRouteEventNotifier.setMeterRegistry(registry); camelContext.getManagementStrategy().addEventNotifier(micrometerRouteEventNotifier); } @Override public void afterApplicationStart(CamelContext camelContext) { } }; }Copy to Clipboard Copied! Toggle word wrap Toggle overflow 将应用部署到 OpenShift。
mvn -Popenshift oc:deploy
mvn -Popenshift oc:deployCopy to Clipboard Copied! Toggle word wrap Toggle overflow 验证您的应用是否已部署。
oc get pods -n myapp NAME READY STATUS RESTARTS AGE camel-example-spring-boot-xml-2-deploy 0/1 Completed 0 13m camel-example-spring-boot-xml-2-x78rk 1/1 Running 0 13m camel-example-spring-boot-xml-s2i-2-build 0/1 Completed 0 14m
oc get pods -n myapp NAME READY STATUS RESTARTS AGE camel-example-spring-boot-xml-2-deploy 0/1 Completed 0 13m camel-example-spring-boot-xml-2-x78rk 1/1 Running 0 13m camel-example-spring-boot-xml-s2i-2-build 0/1 Completed 0 14mCopy to Clipboard Copied! Toggle word wrap Toggle overflow 添加此应用程序的 Service Monitor,以便 Openshift 的 prometheus 实例可以从 / actuator/prometheus 端点开始提取。
为服务监控器创建以下 YAML 清单:在本例中,该文件被命名为
servicemonitor.yaml。apiVersion: monitoring.coreos.com/v1 kind: ServiceMonitor metadata: labels: k8s-app: csb-demo-monitor name: csb-demo-monitor spec: endpoints: - interval: 30s port: http scheme: http path: /actuator/prometheus selector: matchLabels: app: camel-example-spring-boot-xmlapiVersion: monitoring.coreos.com/v1 kind: ServiceMonitor metadata: labels: k8s-app: csb-demo-monitor name: csb-demo-monitor spec: endpoints: - interval: 30s port: http scheme: http path: /actuator/prometheus selector: matchLabels: app: camel-example-spring-boot-xmlCopy to Clipboard Copied! Toggle word wrap Toggle overflow 为此应用程序添加服务监控器。
oc apply -f servicemonitor.yml servicemonitor.monitoring.coreos.com/csb-demo-monitor "myapp" created
oc apply -f servicemonitor.yml servicemonitor.monitoring.coreos.com/csb-demo-monitor "myapp" createdCopy to Clipboard Copied! Toggle word wrap Toggle overflow
验证服务监控器是否已成功部署。
oc get servicemonitor NAME AGE csb-demo-monitor 9m17s
oc get servicemonitor NAME AGE csb-demo-monitor 9m17sCopy to Clipboard Copied! Toggle word wrap Toggle overflow -
验证您可以在提取目标列表中看到服务监控器。在 Administrator 视图中,进入到 Observe
Targets。您可以在提取目标列表中找到 csb-demo-monitor。 -
部署 servicemonitor 后等待大约十分钟。然后,导航到 Developer 视图中的 Observe
Metrics。从下拉菜单中选择 Custom query,然后键入 camel来查看通过 /actuator/prometheus 端点公开的 Camel 指标。
红帽不支持在非 OCP 环境中安装和配置 Prometheus 和 Grafana。