1

I have a dataset of pairs that represent HTTP request samples

(request time, request duration)

By using apache math EmpiricalDistribution I can calculate the average request count over time like this

double[] input = [request times from the pairs];
EmpiricalDistribution dist = new EmpiricalDistribution((number of buckets));
dist.load(input);

dist.getBinStats()
  .stream()
  .filter(stat -> stat.getN() > 0)
  .forEach(stat -> (logic to store the data in proper format);

This way I can store the data in a chart-like way and plot it later on. Now what I can't do is calculate the average request duration over time.

In systems like Prometheus, this is done by using queries like

  rate(http_server_requests_seconds_sum[5m])
/
  rate(http_server_requests_seconds_count[5m])

I want to achieve the same thing (if possible) in my java code

Borislav Stoilov
  • 3,247
  • 2
  • 21
  • 46

0 Answers0