Commit a47345a6 authored by rpereira2's avatar rpereira2

Add Prometheus series API to allowed list

- Allow the Prometheus::ProxyService to proxy the Prometheus series API.
parent dfdd1f42
......@@ -30,6 +30,10 @@ module Prometheus
'query_range' => {
method: ['GET'],
params: %w(query start end step timeout)
},
'series' => {
method: %w(GET),
params: %w(match start end)
}
}.freeze
......
......@@ -41,6 +41,27 @@ describe Prometheus::ProxyService do
expect(result.params).to eq('query' => '1')
end
end
context 'with series method' do
let(:params) do
ActionController::Parameters.new(
match: ['1'],
start: "2020-06-11T10:15:51Z",
end: "2020-06-11T11:16:06Z",
unknown_param: 'val'
).permit!
end
it 'allows match, start and end parameters' do
result = described_class.new(environment, 'GET', 'series', params)
expect(result.params).to eq(
'match' => ['1'],
'start' => "2020-06-11T10:15:51Z",
'end' => "2020-06-11T11:16:06Z"
)
end
end
end
describe '#execute' do
......@@ -182,6 +203,24 @@ describe Prometheus::ProxyService do
end
end
end
context 'with series API' do
let(:rest_client_response) { instance_double(RestClient::Response, code: 200, body: '') }
let(:params) do
ActionController::Parameters.new(match: ['1'], start: 1.hour.ago.rfc3339, end: Time.current.rfc3339).permit!
end
subject { described_class.new(environment, 'GET', 'series', params) }
it 'calls PrometheusClient with given parameters' do
expect(prometheus_client).to receive(:proxy)
.with('series', params.to_h)
.and_return(rest_client_response)
subject.execute
end
end
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