Skip to content

Commit

Permalink
Added filter for throttling
Browse files Browse the repository at this point in the history
  • Loading branch information
Naveen Goswami committed Sep 14, 2018
1 parent 6672a93 commit 9e43a81
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
filter {

throttle {
before_count => "${THROTTLE_SAME_MESSAGE_BEFORE_COUNT}"
after_count => "${THROTTLE_SAME_MESSAGE_AFTER_COUNT}"
period => "${THROTTLE_SAME_MESSAGE_PERIOD}"
max_age => "${THROTTLE_SAME_MESSAGE_MAX_AGE}"
key => "%{[@cf][app_id]}%{[@message]}"
add_tag => ["throttle", "throttled_same_message"]
}

if "throttle_same_message" in [tags] {
drop { percentage => "${THROTTLE_SAME_MESSAGE_DROP_PERCENTAGE}"}
}

throttle {
before_count => "${THROTTLE_RATE_LIMIT_BEFORE_COUNT}"
after_count => "${THROTTLE_RATE_LIMIT_AFTER_COUNT}"
period => "${THROTTLE_RATE_LIMIT_PERIOD}"
max_age => "${THROTTLE_RATE_LIMIT_MAX_AGE}"
key => "%{[@cf][app_id]}"
add_tag => ["throttle", "exceed_rate_limit"]
}

if "throttled" in [tags] {
drop { percentage => "${THROTTLE_RATE_LIMIT_DROP_PERCENTAGE}"}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
output {

if "throttled" in [tags] {
stdout {
codec => line {format => "DROP from Throttled: %{[@cf][app]} %{[@timestamp]} %{[@message]}"}
}

} else if "throttle_same_message" in [tags] {
stdout {
codec => line {format => "DROP from same message: %{[@cf][app]} %{[@timestamp]} %{[@message]}"
}
}

} else {
stdout {
codec => line {format => "%{[@cf][app]} %{[@timestamp]} %{[@message]}"}
}
}

}

0 comments on commit 9e43a81

Please sign in to comment.