Commit fb2c4b8e authored by Ash McKenzie's avatar Ash McKenzie

Merge branch 'rc/rename-time-params' into 'master'

Rename time window params

Closes #196986

See merge request gitlab-org/gitlab!26333
parents 5d28c06a ea537e11
...@@ -46,8 +46,8 @@ const requestLogsUntilData = state => { ...@@ -46,8 +46,8 @@ const requestLogsUntilData = state => {
if (state.timeRange.current) { if (state.timeRange.current) {
try { try {
const { start, end } = convertToFixedRange(state.timeRange.current); const { start, end } = convertToFixedRange(state.timeRange.current);
params.start = start; params.start_time = start;
params.end = end; params.end_time = end;
} catch { } catch {
flashTimeRangeWarning(); flashTimeRangeWarning();
} }
......
...@@ -86,8 +86,8 @@ export const fetchDashboard = ({ state, commit, dispatch }) => { ...@@ -86,8 +86,8 @@ export const fetchDashboard = ({ state, commit, dispatch }) => {
if (state.timeRange) { if (state.timeRange) {
const { start, end } = convertToFixedRange(state.timeRange); const { start, end } = convertToFixedRange(state.timeRange);
params.start = start; params.start_time = start;
params.end = end; params.end_time = end;
} }
if (state.currentDashboard) { if (state.currentDashboard) {
...@@ -139,16 +139,16 @@ function fetchPrometheusResult(prometheusEndpoint, params) { ...@@ -139,16 +139,16 @@ function fetchPrometheusResult(prometheusEndpoint, params) {
* @param {metric} metric * @param {metric} metric
*/ */
export const fetchPrometheusMetric = ({ commit }, { metric, params }) => { export const fetchPrometheusMetric = ({ commit }, { metric, params }) => {
const { start, end } = params; const { start_time, end_time } = params;
const timeDiff = (new Date(end) - new Date(start)) / 1000; const timeDiff = (new Date(end_time) - new Date(start_time)) / 1000;
const minStep = 60; const minStep = 60;
const queryDataPoints = 600; const queryDataPoints = 600;
const step = Math.max(minStep, Math.ceil(timeDiff / queryDataPoints)); const step = Math.max(minStep, Math.ceil(timeDiff / queryDataPoints));
const queryParams = { const queryParams = {
start, start_time,
end, end_time,
step, step,
}; };
......
...@@ -48,7 +48,7 @@ module Projects ...@@ -48,7 +48,7 @@ module Projects
end end
def elasticsearch_params def elasticsearch_params
params.permit(:container_name, :pod_name, :search, :start, :end, :cursor) params.permit(:container_name, :pod_name, :search, :start_time, :end_time, :cursor)
end end
def environment def environment
......
...@@ -16,7 +16,7 @@ module PodLogs ...@@ -16,7 +16,7 @@ module PodLogs
private private
def valid_params def valid_params
super + %w(search start end cursor) super + %w(search start_time end_time cursor)
end end
def success_return_keys def success_return_keys
...@@ -24,8 +24,8 @@ module PodLogs ...@@ -24,8 +24,8 @@ module PodLogs
end end
def check_times(result) def check_times(result)
result[:start] = params['start'] if params.key?('start') && Time.iso8601(params['start']) result[:start_time] = params['start_time'] if params.key?('start_time') && Time.iso8601(params['start_time'])
result[:end] = params['end'] if params.key?('end') && Time.iso8601(params['end']) result[:end_time] = params['end_time'] if params.key?('end_time') && Time.iso8601(params['end_time'])
success(result) success(result)
rescue ArgumentError rescue ArgumentError
...@@ -53,8 +53,8 @@ module PodLogs ...@@ -53,8 +53,8 @@ module PodLogs
pod_name: result[:pod_name], pod_name: result[:pod_name],
container_name: result[:container_name], container_name: result[:container_name],
search: result[:search], search: result[:search],
start_time: result[:start], start_time: result[:start_time],
end_time: result[:end], end_time: result[:end_time],
cursor: result[:cursor] cursor: result[:cursor]
) )
......
...@@ -114,11 +114,23 @@ module Prometheus ...@@ -114,11 +114,23 @@ module Prometheus
end end
def filter_params(params, path) def filter_params(params, path)
params = substitute_params(params)
params.slice(*PROXY_SUPPORT.dig(path, :params)) params.slice(*PROXY_SUPPORT.dig(path, :params))
end end
def can_proxy? def can_proxy?
PROXY_SUPPORT.dig(@path, :method)&.include?(@method) PROXY_SUPPORT.dig(@path, :method)&.include?(@method)
end end
def substitute_params(params)
start_time = params[:start_time]
end_time = params[:end_time]
params['start'] = start_time if start_time
params['end'] = end_time if end_time
params
end
end end
end end
...@@ -6,6 +6,7 @@ module Prometheus ...@@ -6,6 +6,7 @@ module Prometheus
steps :validate_variables, steps :validate_variables,
:add_params_to_result, :add_params_to_result,
:substitute_params,
:substitute_ruby_variables, :substitute_ruby_variables,
:substitute_liquid_variables :substitute_liquid_variables
...@@ -35,6 +36,16 @@ module Prometheus ...@@ -35,6 +36,16 @@ module Prometheus
success(result) success(result)
end end
def substitute_params(result)
start_time = result[:params][:start_time]
end_time = result[:params][:end_time]
result[:params][:start] = start_time if start_time
result[:params][:end] = end_time if end_time
success(result)
end
def substitute_liquid_variables(result) def substitute_liquid_variables(result)
return success(result) unless query(result) return success(result) unless query(result)
......
...@@ -21,7 +21,7 @@ module Gitlab ...@@ -21,7 +21,7 @@ module Gitlab
) )
{ {
ops_rate: transform_rate_result(client_query_range(rate_query, start: from, stop: to)), ops_rate: transform_rate_result(client_query_range(rate_query, start_time: from, end_time: to)),
ops_total: transform_sum_result(client_query(total_query, time: to)) ops_total: transform_sum_result(client_query(total_query, time: to))
} }
end end
......
...@@ -13,8 +13,8 @@ describe Gitlab::Prometheus::Queries::AdditionalMetricsDeploymentQuery do ...@@ -13,8 +13,8 @@ describe Gitlab::Prometheus::Queries::AdditionalMetricsDeploymentQuery do
it 'queries using specific time' do it 'queries using specific time' do
expect(client).to receive(:query_range).with(anything, expect(client).to receive(:query_range).with(anything,
start: (deployment.created_at - 30.minutes).to_f, start_time: (deployment.created_at - 30.minutes).to_f,
stop: (deployment.created_at + 30.minutes).to_f) end_time: (deployment.created_at + 30.minutes).to_f)
expect(query_result).not_to be_nil expect(query_result).not_to be_nil
end end
......
...@@ -11,7 +11,7 @@ describe Gitlab::Prometheus::Queries::AdditionalMetricsEnvironmentQuery do ...@@ -11,7 +11,7 @@ describe Gitlab::Prometheus::Queries::AdditionalMetricsEnvironmentQuery do
let(:query_params) { [environment.id] } let(:query_params) { [environment.id] }
it 'queries using specific time' do it 'queries using specific time' do
expect(client).to receive(:query_range).with(anything, start: 8.hours.ago.to_f, stop: Time.now.to_f) expect(client).to receive(:query_range).with(anything, start_time: 8.hours.ago.to_f, end_time: Time.now.to_f)
expect(query_result).not_to be_nil expect(query_result).not_to be_nil
end end
......
...@@ -20,6 +20,6 @@ describe Gitlab::Prometheus::Queries::ClusterQuery do ...@@ -20,6 +20,6 @@ describe Gitlab::Prometheus::Queries::ClusterQuery do
it 'sends queries to prometheus' do it 'sends queries to prometheus' do
subject.query subject.query
expect(client).to have_received(:query_range).with(anything, start: 8.hours.ago, stop: Time.now).at_least(1) expect(client).to have_received(:query_range).with(anything, start_time: 8.hours.ago, end_time: Time.now).at_least(1)
end end
end end
...@@ -82,7 +82,7 @@ describe Gitlab::Prometheus::Queries::PacketFlowQuery do ...@@ -82,7 +82,7 @@ describe Gitlab::Prometheus::Queries::PacketFlowQuery do
context 'ops_rate query' do context 'ops_rate query' do
it 'sets query time range' do it 'sets query time range' do
expect(client).to receive(:query_range).with(anything, start: from, stop: to) expect(client).to receive(:query_range).with(anything, start_time: from, end_time: to)
subject.query(namespace, from: from, to: to) subject.query(namespace, from: from, to: to)
end end
end end
......
...@@ -18,11 +18,11 @@ module Gitlab ...@@ -18,11 +18,11 @@ module Gitlab
timeframe_end = (deployment.created_at + 30.minutes).to_f timeframe_end = (deployment.created_at + 30.minutes).to_f
{ {
memory_values: client_query_range(memory_query, start: timeframe_start, stop: timeframe_end), memory_values: client_query_range(memory_query, start_time: timeframe_start, end_time: timeframe_end),
memory_before: client_query(memory_avg_query, time: deployment.created_at.to_f), memory_before: client_query(memory_avg_query, time: deployment.created_at.to_f),
memory_after: client_query(memory_avg_query, time: timeframe_end), memory_after: client_query(memory_avg_query, time: timeframe_end),
cpu_values: client_query_range(cpu_query, start: timeframe_start, stop: timeframe_end), cpu_values: client_query_range(cpu_query, start_time: timeframe_start, end_time: timeframe_end),
cpu_before: client_query(cpu_avg_query, time: deployment.created_at.to_f), cpu_before: client_query(cpu_avg_query, time: deployment.created_at.to_f),
cpu_after: client_query(cpu_avg_query, time: timeframe_end) cpu_after: client_query(cpu_avg_query, time: timeframe_end)
} }
......
...@@ -15,9 +15,9 @@ module Gitlab ...@@ -15,9 +15,9 @@ module Gitlab
cpu_query = raw_cpu_usage_query(environment_slug) cpu_query = raw_cpu_usage_query(environment_slug)
{ {
memory_values: client_query_range(memory_query, start: timeframe_start, stop: timeframe_end), memory_values: client_query_range(memory_query, start_time: timeframe_start, end_time: timeframe_end),
memory_current: client_query(memory_query, time: timeframe_end), memory_current: client_query(memory_query, time: timeframe_end),
cpu_values: client_query_range(cpu_query, start: timeframe_start, stop: timeframe_end), cpu_values: client_query_range(cpu_query, start_time: timeframe_start, end_time: timeframe_end),
cpu_current: client_query(cpu_query, time: timeframe_end) cpu_current: client_query(cpu_query, time: timeframe_end)
} }
end end
......
...@@ -29,7 +29,7 @@ module Gitlab ...@@ -29,7 +29,7 @@ module Gitlab
def run_query(query, context) def run_query(query, context)
query %= context query %= context
client_query_range(query, start: 8.hours.ago.to_f, stop: Time.now.to_f) client_query_range(query, start_time: 8.hours.ago.to_f, end_time: Time.now.to_f)
end end
def self.transform_reactive_result(result) def self.transform_reactive_result(result)
......
...@@ -43,7 +43,7 @@ module Gitlab ...@@ -43,7 +43,7 @@ module Gitlab
series = metric_groups.flat_map(&:metrics).flat_map(&:required_metrics).uniq series = metric_groups.flat_map(&:metrics).flat_map(&:required_metrics).uniq
lookup = series.each_slice(MAX_QUERY_ITEMS).flat_map do |batched_series| lookup = series.each_slice(MAX_QUERY_ITEMS).flat_map do |batched_series|
client_series(*batched_series, start: timeframe_start, stop: timeframe_end) client_series(*batched_series, start_time: timeframe_start, end_time: timeframe_end)
.select(&method(:has_matching_label?)) .select(&method(:has_matching_label?))
.map { |series_info| [series_info['__name__'], true] } .map { |series_info| [series_info['__name__'], true] }
end end
......
...@@ -59,7 +59,7 @@ module Gitlab ...@@ -59,7 +59,7 @@ module Gitlab
result = result =
if query.key?(:query_range) if query.key?(:query_range)
query[:query_range] %= context query[:query_range] %= context
client_query_range(query[:query_range], start: context[:timeframe_start], stop: context[:timeframe_end]) client_query_range(query[:query_range], start_time: context[:timeframe_start], end_time: context[:timeframe_end])
else else
query[:query] %= context query[:query] %= context
client_query(query[:query], time: context[:timeframe_end]) client_query(query[:query], time: context[:timeframe_end])
......
...@@ -47,17 +47,17 @@ module Gitlab ...@@ -47,17 +47,17 @@ module Gitlab
end end
end end
def query_range(query, start: 8.hours.ago, stop: Time.now) def query_range(query, start_time: 8.hours.ago, end_time: Time.now)
start = start.to_f start_time = start_time.to_f
stop = stop.to_f end_time = end_time.to_f
step = self.class.compute_step(start, stop) step = self.class.compute_step(start_time, end_time)
get_result('matrix') do get_result('matrix') do
json_api_get( json_api_get(
'query_range', 'query_range',
query: query, query: query,
start: start, start: start_time,
end: stop, end: end_time,
step: step step: step
) )
end end
...@@ -67,12 +67,12 @@ module Gitlab ...@@ -67,12 +67,12 @@ module Gitlab
json_api_get("label/#{name}/values") json_api_get("label/#{name}/values")
end end
def series(*matches, start: 8.hours.ago, stop: Time.now) def series(*matches, start_time: 8.hours.ago, end_time: Time.now)
json_api_get('series', 'match': matches, start: start.to_f, end: stop.to_f) json_api_get('series', 'match': matches, start: start_time.to_f, end: end_time.to_f)
end end
def self.compute_step(start, stop) def self.compute_step(start_time, end_time)
diff = stop - start diff = end_time - start_time
step = (diff / QUERY_RANGE_DATA_POINTS).ceil step = (diff / QUERY_RANGE_DATA_POINTS).ceil
......
...@@ -202,8 +202,8 @@ describe('Logs Store actions', () => { ...@@ -202,8 +202,8 @@ describe('Logs Store actions', () => {
return testAction(fetchLogs, null, state, expectedMutations, expectedActions, () => { return testAction(fetchLogs, null, state, expectedMutations, expectedActions, () => {
expect(latestGetParams()).toEqual({ expect(latestGetParams()).toEqual({
pod_name: mockPodName, pod_name: mockPodName,
start: mockFixedRange.start, start_time: mockFixedRange.start,
end: mockFixedRange.end, end_time: mockFixedRange.end,
cursor: mockCursor, cursor: mockCursor,
}); });
}); });
...@@ -280,8 +280,8 @@ describe('Logs Store actions', () => { ...@@ -280,8 +280,8 @@ describe('Logs Store actions', () => {
() => { () => {
expect(latestGetParams()).toEqual({ expect(latestGetParams()).toEqual({
pod_name: mockPodName, pod_name: mockPodName,
start: mockFixedRange.start, start_time: mockFixedRange.start,
end: mockFixedRange.end, end_time: mockFixedRange.end,
cursor: mockCursor, cursor: mockCursor,
}); });
}, },
......
...@@ -509,8 +509,8 @@ describe('Monitoring store actions', () => { ...@@ -509,8 +509,8 @@ describe('Monitoring store actions', () => {
}); });
describe('fetchPrometheusMetric', () => { describe('fetchPrometheusMetric', () => {
const params = { const params = {
start: '2019-08-06T12:40:02.184Z', start_time: '2019-08-06T12:40:02.184Z',
end: '2019-08-06T20:40:02.184Z', end_time: '2019-08-06T20:40:02.184Z',
}; };
let metric; let metric;
let state; let state;
......
...@@ -14,8 +14,8 @@ describe Gitlab::Prometheus::Queries::AdditionalMetricsDeploymentQuery do ...@@ -14,8 +14,8 @@ describe Gitlab::Prometheus::Queries::AdditionalMetricsDeploymentQuery do
it 'queries using specific time' do it 'queries using specific time' do
expect(client).to receive(:query_range).with(anything, expect(client).to receive(:query_range).with(anything,
start: (deployment.created_at - 30.minutes).to_f, start_time: (deployment.created_at - 30.minutes).to_f,
stop: (deployment.created_at + 30.minutes).to_f) end_time: (deployment.created_at + 30.minutes).to_f)
expect(query_result).not_to be_nil expect(query_result).not_to be_nil
end end
......
...@@ -12,7 +12,7 @@ describe Gitlab::Prometheus::Queries::AdditionalMetricsEnvironmentQuery do ...@@ -12,7 +12,7 @@ describe Gitlab::Prometheus::Queries::AdditionalMetricsEnvironmentQuery do
it 'queries using specific time' do it 'queries using specific time' do
expect(client).to receive(:query_range) expect(client).to receive(:query_range)
.with(anything, start: 8.hours.ago.to_f, stop: Time.now.to_f) .with(anything, start_time: 8.hours.ago.to_f, end_time: Time.now.to_f)
expect(query_result).not_to be_nil expect(query_result).not_to be_nil
end end
...@@ -25,7 +25,7 @@ describe Gitlab::Prometheus::Queries::AdditionalMetricsEnvironmentQuery do ...@@ -25,7 +25,7 @@ describe Gitlab::Prometheus::Queries::AdditionalMetricsEnvironmentQuery do
it 'queries using the provided times' do it 'queries using the provided times' do
expect(client).to receive(:query_range) expect(client).to receive(:query_range)
.with(anything, start: start_time, stop: end_time) .with(anything, start_time: start_time, end_time: end_time)
expect(query_result).not_to be_nil expect(query_result).not_to be_nil
end end
end end
...@@ -36,7 +36,7 @@ describe Gitlab::Prometheus::Queries::AdditionalMetricsEnvironmentQuery do ...@@ -36,7 +36,7 @@ describe Gitlab::Prometheus::Queries::AdditionalMetricsEnvironmentQuery do
it 'queries using the provided times converted to unix' do it 'queries using the provided times converted to unix' do
expect(client).to receive(:query_range) expect(client).to receive(:query_range)
.with(anything, start: start_time.to_f, stop: end_time.to_f) .with(anything, start_time: start_time.to_f, end_time: end_time.to_f)
expect(query_result).not_to be_nil expect(query_result).not_to be_nil
end end
end end
......
...@@ -16,22 +16,22 @@ describe Gitlab::Prometheus::Queries::DeploymentQuery do ...@@ -16,22 +16,22 @@ describe Gitlab::Prometheus::Queries::DeploymentQuery do
it 'sends appropriate queries to prometheus' do it 'sends appropriate queries to prometheus' do
start_time = (deployment.created_at - 30.minutes).to_f start_time = (deployment.created_at - 30.minutes).to_f
stop_time = (deployment.created_at + 30.minutes).to_f end_time = (deployment.created_at + 30.minutes).to_f
created_at = deployment.created_at.to_f created_at = deployment.created_at.to_f
expect(client).to receive(:query_range).with('avg(container_memory_usage_bytes{container_name!="POD",environment="environment-slug"}) / 2^20', expect(client).to receive(:query_range).with('avg(container_memory_usage_bytes{container_name!="POD",environment="environment-slug"}) / 2^20',
start: start_time, stop: stop_time) start_time: start_time, end_time: end_time)
expect(client).to receive(:query).with('avg(avg_over_time(container_memory_usage_bytes{container_name!="POD",environment="environment-slug"}[30m]))', expect(client).to receive(:query).with('avg(avg_over_time(container_memory_usage_bytes{container_name!="POD",environment="environment-slug"}[30m]))',
time: created_at) time: created_at)
expect(client).to receive(:query).with('avg(avg_over_time(container_memory_usage_bytes{container_name!="POD",environment="environment-slug"}[30m]))', expect(client).to receive(:query).with('avg(avg_over_time(container_memory_usage_bytes{container_name!="POD",environment="environment-slug"}[30m]))',
time: stop_time) time: end_time)
expect(client).to receive(:query_range).with('avg(rate(container_cpu_usage_seconds_total{container_name!="POD",environment="environment-slug"}[2m])) * 100', expect(client).to receive(:query_range).with('avg(rate(container_cpu_usage_seconds_total{container_name!="POD",environment="environment-slug"}[2m])) * 100',
start: start_time, stop: stop_time) start_time: start_time, end_time: end_time)
expect(client).to receive(:query).with('avg(rate(container_cpu_usage_seconds_total{container_name!="POD",environment="environment-slug"}[30m])) * 100', expect(client).to receive(:query).with('avg(rate(container_cpu_usage_seconds_total{container_name!="POD",environment="environment-slug"}[30m])) * 100',
time: created_at) time: created_at)
expect(client).to receive(:query).with('avg(rate(container_cpu_usage_seconds_total{container_name!="POD",environment="environment-slug"}[30m])) * 100', expect(client).to receive(:query).with('avg(rate(container_cpu_usage_seconds_total{container_name!="POD",environment="environment-slug"}[30m])) * 100',
time: stop_time) time: end_time)
expect(subject.query(deployment.id)).to eq(memory_values: nil, memory_before: nil, memory_after: nil, expect(subject.query(deployment.id)).to eq(memory_values: nil, memory_before: nil, memory_after: nil,
cpu_values: nil, cpu_before: nil, cpu_after: nil) cpu_values: nil, cpu_before: nil, cpu_after: nil)
......
...@@ -22,7 +22,7 @@ describe Gitlab::Prometheus::Queries::KnativeInvocationQuery do ...@@ -22,7 +22,7 @@ describe Gitlab::Prometheus::Queries::KnativeInvocationQuery do
it 'has the query, but no data' do it 'has the query, but no data' do
expect(client).to receive(:query_range).with( expect(client).to receive(:query_range).with(
'sum(ceil(rate(istio_requests_total{destination_service_namespace="test-ns", destination_service=~"test-name.*"}[1m])*60))', 'sum(ceil(rate(istio_requests_total{destination_service_namespace="test-ns", destination_service=~"test-name.*"}[1m])*60))',
hash_including(:start, :stop) hash_including(:start_time, :end_time)
) )
subject.query(serverless_func.id) subject.query(serverless_func.id)
......
...@@ -193,23 +193,23 @@ describe Gitlab::PrometheusClient do ...@@ -193,23 +193,23 @@ describe Gitlab::PrometheusClient do
let(:time_stop) { Time.now.in_time_zone("Warsaw") } let(:time_stop) { Time.now.in_time_zone("Warsaw") }
let(:time_start) { time_stop - 8.hours } let(:time_start) { time_stop - 8.hours }
let(:query_url) { prometheus_query_range_url(prometheus_query, start: time_start.utc.to_f, stop: time_stop.utc.to_f) } let(:query_url) { prometheus_query_range_url(prometheus_query, start_time: time_start.utc.to_f, end_time: time_stop.utc.to_f) }
it 'passed dates are properly converted to utc' do it 'passed dates are properly converted to utc' do
req_stub = stub_prometheus_request(query_url, body: prometheus_values_body('vector')) req_stub = stub_prometheus_request(query_url, body: prometheus_values_body('vector'))
subject.query_range(prometheus_query, start: time_start, stop: time_stop) subject.query_range(prometheus_query, start_time: time_start, end_time: time_stop)
expect(req_stub).to have_been_requested expect(req_stub).to have_been_requested
end end
end end
context 'when a start time is passed' do context 'when a start time is passed' do
let(:query_url) { prometheus_query_range_url(prometheus_query, start: 2.hours.ago) } let(:query_url) { prometheus_query_range_url(prometheus_query, start_time: 2.hours.ago) }
it 'passed it in the requested URL' do it 'passed it in the requested URL' do
req_stub = stub_prometheus_request(query_url, body: prometheus_values_body('vector')) req_stub = stub_prometheus_request(query_url, body: prometheus_values_body('vector'))
subject.query_range(prometheus_query, start: 2.hours.ago) subject.query_range(prometheus_query, start_time: 2.hours.ago)
expect(req_stub).to have_been_requested expect(req_stub).to have_been_requested
end end
end end
......
...@@ -27,8 +27,8 @@ describe ::PodLogs::ElasticsearchService do ...@@ -27,8 +27,8 @@ describe ::PodLogs::ElasticsearchService do
context 'with start and end provided and valid' do context 'with start and end provided and valid' do
let(:params) do let(:params) do
{ {
'start' => start_time, 'start_time' => start_time,
'end' => end_time 'end_time' => end_time
} }
end end
...@@ -36,8 +36,8 @@ describe ::PodLogs::ElasticsearchService do ...@@ -36,8 +36,8 @@ describe ::PodLogs::ElasticsearchService do
result = subject.send(:check_times, {}) result = subject.send(:check_times, {})
expect(result[:status]).to eq(:success) expect(result[:status]).to eq(:success)
expect(result[:start]).to eq(start_time) expect(result[:start_time]).to eq(start_time)
expect(result[:end]).to eq(end_time) expect(result[:end_time]).to eq(end_time)
end end
end end
...@@ -57,8 +57,8 @@ describe ::PodLogs::ElasticsearchService do ...@@ -57,8 +57,8 @@ describe ::PodLogs::ElasticsearchService do
context 'with start valid and end invalid' do context 'with start valid and end invalid' do
let(:params) do let(:params) do
{ {
'start' => start_time, 'start_time' => start_time,
'end' => 'invalid date' 'end_time' => 'invalid date'
} }
end end
...@@ -73,8 +73,8 @@ describe ::PodLogs::ElasticsearchService do ...@@ -73,8 +73,8 @@ describe ::PodLogs::ElasticsearchService do
context 'with start invalid and end valid' do context 'with start invalid and end valid' do
let(:params) do let(:params) do
{ {
'start' => 'invalid date', 'start_time' => 'invalid date',
'end' => end_time 'end_time' => end_time
} }
end end
...@@ -153,8 +153,8 @@ describe ::PodLogs::ElasticsearchService do ...@@ -153,8 +153,8 @@ describe ::PodLogs::ElasticsearchService do
pod_name: pod_name, pod_name: pod_name,
container_name: container_name, container_name: container_name,
search: search, search: search,
start: start_time, start_time: start_time,
end: end_time, end_time: end_time,
cursor: cursor cursor: cursor
} }
end end
......
...@@ -31,15 +31,15 @@ module PrometheusHelpers ...@@ -31,15 +31,15 @@ module PrometheusHelpers
"https://prometheus.example.com/api/v1/query?#{query}" "https://prometheus.example.com/api/v1/query?#{query}"
end end
def prometheus_query_range_url(prometheus_query, start: 8.hours.ago, stop: Time.now, step: nil) def prometheus_query_range_url(prometheus_query, start_time: 8.hours.ago, end_time: Time.now, step: nil)
start = start.to_f start_time = start_time.to_f
stop = stop.to_f end_time = end_time.to_f
step ||= Gitlab::PrometheusClient.compute_step(start, stop) step ||= Gitlab::PrometheusClient.compute_step(start_time, end_time)
query = { query = {
query: prometheus_query, query: prometheus_query,
start: start, start: start_time,
end: stop, end: end_time,
step: step step: step
}.to_query }.to_query
...@@ -50,11 +50,11 @@ module PrometheusHelpers ...@@ -50,11 +50,11 @@ module PrometheusHelpers
"https://prometheus.example.com/api/v1/label/#{name}/values" "https://prometheus.example.com/api/v1/label/#{name}/values"
end end
def prometheus_series_url(*matches, start: 8.hours.ago, stop: Time.now) def prometheus_series_url(*matches, start_time: 8.hours.ago, end_time: Time.now)
query = { query = {
match: matches, match: matches,
start: start.to_f, start: start_time.to_f,
end: stop.to_f end: end_time.to_f
}.to_query }.to_query
"https://prometheus.example.com/api/v1/series?#{query}" "https://prometheus.example.com/api/v1/series?#{query}"
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment