|
Monitoring System 0.1.0
System resource monitoring with pluggable collectors and alerting
|
Container for monitoring metrics from a component. More...
#include <monitorable_interface.h>

Public Types | |
| using | metric_map = std::unordered_map<std::string, double> |
| using | tag_map = std::unordered_map<std::string, std::string> |
Public Member Functions | |
| monitoring_data () | |
| Default constructor. | |
| monitoring_data (const std::string &name) | |
| Constructor with component name. | |
| void | add_metric (const std::string &key, double value) |
| Add a numeric metric. | |
| void | add_tag (const std::string &key, const std::string &value) |
| Add a tag (string metadata) | |
| std::optional< double > | get_metric (const std::string &key) const |
| Get a metric value. | |
| std::optional< std::string > | get_tag (const std::string &key) const |
| Get a tag value. | |
| const metric_map & | get_metrics () const |
| Get all metrics. | |
| const tag_map & | get_tags () const |
| Get all tags. | |
| std::chrono::system_clock::time_point | get_timestamp () const |
| Get the timestamp. | |
| const std::string & | get_component_name () const |
| Get the component name. | |
| void | set_component_name (const std::string &name) |
| Set the component name. | |
| void | clear () |
| Clear all metrics and tags. | |
| bool | empty () const |
| Check if data is empty. | |
| std::size_t | metric_count () const |
| Get the number of metrics. | |
| std::size_t | tag_count () const |
| Get the number of tags. | |
| void | merge (const monitoring_data &other, const std::string &prefix="") |
| Merge another monitoring_data into this one. | |
Private Attributes | |
| metric_map | metrics_ |
| tag_map | tags_ |
| std::chrono::system_clock::time_point | timestamp_ |
| std::string | component_name_ |
Container for monitoring metrics from a component.
This structure holds key-value pairs of metrics that a component exposes for monitoring purposes. It supports both numeric metrics and string tags for additional metadata.
mutable with mutex for thread-safe access in derived classes. Definition at line 63 of file monitorable_interface.h.
| using kcenon::monitoring::monitoring_data::metric_map = std::unordered_map<std::string, double> |
Definition at line 64 of file monitorable_interface.h.
| using kcenon::monitoring::monitoring_data::tag_map = std::unordered_map<std::string, std::string> |
Definition at line 65 of file monitorable_interface.h.
|
inline |
Default constructor.
Definition at line 77 of file monitorable_interface.h.
|
inlineexplicit |
Constructor with component name.
| name | Name of the component being monitored |
Definition at line 84 of file monitorable_interface.h.
|
inline |
Add a numeric metric.
| key | Metric name |
| value | Metric value |
Definition at line 93 of file monitorable_interface.h.
References metrics_.
Referenced by kcenon::monitoring::monitoring_aggregator::collect_all(), MetricExportersTest::create_test_monitoring_data(), test_monitorable_component::get_monitoring_data(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), and kcenon::monitoring::monitorable_component::update_metric().

|
inline |
Add a tag (string metadata)
| key | Tag name |
| value | Tag value |
Definition at line 102 of file monitorable_interface.h.
References tags_.
Referenced by kcenon::monitoring::monitoring_aggregator::collect_all(), MetricExportersTest::create_test_monitoring_data(), test_monitorable_component::get_monitoring_data(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), and kcenon::monitoring::monitorable_component::update_tag().

|
inline |
Clear all metrics and tags.
Definition at line 175 of file monitorable_interface.h.
References metrics_, and tags_.
Referenced by kcenon::monitoring::monitorable_component::reset_monitoring(), and TEST_F().

|
inline |
|
inline |
Get the component name.
Definition at line 160 of file monitorable_interface.h.
References component_name_.
Referenced by kcenon::monitoring::prometheus_exporter::convert_monitoring_data(), kcenon::monitoring::statsd_exporter::convert_monitoring_data(), and TEST_F().

|
inline |
Get a metric value.
| key | Metric name |
Definition at line 111 of file monitorable_interface.h.
References metrics_.
Referenced by TEST_F(), TEST_F(), and TEST_F().

|
inline |
Get all metrics.
Definition at line 136 of file monitorable_interface.h.
References metrics_.
Referenced by kcenon::monitoring::opentelemetry_metrics_adapter::convert_monitoring_data(), kcenon::monitoring::prometheus_exporter::convert_monitoring_data(), and kcenon::monitoring::statsd_exporter::convert_monitoring_data().

|
inline |
Get a tag value.
| key | Tag name |
Definition at line 124 of file monitorable_interface.h.
References tags_.
Referenced by TEST_F(), TEST_F(), and TEST_F().

|
inline |
Get all tags.
Definition at line 144 of file monitorable_interface.h.
References tags_.
Referenced by kcenon::monitoring::opentelemetry_metrics_adapter::convert_monitoring_data(), kcenon::monitoring::prometheus_exporter::convert_monitoring_data(), and kcenon::monitoring::statsd_exporter::convert_monitoring_data().

|
inline |
Get the timestamp.
Definition at line 152 of file monitorable_interface.h.
References timestamp_.
Referenced by kcenon::monitoring::opentelemetry_metrics_adapter::convert_monitoring_data(), kcenon::monitoring::prometheus_exporter::convert_monitoring_data(), and TEST_F().

|
inline |
Merge another monitoring_data into this one.
| other | Data to merge |
| prefix | Optional prefix for merged metrics |
Definition at line 209 of file monitorable_interface.h.
References metrics_, kcenon::monitoring::other, and tags_.
Referenced by kcenon::monitoring::monitoring_aggregator::collect_all(), and TEST_F().

|
inline |
Get the number of metrics.
Definition at line 192 of file monitorable_interface.h.
References metrics_.
Referenced by kcenon::monitoring::monitoring_aggregator::collect_all(), TEST_F(), TEST_F(), and TEST_F().

|
inline |
Set the component name.
| name | Component name |
Definition at line 168 of file monitorable_interface.h.
References component_name_.
Referenced by kcenon::monitoring::monitorable_component::reset_monitoring().

|
inline |
|
private |
Definition at line 71 of file monitorable_interface.h.
Referenced by get_component_name(), and set_component_name().
|
private |
Definition at line 68 of file monitorable_interface.h.
Referenced by add_metric(), clear(), empty(), get_metric(), get_metrics(), merge(), and metric_count().
|
private |
Definition at line 69 of file monitorable_interface.h.
Referenced by add_tag(), clear(), empty(), get_tag(), get_tags(), merge(), and tag_count().
|
private |
Definition at line 70 of file monitorable_interface.h.
Referenced by get_timestamp().