Class: Grafana::ImageRenderingDatasource
- Inherits:
-
AbstractDatasource
- Object
- AbstractDatasource
- Grafana::ImageRenderingDatasource
- Defined in:
- lib/grafana/image_rendering_datasource.rb
Overview
Implements the interface to image rendering datasources.
Instance Attribute Summary
Attributes inherited from AbstractDatasource
Instance Method Summary collapse
-
#request(query_description) ⇒ Object
:raw_query
needs to contain a Hash with the following structure:.
Methods inherited from AbstractDatasource
build_instance, #category, #default_variable_format, handles?, #id, inherited, #initialize, #name, #raw_query_from_panel_model, #replace_variables, #type, #uid
Constructor Details
This class inherits a constructor from Grafana::AbstractDatasource
Instance Method Details
#request(query_description) ⇒ Object
:raw_query
needs to contain a Hash with the following structure:
{
panel: {Panel} which shall be rendered
}
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/grafana/image_rendering_datasource.rb', line 12 def request(query_description) panel = query_description[:raw_query][:panel] webrequest = query_description[:prepared_request] webrequest.relative_url = panel.render_url + url_params(query_description) webrequest..merge!({ accept: 'image/png' }) result = webrequest.execute(query_description[:timeout]) raise ImageCouldNotBeRenderedError, panel if result.body.include?('<html') { header: ['image'], content: [result.body] } end |