Class: PrometheusMetric
Constant Summary
ApplicationRecord::MAX_PLUCK
ResetOnUnionError::MAX_RESET_PERIOD
Instance Method Summary
collapse
cached_column_list, #create_or_load_association, declarative_enum, default_select_columns, id_in, id_not_in, iid_in, pluck_primary_key, primary_key_in, #readable_by?, safe_ensure_unique, safe_find_or_create_by, safe_find_or_create_by!, #to_ability_name, underscore, where_exists, where_not_exists, with_fast_read_statement_timeout, without_order
#serializable_hash
Instance Method Details
#group_title ⇒ Object
35
36
37
|
# File 'app/models/prometheus_metric.rb', line 35
def group_title
group_details(group).fetch(:group_title)
end
|
#priority ⇒ Object
31
32
33
|
# File 'app/models/prometheus_metric.rb', line 31
def priority
group_details(group).fetch(:priority)
end
|
#queries ⇒ Object
51
52
53
54
55
56
57
58
59
60
|
# File 'app/models/prometheus_metric.rb', line 51
def queries
[
{
query_range: query,
unit: unit,
label: legend,
series: query_series
}.compact
]
end
|
#query_series ⇒ Object
62
63
64
65
66
67
68
69
70
71
72
73
74
|
# File 'app/models/prometheus_metric.rb', line 62
def query_series
case legend
when 'Status Code'
[{
label: 'status_code',
when: [
{ value: '2xx', color: 'green' },
{ value: '4xx', color: 'orange' },
{ value: '5xx', color: 'red' }
]
}]
end
end
|
#required_metrics ⇒ Object
39
40
41
|
# File 'app/models/prometheus_metric.rb', line 39
def required_metrics
group_details(group).fetch(:required_metrics, []).map(&:to_s)
end
|
#to_metric_hash ⇒ Object
47
48
49
|
# File 'app/models/prometheus_metric.rb', line 47
def to_metric_hash
queries.first.merge(metric_id: id)
end
|
#to_query_metric ⇒ Object
43
44
45
|
# File 'app/models/prometheus_metric.rb', line 43
def to_query_metric
Gitlab::Prometheus::Metric.new(id: id, title: title, required_metrics: required_metrics, weight: 0, y_label: y_label, queries: queries)
end
|