我注意到logstash在性能上很奇怪。如果我有我的配置文件像這樣設置:logstash性能下降
input {
kafka {
topics => ["kafka-jmx"]
bootstrap_servers => "kafka1.com:9092"
consumer_threads => 1
}
}
output {
stdout {}
}
我的消耗量約爲每秒20k信息從kafka。我可以看到,因爲我使用RMI偵聽器啓動了logstash,因此我可以通過jconsole查看JVM中發生了什麼。
當我在添加過濾器是這樣的:
filter {
json {
source => "message"
}
grok {
patterns_dir => "/home/ec2-user/logstash-5.2.0/bin/patterns/"
match => {"metric_path" => [
"%{DATA:kafka_host}\.%{DATA:kafka_metric_group}:type=%{DATA:kafka_metric_type},name=%{WORD:kafka_metric_name},topic=%{KTOPIC:kafka_topic},partition=%{KPARTITION:topic_partition}\.%{GREEDYDATA:attr_type}",
"%{DATA:kafka_host}\.%{DATA:kafka_metric_group}:type=%{DATA:kafka_metric_type},name=%{WORD:kafka_metric_name},topic=%{KTOPIC:kafka_topic}\.%{GREEDYDATA:attr_type}",
"%{DATA:kafka_host}\.%{DATA:kafka_metric_group}:type=%{DATA:kafka_metric_type},name=%{GREEDYDATA:kafka_metric_name}\.%{GREEDYDATA:attr_type}"
]
}
}
ruby {
code => "event.set('time', event.get('@timestamp').to_f * 1000)"
}
mutate {
remove_field => ["message"]
convert => {"time" => "integer"
"metric_value_number" => "integer"
}
}
}
它從20K /秒至約1500 /秒
然後當I增加輸出在這樣的:
output {
influxdb {
host => "10.204.95.88"
db => "monitoring"
measurement => "BrokerMetrics"
retention_policy => "one_week"
allow_time_override => "true"
exclude_fields => ["@timestamp", "@version", "path"]
data_points => {
"time" => "%{time}"
"cluster_field" => "%{cluster}"
"kafka_host_field" => "%{kafka_host}"
"kafka_metric_group_field" => "%{kafka_metric_group}"
"kafka_metric_type_field" => "%{kafka_metric_type}"
"kafka_metric_name_field" => "%{kafka_metric_name}"
"kafka_topic_field" => "%{kafka_topic}"
"attr_type_field" => "%{attr_type}"
"cluster" => "%{[cluster]}"
"kafka_host" => "%{[kafka_host]}"
"kafka_metric_group" => "%{[kafka_metric_group]}"
"kafka_metric_type" => "%{[kafka_metric_type]}"
"kafka_metric_name" => "%{[kafka_metric_name]}"
"kafka_topic" => "%{[kafka_topic]}"
"attr_type" => "%{[attr_type]}"
"metric_value_number" => "%{metric_value_number}"
"metric_value_string" => "%{metric_value_string}"
"topic_partition_field" => "%{topic_partition}"
"topic_partition" => "%{[topic_partition]}"
}
coerce_values => {"metric_value_number" => "integer"}
send_as_tags => [ "kafka_host", "kafka_metric_group","cluster", "kafka_metric_type", "kafka_metric_name", "attr_type", "kafka_topic", "topic_partition" ]
}
}
消耗量從1,500 /秒下降到約300 /秒。總而言之,我的速度從20,000 /秒降至300 /秒。
我沒有在我的logstash.yml文件中設置任何設置,我將heap_size設置爲2g(並且jvm告訴我我有足夠的堆空間)。我也只使用了大約60%的CPU使用率以及...
爲什麼會發生這種情況?我也試過用-w 2
,一直到4啓動logstash時,但似乎沒有影響....