Skip to content

配置指标 ​

Ignite 的指标管理通过命令行工具来操作。

1.列出指标源 ​

可以列出一个节点或整个集群的所有可用指标源:

shell
node metric source list
cluster metric source list

2.列出指标 ​

可以列出节点的所有指标。

提示

要查看指标列表,需要先启用相关指标源,具体请参见下面的启用指标源。

shell
node metric list

上述命令返回与其导出器对应的所有可用指标的列表。

3.启用指标源 ​

指标收集可能会影响程序的性能,因此所有指标源默认都处于禁用状态。

指标源的启用方式:

  • 节点范围:可以使用参数来指定要与之交互的节点,-u可以指定节点的 URL,-n参数可以指定节点名;
  • 集群范围。

例如:

shell
node metric source enable -n=defaultNode jvm
cluster metric source enable jvm

4.禁用指标源 ​

指标源的禁用方式:

  • 节点范围:可以使用参数来指定要与之交互的节点,-u可以指定节点的 URL,-n参数可以指定节点名;
  • 集群范围。

例如:

shell
node metric source disable -n=defaultNode jvm
cluster metric source disable jvm

5.配置指标导出器 ​

要使用外部工具访问收集的指标,需要配置指标导出器。

5.1.JMX ​

JMX 导出器以 JMX(Java 管理扩展)格式提供有关 Ignite 节点的信息,启用该导出器后,节点会向监控工具暴露指标。

JMX 导出器的启用方式:

shell
cluster config update ignite.metrics.exporters.myJmxExporter.exporterName=jmx

之后 JMX 监控工具将能够从指定节点收集已启用的指标: JMX

还可以打开 JMX 所需的内部 JDK 模块,启用远程 JMX 代理,配置连接端口、认证和 SSL,在 Ignite 节点配置中添加以下 JVM 选项:

--add-opens=jdk.management/com.sun.management.internal=ALL-UNNAMED

-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=<PORT_NUMBER>
-Dcom.sun.management.jmxremote.authenticate=true|false
-Dcom.sun.management.jmxremote.ssl=true|false

5.2.日志导出器 ​

日志导出器将指标数据写入日志,以便日志收集器调用或手动检查。可以使用以下参数进行配置:

参数描述默认值
periodMillis指标导出时间间隔(毫秒)。30000
oneLinePerMetricSource是否在单个日志行上打印来自一个指标源的所有指标。true
enabledMetrics启用的指标源列表。如果该列表非空,只输出列出的指标源,其他所有会被跳过。可以使用通配符来匹配前缀(例如:jvm.*)。某些后台活动的指标默认会被输出。metastorage、placement-driver、resource.vacuum

要将日志导出器添加到集群导出器列表,可以执行以下命令,并在enabledMetrics列表中定义要输出的所有指标:

shell
cluster config update ignite.metrics.exporters.logPush '{"exporterName":"logPush","periodMillis":30000,"oneLinePerMetricSource":true,"enabledMetrics":[]}'

更新后的导出器配置应该是这样的:

exporters=[
    {
        enabledMetrics=[]
        exporterName=logPush
        name=logPush
        oneLinePerMetricSource=true
        periodMillis=30000
    }
]

5.3.OpenTelemetry ​

OpenTelemetry 导出器会接入节点提供的 OpenTelemetry 服务,并向其发送集群信息,每个节点独立发送指标,并且需要访问指定的端点。

以下示例显示了基本的 OpenTelemetry 配置,由于 OpenTelemetry 服务需要不同的 URL 格式,并且可能需要头信息,因此此示例可能不适用于具体的环境。

shell
cluster config update ignite.metrics.exporters.test: {exporterName:otlp, endpoint:"http://localhost:9090/api/v1/otlp/v1/metrics", protocol:"http/protobuf"}

此命令创建的 OpenTelemetry 导出器将如下所示:

{
        compression=gzip
        endpoint="http://localhost:9090/api/v1/otlp/v1/metrics"
        exporterName=otlp
        headers=[]
        name=test
        periodMillis=30000
        protocol="http/protobuf"
        ssl {
            ciphers=""
            clientAuth=none
            enabled=false
            keyStore {
                password="********"
                path=""
                type=PKCS12
            }
            trustStore {
                password="********"
                path=""
                type=PKCS12
            }
        }
    },

以下是配置参数的说明:

参数描述默认值
compression对内容的压缩方式,可选值:none、gzipgzip
endpointOpenTelemetry 端点,每个节点单独解析端点。
exporterName导出器名称,必须为 otlp 以使用 OpenTelemetry。
headers请求头信息(如果有)。
name用户定义的导出器名,用于在 Ignite 中引用。
periodMillis指标的导出间隔(毫秒)。30000
protocol用于发送 Opentelemetry 数据的协议,可选值: grpc、http/protobufgrpc
ssl.ciphers要启用的密码列表,以逗号分隔,为空表示自动选择密码。
ssl.clientAuth是否启用 SSL 客户端身份验证以及是否为强制性身份验证。
ssl.enabled是否启用 SSL。false
ssl.keyStore.passwordSSL 密钥库密码。
ssl.keyStore.pathSSL 密钥库的路径。
ssl.keyStore.type密钥库类型。PKCS12
ssl.trustStore.password信任库密码。
ssl.trustStore.path信任库的路径。
ssl.trustStore.type信任库类型。PKCS12

5.3.1.与 Grafana 的集成 ​

连接到 Grafana Cloud 时,需要使用 protobuf 协议,并在配置中传递认证的头信息:

shell
cluster config update ignite.metrics.exporters.test: {exporterName:otlp, endpoint:"https://otlp-gateway-prod-eu-west-2.grafana.net/otlp", protocol:"http/protobuf", headers {Authorization.header="Basic myBasicAuthKey"}}

5.3.2.与 Prometheus 的集成 ​

连接 Prometheus 时,需要使用 protobuf 协议,并在启用 OTLP 指标接收器后将指标发送到/api/v1/otlp/v1/metrics ,具体请参见 Prometheus 文档。

shell
cluster config update ignite.metrics.exporters.test: {exporterName:otlp, endpoint:"http://localhost:9090/api/v1/otlp/v1/metrics", protocol:"http/protobuf"}

18624049226