mirror of
https://github.com/elastic/logstash.git
synced 2025-04-24 06:37:19 -04:00
Add metrics filter tests for clear and flush intervals
This commit is contained in:
parent
de0bdacbf7
commit
313923e7e6
1 changed files with 31 additions and 0 deletions
|
@ -74,4 +74,35 @@ describe LogStash::Filters::Metrics do
|
|||
insist { events_tag2.first["http.200.count"] } == 2
|
||||
end
|
||||
end
|
||||
|
||||
context "when a custom flush_interval is set" do
|
||||
it "should flush only when required" do
|
||||
config = {"meter" => ["http.%{response}"], "flush_interval" => 15}
|
||||
filter = LogStash::Filters::Metrics.new config
|
||||
filter.register
|
||||
filter.filter LogStash::Event.new({"response" => 200})
|
||||
|
||||
insist { filter.flush }.nil? # 5s
|
||||
insist { filter.flush }.nil? # 10s
|
||||
insist { filter.flush.length } == 1 # 15s
|
||||
insist { filter.flush }.nil? # 20s
|
||||
insist { filter.flush }.nil? # 25s
|
||||
insist { filter.flush.length } == 1 # 30s
|
||||
end
|
||||
end
|
||||
|
||||
context "when a custom clear_interval is set" do
|
||||
it "should clear the metrics after interval has passed" do
|
||||
config = {"meter" => ["http.%{response}"], "clear_interval" => 15}
|
||||
filter = LogStash::Filters::Metrics.new config
|
||||
filter.register
|
||||
filter.filter LogStash::Event.new({"response" => 200})
|
||||
|
||||
insist { filter.flush.first["http.200.count"] } == 1 # 5s
|
||||
insist { filter.flush.first["http.200.count"] } == 1 # 10s
|
||||
insist { filter.flush.first["http.200.count"] } == 1 # 15s
|
||||
insist { filter.flush }.nil? # 20s
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue