This is being done in Typescript, but the algorithm is applicable to any language, I think.
I am sending log data (parsed AWS ALB logs) to New Relic, and their maximum pa