Seastar
High performance C++ framework for concurrent servers
|
metrics creation and registration
the metrics namespace holds the relevant method and classes to generate metrics.
The metrics layer support registering metrics, that later will be exported via different API protocols.
To be able to support multiple protocols the following simplifications where made:
To add metrics definition to class A do the following:
In A header file
In A source file:
Classes | |
class | double_registration |
class | description |
Human-readable description of a metric/group. More... | |
class | label_instance |
Label a metrics. More... | |
class | label |
Class that creates label instances. More... | |
struct | metric_relabeling_result |
result of metric relabeling More... | |
struct | options |
Metrics configuration options. More... | |
class | metric_definition |
class | metric_group_definition |
class | metric_groups |
holds the metric definition. More... | |
class | metric_group |
hold a single metric group Initialization is done in the constructor or with a call to add_group More... | |
struct | histogram_bucket |
Histogram bucket type. More... | |
struct | histogram |
Histogram data type. More... | |
class | relabel_config_regex |
a wrapper class around regex with the original expr More... | |
struct | relabel_config |
a relabel_config allows changing metrics labels dynamically More... | |
Typedefs | |
using | metric_type_def = sstring |
using | metric_name_type = sstring |
using | instance_id_type = sstring |
using | skip_when_empty = bool_class< class skip_when_empty_tag > |
using | group_name_type = sstring |
Functions | |
template<typename T > | |
impl::metric_definition_impl | make_gauge (metric_name_type name, T &&val, description d=description(), std::vector< label_instance > labels={}) |
Gauge are a general purpose metric. More... | |
template<typename T > | |
impl::metric_definition_impl | make_gauge (metric_name_type name, description d, T &&val) |
Gauge are a general purpose metric. More... | |
template<typename T > | |
impl::metric_definition_impl | make_gauge (metric_name_type name, description d, std::vector< label_instance > labels, T &&val) |
Gauge are a general purpose metric. More... | |
template<typename T > | |
impl::metric_definition_impl | make_derive (metric_name_type name, T &&val, description d=description(), std::vector< label_instance > labels={}) |
Derive are used when a rate is more interesting than the value. More... | |
template<typename T > | |
impl::metric_definition_impl | make_derive (metric_name_type name, description d, T &&val) |
Derive are used when a rate is more interesting than the value. More... | |
template<typename T > | |
impl::metric_definition_impl | make_derive (metric_name_type name, description d, std::vector< label_instance > labels, T &&val) |
Derive are used when a rate is more interesting than the value. More... | |
template<typename T > | |
impl::metric_definition_impl | make_counter (metric_name_type name, T &&val, description d=description(), std::vector< label_instance > labels={}) |
create a counter metric More... | |
template<typename T > | |
impl::metric_definition_impl | make_counter (metric_name_type name, description d, T &&val) |
create a counter metric More... | |
template<typename T > | |
impl::metric_definition_impl | make_counter (metric_name_type name, description d, std::vector< label_instance > labels, T &&val) |
create a counter metric More... | |
template<typename T > | |
impl::metric_definition_impl | make_absolute (metric_name_type name, T &&val, description d=description(), std::vector< label_instance > labels={}) |
create an absolute metric. More... | |
template<typename T > | |
impl::metric_definition_impl | make_histogram (metric_name_type name, T &&val, description d=description(), std::vector< label_instance > labels={}) |
create a histogram metric. More... | |
template<typename T > | |
impl::metric_definition_impl | make_histogram (metric_name_type name, description d, std::vector< label_instance > labels, T &&val) |
create a histogram metric. More... | |
template<typename T > | |
impl::metric_definition_impl | make_histogram (metric_name_type name, description d, T &&val) |
create a histogram metric. More... | |
template<typename T > | |
impl::metric_definition_impl | make_summary (metric_name_type name, description d, T &&val) |
create a summary metric. More... | |
template<typename T > | |
impl::metric_definition_impl | make_total_bytes (metric_name_type name, T &&val, description d=description(), std::vector< label_instance > labels={}, instance_id_type=impl::shard()) |
create a total_bytes metric. More... | |
template<typename T > | |
impl::metric_definition_impl | make_current_bytes (metric_name_type name, T &&val, description d=description(), std::vector< label_instance > labels={}, instance_id_type=impl::shard()) |
create a current_bytes metric. More... | |
template<typename T > | |
impl::metric_definition_impl | make_queue_length (metric_name_type name, T &&val, description d=description(), std::vector< label_instance > labels={}, instance_id_type=impl::shard()) |
create a queue_length metric. More... | |
template<typename T > | |
impl::metric_definition_impl | make_total_operations (metric_name_type name, T &&val, description d=description(), std::vector< label_instance > labels={}, instance_id_type=impl::shard()) |
create a total operation metric. More... | |
future | configure (const options &opts) |
set the metrics configuration | |
future< metric_relabeling_result > | set_relabel_configs (const std::vector< relabel_config > &relabel_configs) |
Perform relabeling and operation on metrics dynamically. More... | |
const std::vector< relabel_config > & | get_relabel_configs () |
relabel_config::relabel_action | relabel_config_action (const std::string &action) |
a helper function to translate a string to relabel_config::relabel_action enum values | |
Variables | |
const bool | metric_disabled |
label | shard_label |
struct seastar::metrics::metric_relabeling_result |
using seastar::metrics::group_name_type = typedef sstring |
A group of logically related metrics
future<metric_relabeling_result> seastar::metrics::set_relabel_configs | ( | const std::vector< relabel_config > & | relabel_configs | ) |
Perform relabeling and operation on metrics dynamically.
The function would return true if the changes were applied with no conflict or false, if there was a conflict in the registration.
The general logic follows Prometheus metrics_relabel_config configuration. The relabel rules are applied one after the other. You can add or change a label. you can enable or disable a metric, in that case the metrics will not be reported at all. You can turn on and off the skip_when_empty flag.
Using the Prometheus convention, the metric name is name. Names cannot be changed.
Import notes:
A few examples: To add a level label with a value 1, to the reactor_utilization metric: std::vector<sm::relabel_config> rl(1); rl[0].source_labels = {"__name__"}; rl[0].target_label = "level"; rl[0].replacement = "1"; rl[0].expr = "reactor_utilization"; set_relabel_configs(rl);
To report only the metrics with the level label equals 1
std::vector<sm::relabel_config> rl(2); rl[0].source_labels = {"__name__"}; rl[0].action = sm::relabel_config::relabel_action::drop;
rl[1].source_labels = {"level"}; rl[1].expr = "1"; rl[1].action = sm::relabel_config::relabel_action::keep; set_relabel_configs(rl);