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
#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 GrafanaReporter::AbstractQuery#format_columns, GrafanaReporter::AbstractQuery#replace_values and GrafanaReporter::AbstractQuery#filter_columns.
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/grafana_reporter/alerts_table_query.rb', line 31 def post_process @result = format_columns(@result, @variables['format']) @result = replace_values(@result, @variables.select { |k, _v| k =~ /^replace_values_\d+/ }) @result = filter_columns(@result, @variables['filter_columns']) @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 |
# 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) end |