[GH-ISSUE #848] FloodProtectedHandler #331

Closed
opened 2026-03-04 02:14:12 +03:00 by kerem · 4 comments
Owner

Originally created by @Moosh-be on GitHub (Sep 8, 2016).
Original GitHub issue: https://github.com/Seldaek/monolog/issues/848

Hello,

I need so, I want work on a new feature.

but before I explain it here for feedback

My target is to reduce quantity of similar event.

It's near but not DeduplicationHandler, BufferHandler or SamplingHandler

How ?
Before to store the event

  • compute an hash based on some value of the event
  • use a counter for this key (like redis increment)
  • store event only for some value of counter (ie 1,2,3,5,10,100,1000,10000,...)

My use case .

protect my system when I need to log events that happen rarely but arriving massively.
For example an error on a very very very FREQUENTLY displayed page.

WDYT about this ?


  • the store counter would be shared, and very light
  • the store trigger use the current counter value in a expression
    -- the class provide some common trigger expression like
    --- ($counter % n)
    --- (in array($counter, array(1,10,100,1000,10000,1000000 ))
    --- (in array($counter, array(1,2,3,5,8,13,21,34,55,89, 144, 233, 377,610,987,1597,2584,4181,6765, 10946, 17711, ...))
  • the max value of counter is by default 2^5 but can be set
  • the hash is compute by default on all data of event but we can set whitelist and or blacklist
Originally created by @Moosh-be on GitHub (Sep 8, 2016). Original GitHub issue: https://github.com/Seldaek/monolog/issues/848 Hello, I need so, I want work on a new feature. but before I explain it here for feedback My target is to reduce quantity of similar event. It's near but not DeduplicationHandler, BufferHandler or SamplingHandler How ? Before to store the event - compute an hash based on some value of the event - use a counter for this key (like redis increment) - store event only for some value of counter (ie 1,2,3,5,10,100,1000,10000,...) My use case . protect my system when I need to log events that happen rarely but arriving massively. For example an error on a very very very FREQUENTLY displayed page. WDYT about this ? --- - the store counter would be shared, and very light - the store trigger use the current counter value in a expression -- the class provide some common trigger expression like --- ($counter % n) --- (in array($counter, array(1,10,100,1000,10000,1000000 )) --- (in array($counter, array(1,2,3,5,8,13,21,34,55,89, 144, 233, 377,610,987,1597,2584,4181,6765, 10946, 17711, ...)) - the max value of counter is by default 2^5 but can be set - the hash is compute by default on all data of event but we can set whitelist and or blacklist
kerem closed this issue 2026-03-04 02:14:12 +03:00
Author
Owner

@Moosh-be commented on GitHub (Sep 12, 2016):

ok a colleague told me that a "plug-in" already exist for that.

#34 #87

<!-- gh-comment-id:246302686 --> @Moosh-be commented on GitHub (Sep 12, 2016): ok a colleague told me that a "plug-in" already exist for that. #34 #87
Author
Owner

@Seldaek commented on GitHub (Sep 25, 2016):

Indeed, DeduplicationHandler is all we have right now, but I think it's kinda enough.. What you are looking for sounds very specialized and I think for custom cases it's better to write your custom handler. You can also publish it as a third party handler package so you can re-use it across projects or let others use it too of course.

<!-- gh-comment-id:249425225 --> @Seldaek commented on GitHub (Sep 25, 2016): Indeed, DeduplicationHandler is all we have right now, but I think it's kinda enough.. What you are looking for sounds very specialized and I think for custom cases it's better to write your custom handler. You can also publish it as a third party handler package so you can re-use it across projects or let others use it too of course.
Author
Owner

@Moosh-be commented on GitHub (Sep 25, 2016):

Exactly my idea. Ok.
I would start on miy side aand share my work

<!-- gh-comment-id:249432340 --> @Moosh-be commented on GitHub (Sep 25, 2016): Exactly my idea. Ok. I would start on miy side aand share my work
Author
Owner

@Moosh-be commented on GitHub (Sep 25, 2016):

https://github.com/bobagold/monolog-bubble

<!-- gh-comment-id:249434654 --> @Moosh-be commented on GitHub (Sep 25, 2016): https://github.com/bobagold/monolog-bubble
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/monolog#331
No description provided.