|
Monitoring System 0.1.0
System resource monitoring with pluggable collectors and alerting
|
Prometheus metric exporter implementation. More...
#include <metric_exporters.h>


Public Member Functions | |
| prometheus_exporter (const metric_export_config &config) | |
| std::vector< prometheus_metric_data > | convert_monitoring_data (const monitoring_data &data) const |
| Convert monitoring_data to Prometheus format. | |
| std::vector< prometheus_metric_data > | convert_snapshot (const metrics_snapshot &snapshot) const |
| Convert metrics_snapshot to Prometheus format. | |
| common::VoidResult | export_metrics (const std::vector< monitoring_data > &metrics) override |
| Export a batch of metrics. | |
| common::VoidResult | export_snapshot (const metrics_snapshot &snapshot) override |
| Export a single metrics snapshot. | |
| std::string | get_metrics_text () const |
| Get current metrics in Prometheus format (for HTTP endpoint) | |
| common::VoidResult | flush () override |
| Flush any pending metrics. | |
| common::VoidResult | shutdown () override |
| Shutdown the exporter. | |
| std::unordered_map< std::string, std::size_t > | get_stats () const override |
| Get exporter statistics. | |
Public Member Functions inherited from kcenon::monitoring::metric_exporter_interface | |
| virtual | ~metric_exporter_interface ()=default |
| virtual common::VoidResult | start () |
| Start the exporter (for pull-based systems) | |
| virtual common::VoidResult | stop () |
| Stop the exporter. | |
Private Member Functions | |
| std::string | sanitize_metric_name (const std::string &name) const |
| std::string | sanitize_label_name (const std::string &name) const |
| metric_type | infer_metric_type (const std::string &name, double) const |
Private Attributes | |
| metric_export_config | config_ |
| std::atomic< std::size_t > | exported_metrics_ {0} |
| std::atomic< std::size_t > | failed_exports_ {0} |
| std::atomic< std::size_t > | scrape_requests_ {0} |
| std::vector< prometheus_metric_data > | current_metrics_ |
| std::mutex | metrics_mutex_ |
Prometheus metric exporter implementation.
Definition at line 286 of file metric_exporters.h.
|
inlineexplicit |
Definition at line 296 of file metric_exporters.h.
|
inline |
Convert monitoring_data to Prometheus format.
Definition at line 302 of file metric_exporters.h.
References config_, kcenon::monitoring::monitoring_data::get_component_name(), kcenon::monitoring::monitoring_data::get_metrics(), kcenon::monitoring::monitoring_data::get_tags(), kcenon::monitoring::monitoring_data::get_timestamp(), infer_metric_type(), kcenon::monitoring::metric_export_config::instance_id, kcenon::monitoring::metric_export_config::labels, kcenon::monitoring::metric::name, sanitize_label_name(), sanitize_metric_name(), kcenon::monitoring::metric::timestamp, kcenon::monitoring::metric::type, and kcenon::monitoring::metric::value.
Referenced by export_metrics(), TEST_F(), and TEST_F().


|
inline |
Convert metrics_snapshot to Prometheus format.
Definition at line 339 of file metric_exporters.h.
References config_, infer_metric_type(), kcenon::monitoring::metric_export_config::instance_id, kcenon::monitoring::metric_export_config::labels, kcenon::monitoring::metrics_snapshot::metrics, kcenon::monitoring::metric::name, sanitize_label_name(), sanitize_metric_name(), kcenon::monitoring::metrics_snapshot::source_id, kcenon::monitoring::metric::timestamp, kcenon::monitoring::metric::type, and kcenon::monitoring::metric::value.
Referenced by export_snapshot(), and TEST_F().


|
inlineoverridevirtual |
Export a batch of metrics.
Implements kcenon::monitoring::metric_exporter_interface.
Definition at line 375 of file metric_exporters.h.
References convert_monitoring_data(), current_metrics_, exported_metrics_, failed_exports_, metrics_mutex_, kcenon::monitoring::operation_failed, and kcenon::monitoring::error_info::to_common_error().
Referenced by TEST_F(), and TEST_F().


|
inlineoverridevirtual |
Export a single metrics snapshot.
Implements kcenon::monitoring::metric_exporter_interface.
Definition at line 396 of file metric_exporters.h.
References convert_snapshot(), current_metrics_, exported_metrics_, failed_exports_, metrics_mutex_, kcenon::monitoring::operation_failed, and kcenon::monitoring::error_info::to_common_error().
Referenced by TEST_F(), and TEST_F().


|
inlineoverridevirtual |
Flush any pending metrics.
Implements kcenon::monitoring::metric_exporter_interface.
Definition at line 430 of file metric_exporters.h.
Referenced by shutdown(), and TEST_F().

|
inline |
Get current metrics in Prometheus format (for HTTP endpoint)
Definition at line 416 of file metric_exporters.h.
References current_metrics_, metrics_mutex_, and scrape_requests_.
Referenced by TEST_F().

|
inlineoverridevirtual |
Get exporter statistics.
Implements kcenon::monitoring::metric_exporter_interface.
Definition at line 439 of file metric_exporters.h.
References current_metrics_, exported_metrics_, failed_exports_, and scrape_requests_.
Referenced by TEST_F(), and TEST_F().

|
inlineprivate |
Definition at line 477 of file metric_exporters.h.
References kcenon::monitoring::counter, kcenon::monitoring::gauge, kcenon::monitoring::histogram, and kcenon::monitoring::summary.
Referenced by convert_monitoring_data(), and convert_snapshot().

|
inlineprivate |
Definition at line 463 of file metric_exporters.h.
Referenced by convert_monitoring_data(), and convert_snapshot().

|
inlineprivate |
Definition at line 449 of file metric_exporters.h.
Referenced by convert_monitoring_data(), and convert_snapshot().

|
inlineoverridevirtual |
Shutdown the exporter.
Implements kcenon::monitoring::metric_exporter_interface.
Definition at line 435 of file metric_exporters.h.
References flush().
Referenced by TEST_F().


|
private |
Definition at line 288 of file metric_exporters.h.
Referenced by convert_monitoring_data(), and convert_snapshot().
|
private |
Definition at line 292 of file metric_exporters.h.
Referenced by export_metrics(), export_snapshot(), get_metrics_text(), and get_stats().
|
private |
Definition at line 289 of file metric_exporters.h.
Referenced by export_metrics(), export_snapshot(), and get_stats().
|
private |
Definition at line 290 of file metric_exporters.h.
Referenced by export_metrics(), export_snapshot(), and get_stats().
|
mutableprivate |
Definition at line 293 of file metric_exporters.h.
Referenced by export_metrics(), export_snapshot(), and get_metrics_text().
|
private |
Definition at line 291 of file metric_exporters.h.
Referenced by get_metrics_text(), and get_stats().