4.2. 启用 Data Grid Metrics
配置 Data Grid 以导出量表和直方图。
流程
- 以声明性方式或以编程方式配置指标。
声明性
<cache-container statistics="true"> <metrics gauges="true" histograms="true" /> </cache-container>
<cache-container statistics="true">
<metrics gauges="true" histograms="true" />
</cache-container>
以编程方式
GlobalConfiguration globalConfig = new GlobalConfigurationBuilder() .statistics().enable() .metrics().gauges(true).histograms(true) .build();
GlobalConfiguration globalConfig = new GlobalConfigurationBuilder()
.statistics().enable()
.metrics().gauges(true).histograms(true)
.build();
4.2.1. 收集数据网格指标 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
使用 Prometheus 等监控工具来收集数据网格指标。
先决条件
-
启用统计信息。如果没有启用统计信息,Data Grid 为指标提供
0和-1值。 - (可选)启用直方图。默认情况下,Data Grid 生成量表,但不生成直方图。
流程
获取 Prometheus (OpenMetrics)格式的指标:
curl -v http://localhost:11222/metrics
$ curl -v http://localhost:11222/metricsCopy to Clipboard Copied! Toggle word wrap Toggle overflow 以 MicroProfile JSON 格式获取指标:
curl --header "Accept: application/json" http://localhost:11222/metrics
$ curl --header "Accept: application/json" http://localhost:11222/metricsCopy to Clipboard Copied! Toggle word wrap Toggle overflow
后续步骤
配置监控应用程序以收集数据网格指标。例如,将以下内容添加到 prometheus.yml 中:
static_configs:
- targets: ['localhost:11222']
static_configs:
- targets: ['localhost:11222']
参考
- Prometheus 配置
- 启用 Data Grid Statistics