Class: GrafanaReporter::AlertsTableQuery
- Inherits:
-
AbstractQuery
- Object
- AbstractQuery
- GrafanaReporter::AlertsTableQuery
- Defined in:
- lib/grafana_reporter/alerts_table_query.rb
Overview
This class is used to query alerts from grafana.
Instance Attribute Summary
Attributes inherited from AbstractQuery
#dashboard, #datasource, #panel, #raw_query, #result, #variables
Instance Method Summary collapse
-
#post_process ⇒ void
Filter the query result for the given columns and sets the result in the preformatted SQL result stlye.
-
#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.
Filter the query result for the given columns and sets the result in the preformatted SQL result stlye.
Additionally it applies ‘after_fetch’ and ‘after_calculate’ actions.
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/grafana_reporter/alerts_table_query.rb', line 32 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
-
dashboardId
-
panelId
-
query
-
state
-
folderId
-
dashboardQuery
-
dashboardTag
19 20 21 22 23 24 25 |
# File 'lib/grafana_reporter/alerts_table_query.rb', line 19 def pre_process raise MissingMandatoryAttributeError, 'columns' unless @raw_query['columns'] @datasource = Grafana::GrafanaAlertsDatasource.new(nil) @variables['after_fetch'] ||= ::Grafana::Variable.new('filter_columns') @variables['after_calculate'] ||= ::Grafana::Variable.new('format,replace_values,transpose') end |