2014-11-02 107 views

回答

0

使用类似奇迹的东西,您可以查看这种类型的数据 - 尽管它不是特定于logstash的 - 它通常都是索引。基础数据可通过_stats/indexing网址获得,但您需要做一些工作才能使其可用。你需要进行轮询,然后计算增量,并按轮询之间的间隔除以每秒的速率。

例如:

curl -s http://localhost:9200/_stats/indexing 

返回数据是这样的:

"_all" : { 
    "primaries" : { 
    "indexing" : { 
     "index_total" : 98241849, 
     "index_time_in_millis" : 23590766, 
     "index_current" : 1, 
     "delete_total" : 8, 
     "delete_time_in_millis" : 4, 
     "delete_current" : 0 
    } 
    }, 
    "total" : { 
    "indexing" : { 
     "index_total" : 195892197, 
     "index_time_in_millis" : 46639803, 
     "index_current" : 2707, 
     "delete_total" : 16, 
     "delete_time_in_millis" : 14, 
     "delete_current" : 0 
    } 
    } 
... 
+0

太好了,谢谢! – deez 2014-11-04 08:04:31

0

的logstash文档建议使用所谓的 “度量” 过滤器插件,以生成该信息。我个人而言,使用输出插件“文件”,该结果从管道

下面分开是the documentation提供的示例:

input { 
    generator { 
    type => "generated" 
    } 
} 

filter { 
    if [type] == "generated" { 
    metrics { 
     meter => "events" 
     add_tag => "metric" 
    } 
    } 
} 

output { 
    # only emit events with the 'metric' tag 
    if "metric" in [tags] { 
    stdout { 
     codec => line { 
     format => "rate: %{[events][rate_1m]}" 
     } 
    } 
    } 
}