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
#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 GrafanaReporter::AbstractQuery#format_columns, GrafanaReporter::AbstractQuery#replace_values and GrafanaReporter::AbstractQuery#filter_columns.
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/grafana_reporter/annotations_table_query.rb', line 30 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
-
alertId
-
userId
-
type
-
tags
-
dashboardId
-
panelId
18 19 20 21 22 |
# 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) end |