Jmx 输入插件
编辑Jmx 输入插件
编辑- 插件版本:v3.0.7
- 发布日期:2018-08-13
- 变更日志
其他版本请参见 版本化插件文档。
获取帮助
编辑如有关于插件的问题,请在 Discuss 论坛中发起主题。如需报告错误或提出功能请求,请在 Github 中提交问题。有关 Elastic 支持的插件列表,请查阅 Elastic 支持矩阵。
描述
编辑此输入插件允许使用 JMX 从远程 Java 应用程序检索指标。每隔 polling_frequency
时间,它会扫描包含 JSON 配置文件的文件夹,这些文件描述了要监视的 JVM 以及要检索的指标。然后,线程池将检索指标并创建事件。
配置
编辑在 Logstash 配置中,必须设置轮询频率、用于轮询指标的线程数以及包含每个 JVM 指标检索配置的 JSON 文件的目录绝对路径。Logstash 输入配置示例
jmx { //Required path => "/apps/logstash_conf/jmxconf" //Optional, default 60s polling_frequency => 15 type => "jmx" //Optional, default 4 nb_thread => 4 }
JSON JMX 配置示例
{ //Required, JMX listening host/ip "host" : "192.168.1.2", //Required, JMX listening port "port" : 1335, //Optional, the username to connect to JMX "username" : "user", //Optional, the password to connect to JMX "password": "pass", //Optional, use this alias as a prefix in the metric name. If not set use <host>_<port> "alias" : "test.homeserver.elasticsearch", //Required, list of JMX metrics to retrieve "queries" : [ { //Required, the object name of Mbean to request "object_name" : "java.lang:type=Memory", //Optional, use this alias in the metrics value instead of the object_name "object_alias" : "Memory" }, { "object_name" : "java.lang:type=Runtime", //Optional, set of attributes to retrieve. If not set retrieve //all metrics available on the configured object_name. "attributes" : [ "Uptime", "StartTime" ], "object_alias" : "Runtime" }, { //object_name can be configured with * to retrieve all matching Mbeans "object_name" : "java.lang:type=GarbageCollector,name=*", "attributes" : [ "CollectionCount", "CollectionTime" ], //object_alias can be based on specific value from the object_name thanks to ${<varname>}. //In this case ${type} will be replaced by GarbageCollector... "object_alias" : "${type}.${name}" }, { "object_name" : "java.nio:type=BufferPool,name=*", "object_alias" : "${type}.${name}" } ] }
以下是生成的事件示例。当返回的指标值类型为数字/布尔值时,它将存储在 metric_value_number
事件字段中,否则将存储在 metric_value_string
事件字段中。
{ "@version" => "1", "@timestamp" => "2014-02-18T20:57:27.688Z", "host" => "192.168.1.2", "path" => "/apps/logstash_conf/jmxconf", "type" => "jmx", "metric_path" => "test.homeserver.elasticsearch.GarbageCollector.ParNew.CollectionCount", "metric_value_number" => 2212 }
{ "@version" => "1", "@timestamp" => "2014-02-18T20:58:06.376Z", "host" => "localhost", "path" => "/apps/logstash_conf/jmxconf", "type" => "jmx", "metric_path" => "test.homeserver.elasticsearch.BufferPool.mapped.ObjectName", "metric_value_string" => "java.nio:type=BufferPool,name=mapped" }
常见选项
编辑所有输入插件都支持这些配置选项
codec
编辑- 值类型为 编解码器
- 默认值为
"plain"
用于输入数据的编解码器。输入编解码器是在输入数据进入输入之前对其进行解码的一种便捷方法,无需在 Logstash 管道中使用单独的过滤器。