Calculate 95th for network traffic per month

46 views
Skip to first unread message

Roman Melnyk

unread,
Apr 7, 2022, 3:49:45 AM4/7/22
to Prometheus Users
Hello.
Is it possible to calculate 95th of network traffic in Prometheus ?
Thank you!

Brian Candler

unread,
Apr 7, 2022, 8:06:33 AM4/7/22
to Prometheus Users
Yes, see quantile_over_time().

Here are some example recording rules, to calculate this continuously:

groups:
- name: bandwidth_percentiles_daily
  interval: 5m
  rules:
  - record: interface:in_octets:rate5m_95th_24h
    expr: quantile_over_time(0.95, rate(ifHCInOctets{instance="XXXX",ifName="YYYY"}[10m])[24h:5m])
  - record: interface:out_octets:rate5m_95th_24h
    expr: quantile_over_time(0.95, rate(ifHCOutOctets{instance="XXXX",ifName="YYYY"}[10m])[24h:5m])

- name: bandwidth_percentiles_monthly
  interval: 1h
  rules:
  - record: interface:in_octets:rate5m_95th_30d
    expr: quantile_over_time(0.95, rate(ifHCInOctets{instance="XXXX",ifName="YYYY"}[10m])[30d:5m])
  - record: interface:out_octets:rate5m_95th_30d
    expr: quantile_over_time(0.95, rate(ifHCOutOctets{instance="XXXX",ifName="YYYY"}[10m])[30d:5m])


Each metric gives the 95th-percentile of the rate taken at 5 minute intervals, over the preceding 24 hours or 30 days respectively.

You can of course use these expressions directly in the PromQL browser for ad-hoc queries.  You should be able to use the new modifier "@time" to perform the query at a given instant in time, so will calculate over the 24 hours or 30 days before that time.
Reply all
Reply to author
Forward
0 new messages