Logstash 简明教程
Logstash - Monitoring APIs
Logstash 提供了用于监控其性能的 API。这些监控 API 会提取 Logstash 的运行时指标。
Logstash offers APIs to monitor its performance. These monitoring APIs extract runtime metrics about Logstash.
Node Info API
此 API 用于获取 Logstash 节点的信息。它将以 JSON 格式返回有关操作系统、Logstash 管道和 JVM 的信息。
This API is used to get the information about the nodes of Logstash. It returns the information of the OS, Logstash pipeline and JVM in JSON format.
你可以使用以下 URL 向 Logstash 发送 get 请求来提取信息 -
You can extract the information by sending a get request to Logstash using the following URL −
GET http://localhost:9600/_node?pretty
Response
以下是节点信息 API 的响应。
Following would be the response of the Node Info API.
{
"host" : "Dell-PC",
"version" : "5.0.1",
"http_address" : "127.0.0.1:9600",
"pipeline" : {
"workers" : 4,
"batch_size" : 125,
"batch_delay" : 5,
"config_reload_automatic" : false,
"config_reload_interval" : 3
},
"os" : {
"name" : "Windows 7",
"arch" : "x86",
"version" : "6.1",
"available_processors" : 4
},
"jvm" : {
"pid" : 312,
"version" : "1.8.0_111",
"vm_name" : "Java HotSpot(TM) Client VM",
"vm_version" : "1.8.0_111",
"vm_vendor" : "Oracle Corporation",
"start_time_in_millis" : 1483770315412,
"mem" : {
"heap_init_in_bytes" : 16777216,
"heap_max_in_bytes" : 1046937600,
"non_heap_init_in_bytes" : 163840,
"non_heap_max_in_bytes" : 0
},
"gc_collectors" : [ "ParNew", "ConcurrentMarkSweep" ]
}
}
你还可以通过在 URL 中添加它们的名称来获取管道、操作系统和 JVM 的特定信息。
You can also get the specific information of Pipeline, OS and JVM, by just adding their names in the URL.
GET http://localhost:9600/_node/os?pretty
GET http://localhost:9600/_node/pipeline?pretty
GET http://localhost:9600/_node/jvm?pretty
Plugins Info API
此 API 用于获取 Logstash 中已安装插件的信息。你可以通过向下面提到的 URL 发送 get 请求来检索此信息 -
This API is used to get the information about the installed plugins in the Logstash. You can retrieve this information by sending a get request to the URL mentioned below −
GET http://localhost:9600/_node/plugins?pretty
Response
以下是插件信息 API 的响应。
Following would be the response of the Plugins Info API.
{
"host" : "Dell-PC",
"version" : "5.0.1",
"http_address" : "127.0.0.1:9600",
"total" : 95,
"plugins" : [ {
"name" : "logstash-codec-collectd",
"version" : "3.0.2"
},
{
"name" : "logstash-codec-dots",
"version" : "3.0.2"
},
{
"name" : "logstash-codec-edn",
"version" : "3.0.2"
},
{
"name" : "logstash-codec-edn_lines",
"version" : "3.0.2"
},
............
}
Node Stats API
此 API 用于以 JSON 对象形式提取 Logstash 的统计信息(内存、进程、JVM、管道)。你可以通过向下面提到的 URL 发送 get 请求来检索此信息 -
This API is used to extract the statistics of the Logstash (Memory, Process, JVM, Pipeline) in JSON objects. You can retrieve this information by sending a get request to the URLS mentioned below −
GET http://localhost:9600/_node/stats/?pretty
GET http://localhost:9600/_node/stats/process?pretty
GET http://localhost:9600/_node/stats/jvm?pretty
GET http://localhost:9600/_node/stats/pipeline?pretty
Hot Threads API
此 API 检索有关 Logstash 中热线程的信息。热线程是 java 线程,具有很高的 CPU 使用率且运行时间超过正常的执行时间。你可以通过向下面提到的 URL 发送 get 请求来检索此信息 -
This API retrieves the information about the hot threads in Logstash. Hot threads are the java threads, which has high CPU usage and run longer than then normal execution time. You can retrieve this information by sending a get request to the URL mentioned below −
GET http://localhost:9600/_node/hot_threads?pretty
用户可以使用以下 URL 以更易读的形式获取响应。
A user can use the following URL to get the response in a form that is more readable.
GET http://localhost:9600/_node/hot_threads?human = true