logstash - Logstash:无法从指标中过滤行
问题描述
我需要从 URL 收集指标。指标的格式是这样的:
# HELP base:classloader_total_loaded_class_count Displays the total number of classes that have been loaded since the Java virtual machine has started execution.
# TYPE base:classloader_total_loaded_class_count counter
base:classloader_total_loaded_class_count 23003.0
我需要从收集的事件中排除所有以“#”字符开头的行。所以我安排了以下配置文件:
input {
http_poller {
urls => {
pool_metrics => {
method => "get"
url => "http://localhost:10090/metrics"
headers => {
"Content-Type" => "text/plain"
}
}
}
request_timeout => 30
schedule => { cron => "* * * * * UTC"}
codec => multiline {
pattern => "^#"
negate => "true"
what => previous
}
type => "server_metrics"
}
}
output {
elasticsearch {
# An index is created for each type of metrics inpout
index => "logstash-%{type}"
}
}
不幸的是,当我通过弹性搜索检查收集的数据时,我发现这并不是我所期望的。例如:
{
"_index" : "logstash-server_metrics",
"_type" : "doc",
"_id" : "2egAvWcBwbQ9kTetvX2o",
"_score" : 1.0,
"_source" : {
"type" : "server_metrics",
"tags" : [
"multiline"
],
"message" : "# TYPE base:gc_ps_scavenge_count counter\nbase:gc_ps_scavenge_count 24.0",
"@version" : "1",
"@timestamp" : "2018-12-17T16:30:01.009Z"
}
},
因此,带有“#”的行似乎没有被跳过,而是附加到指标的下一行。你能推荐任何修复它的方法吗?
解决方案
推荐阅读
- javascript - 无法在输入中输入数字或特殊字符
- android-studio - 为什么 Android Studio 不接受有效的 gradle 版本?
- c++ - 错误:构造函数没有返回类型,它说变量 x 和 y 未声明
- spring-boot - JUnit Mocito Sprintboot UnitTest 失败
- windows - TortoiseSVN 对任何东西都需要 ELEVATION
- python - Python 实例方法目录中的 __func__ 属性的用途是什么?
- node.js - 无法从 Spotify api 获取数据
- python - 如何使用 APScheduler 设置小时范围和分钟间隔
- python - 在同一图上绘制温度循环(加热、冷却、加热)
- batch-file - 嵌套 If 语句和命令 RD