Class: PrometheusMetrics

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/fluent/metrics/prometheusMetrics.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePrometheusMetrics

Returns a new instance of PrometheusMetrics.



14
15
16
17
# File 'lib/fluent/metrics/prometheusMetrics.rb', line 14

def initialize
  createMetrics
  registerMetrics
end

Instance Attribute Details

#bytes_postedObject

Returns the value of attribute bytes_posted.



12
13
14
# File 'lib/fluent/metrics/prometheusMetrics.rb', line 12

def bytes_posted
  @bytes_posted
end

#bytes_receivedObject

Returns the value of attribute bytes_received.



12
13
14
# File 'lib/fluent/metrics/prometheusMetrics.rb', line 12

def bytes_received
  @bytes_received
end

#chunk_time_to_receiveObject

Returns the value of attribute chunk_time_to_receive.



12
13
14
# File 'lib/fluent/metrics/prometheusMetrics.rb', line 12

def chunk_time_to_receive
  @chunk_time_to_receive
end

#chunk_time_to_uploadObject

Returns the value of attribute chunk_time_to_upload.



12
13
14
# File 'lib/fluent/metrics/prometheusMetrics.rb', line 12

def chunk_time_to_upload
  @chunk_time_to_upload
end

#records_errorObject

Returns the value of attribute records_error.



12
13
14
# File 'lib/fluent/metrics/prometheusMetrics.rb', line 12

def records_error
  @records_error
end

#records_invalidObject

Returns the value of attribute records_invalid.



12
13
14
# File 'lib/fluent/metrics/prometheusMetrics.rb', line 12

def records_invalid
  @records_invalid
end

#records_postedObject

Returns the value of attribute records_posted.



12
13
14
# File 'lib/fluent/metrics/prometheusMetrics.rb', line 12

def records_posted
  @records_posted
end

#records_receivedObject

Returns the value of attribute records_received.



12
13
14
# File 'lib/fluent/metrics/prometheusMetrics.rb', line 12

def records_received
  @records_received
end

#records_validObject

Returns the value of attribute records_valid.



12
13
14
# File 'lib/fluent/metrics/prometheusMetrics.rb', line 12

def records_valid
  @records_valid
end

Instance Method Details

#createMetricsObject



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/fluent/metrics/prometheusMetrics.rb', line 18

def createMetrics
  gauge = Prometheus::Client::Gauge
  @records_received = gauge.new(:oci_la_fluentd_output_plugin_records_received, docstring: 'Number of records received by the OCI Logging Analytics Fluentd output plugin.', labels: [:worker_id,:tag,:oci_la_log_group_id,:oci_la_log_source_name,:oci_la_log_set])
  @records_valid = gauge.new(:oci_la_fluentd_output_plugin_records_valid, docstring: 'Number of valid records received by the OCI Logging Analytics Fluentd output plugin.', labels: [:worker_id,:tag,:oci_la_log_group_id,:oci_la_log_source_name,:oci_la_log_set])
  @records_invalid = gauge.new(:oci_la_fluentd_output_plugin_records_invalid, docstring: 'Number of invalid records received by the OCI Logging Analytics Fluentd output plugin.', labels: [:worker_id,:tag,:oci_la_log_group_id,:oci_la_log_source_name,:oci_la_log_set,:reason])
  @records_error = gauge.new(:oci_la_fluentd_output_plugin_records_post_error, docstring: 'Number of records failed posting to OCI Logging Analytics by the Fluentd output plugin.', labels: [:worker_id,:tag,:oci_la_log_group_id,:oci_la_log_source_name,:oci_la_log_set,:error_code, :reason])
  @records_posted = gauge.new(:oci_la_fluentd_output_plugin_records_post_success, docstring: 'Number of records posted by the OCI Logging Analytics Fluentd output plugin.', labels: [:worker_id,:tag,:oci_la_log_group_id,:oci_la_log_source_name,:oci_la_log_set])

  histogram = Prometheus::Client::Histogram
  @chunk_time_to_receive = histogram.new(:oci_la_fluentd_output_plugin_chunk_time_to_receive, docstring: 'Average time taken by Fluentd to deliver the collected records from Input plugin to OCI Logging Analytics output plugin.', labels: [:worker_id,:tag])
  @chunk_time_to_upload = histogram.new(:oci_la_fluentd_output_plugin_chunk_time_to_post, docstring: 'Average time taken for posting the received records to OCI Logging Analytics by the Fluentd output plugin.', labels: [:worker_id,:oci_la_log_group_id])
end

#registerMetricsObject



31
32
33
34
35
36
37
38
39
40
# File 'lib/fluent/metrics/prometheusMetrics.rb', line 31

def registerMetrics
  registry = Prometheus::Client.registry
  registry.register(@records_received) unless registry.exist?('oci_la_fluentd_output_plugin_records_received')
  registry.register(@records_valid) unless registry.exist?('oci_la_fluentd_output_plugin_records_valid')
  registry.register(@records_invalid) unless registry.exist?('oci_la_fluentd_output_plugin_records_invalid')
  registry.register(@records_error) unless registry.exist?('oci_la_fluentd_output_plugin_records_post_error')
  registry.register(@records_posted) unless registry.exist?('oci_la_fluentd_output_plugin_records_post_success')
  registry.register(@chunk_time_to_receive) unless registry.exist?('oci_la_fluentd_output_plugin_chunk_time_to_receive')
  registry.register(@chunk_time_to_upload) unless registry.exist?('oci_la_fluentd_output_plugin_chunk_time_to_post')
end