Class: GrafanaReporter::AnnotationsTableQuery
- Inherits:
-
AbstractQuery
- Object
- AbstractQuery
- GrafanaReporter::AnnotationsTableQuery
- Defined in:
- lib/grafana_reporter/annotations_table_query.rb
Overview
This class is used to query annotations from grafana.
Instance Attribute Summary
Attributes inherited from AbstractQuery
#dashboard, #datasource, #panel, #raw_query, #result, #variables
Instance Method Summary collapse
-
#post_process ⇒ void
Filters the query result for the given columns and sets the result in the preformatted SQL result style.
-
#pre_process ⇒ void
Check if mandatory Grafana::Variable
columns
is specified in variables.
Methods inherited from AbstractQuery
#apply, #execute, #filter_columns, #format_columns, #format_table_output, #initialize, #replace_values, #timeout, #translate_date, #transpose
Constructor Details
This class inherits a constructor from GrafanaReporter::AbstractQuery
Instance Method Details
#post_process ⇒ void
This method returns an undefined value.
Filters the query result for the given columns and sets the result in the preformatted SQL result style.
Additionally it applies ‘after_fetch’ and ‘after_calculate’ actions.
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/grafana_reporter/annotations_table_query.rb', line 31 def post_process @result = apply(@result, @variables['after_fetch'], @variables) @result = apply(@result, @variables['after_calculate'], @variables) @result = format_table_output(@result, row_divider: @variables['row_divider'], column_divider: @variables['column_divider'], table_formatter: @variables['table_formatter'], include_headline: @variables['include_headline'], transpose: @variables['transpose']) end |
#pre_process ⇒ void
This method returns an undefined value.
Check if mandatory Grafana::Variable columns
is specified in variables.
The value of the columns
variable has to be a comma separated list of column titles, which need to be included in the following list:
-
limit
-
alertId
-
userId
-
type
-
tags
-
dashboardId
-
panelId
18 19 20 21 22 23 24 |
# File 'lib/grafana_reporter/annotations_table_query.rb', line 18 def pre_process raise MissingMandatoryAttributeError, 'columns' unless @raw_query['columns'] @datasource = Grafana::GrafanaAnnotationsDatasource.new(nil) @variables['after_fetch'] ||= ::Grafana::Variable.new('filter_columns') @variables['after_calculate'] ||= ::Grafana::Variable.new('format,replace_values,transpose') end |