Class: Monitoring::MetricTranslator
- Inherits:
-
Object
- Object
- Monitoring::MetricTranslator
- Defined in:
- lib/fluent/plugin/monitoring.rb
Overview
Translate the internal metrics to the curated metrics in Stackdriver. The Prometheus metrics are collected by Google Kubernetes Engine’s monitoring, so we can’t redefine them. Avoid this mechanism for new metrics by defining them in their final form, so they don’t need translation.
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#view_labels ⇒ Object
readonly
Returns the value of attribute view_labels.
Instance Method Summary collapse
-
#initialize(name, metric_labels) ⇒ MetricTranslator
constructor
A new instance of MetricTranslator.
- #translate_labels(labels) ⇒ Object
Constructor Details
#initialize(name, metric_labels) ⇒ MetricTranslator
Returns a new instance of MetricTranslator.
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 |
# File 'lib/fluent/plugin/monitoring.rb', line 229 def initialize(name, metric_labels) @legacy = true case name when :stackdriver_successful_requests_count, :stackdriver_failed_requests_count @name = :request_count when :stackdriver_ingested_entries_count, :stackdriver_dropped_entries_count @name = :log_entry_count when :stackdriver_retried_entries_count @name = :log_entry_retry_count else @name = name @legacy = false end # Collapsed from [:response_code, :grpc] @view_labels = @legacy ? [:response_code] : metric_labels end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
226 227 228 |
# File 'lib/fluent/plugin/monitoring.rb', line 226 def name @name end |
#view_labels ⇒ Object (readonly)
Returns the value of attribute view_labels.
227 228 229 |
# File 'lib/fluent/plugin/monitoring.rb', line 227 def view_labels @view_labels end |
Instance Method Details
#translate_labels(labels) ⇒ Object
248 249 250 251 252 |
# File 'lib/fluent/plugin/monitoring.rb', line 248 def translate_labels(labels) return labels unless @legacy translation = { code: :response_code, grpc: :grpc } labels.map { |k, v| [translation[k], v] }.to_h end |