diff options
author | Peter Leitzen <pleitzen@gitlab.com> | 2019-04-04 15:38:37 +0000 |
---|---|---|
committer | James Lopez <james@gitlab.com> | 2019-04-04 15:38:37 +0000 |
commit | 552d38861ad77bf6a64b1e61a91e36fcd26d057c (patch) | |
tree | 4983f872121384e08f5d899367b1d32e84cbcec1 /spec/support | |
parent | c7f918aa691b1b9c6ee6a489ae28a094eacff72c (diff) | |
download | gitlab-ce-552d38861ad77bf6a64b1e61a91e36fcd26d057c.tar.gz |
Automatically set Prometheus step interval
By computing the step interval passed to the query_range Prometheus API
call we improve the performance on the Prometheus server and GitLab by
reducing the amount of data points sent back and prevent Prometheus
from sending errors when requesting longer intervals.
Diffstat (limited to 'spec/support')
-rw-r--r-- | spec/support/helpers/prometheus_helpers.rb | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/spec/support/helpers/prometheus_helpers.rb b/spec/support/helpers/prometheus_helpers.rb index ce1f9fce10d..08d1d7a6059 100644 --- a/spec/support/helpers/prometheus_helpers.rb +++ b/spec/support/helpers/prometheus_helpers.rb @@ -25,12 +25,16 @@ module PrometheusHelpers "https://prometheus.example.com/api/v1/query?#{query}" end - def prometheus_query_range_url(prometheus_query, start: 8.hours.ago, stop: Time.now.to_f) + def prometheus_query_range_url(prometheus_query, start: 8.hours.ago, stop: Time.now, step: nil) + start = start.to_f + stop = stop.to_f + step ||= Gitlab::PrometheusClient.compute_step(start, stop) + query = { query: prometheus_query, - start: start.to_f, + start: start, end: stop, - step: 1.minute.to_i + step: step }.to_query "https://prometheus.example.com/api/v1/query_range?#{query}" |