Zephyr API Documentation 4.0.99
A Scalable Open Source RTOS
|
Data Structures | |
struct | prometheus_collector |
Prometheus collector definition. More... | |
struct | prometheus_counter |
Type used to represent a Prometheus counter metric. More... | |
struct | prometheus_gauge |
Type used to represent a Prometheus gauge metric. More... | |
struct | prometheus_histogram_bucket |
Prometheus histogram bucket definition. More... | |
struct | prometheus_histogram |
Type used to represent a Prometheus histogram metric. More... | |
struct | prometheus_label |
Prometheus label definition. More... | |
struct | prometheus_metric |
Type used to represent a Prometheus metric base. More... | |
struct | prometheus_summary_quantile |
Prometheus summary quantile definition. More... | |
struct | prometheus_summary |
Type used to represent a Prometheus summary metric. More... | |
Macros | |
#define | PROMETHEUS_COLLECTOR_DEFINE(_name, ...) |
Prometheus Collector definition. | |
#define | PROMETHEUS_COUNTER_DEFINE(_name, _desc, _label, _collector, ...) |
Prometheus Counter definition. | |
#define | PROMETHEUS_GAUGE_DEFINE(_name, _desc, _label, _collector, ...) |
Prometheus Gauge definition. | |
#define | PROMETHEUS_HISTOGRAM_DEFINE(_name, _desc, _label, _collector, ...) |
Prometheus Histogram definition. | |
#define | MAX_PROMETHEUS_LABELS_PER_METRIC 1 |
#define | PROMETHEUS_SUMMARY_DEFINE(_name, _desc, _label, _collector, ...) |
Prometheus Summary definition. | |
Typedefs | |
typedef int(* | prometheus_scrape_cb_t) (struct prometheus_collector *collector, struct prometheus_metric *metric, void *user_data) |
Callback used to scrape a collector for a specific metric. | |
Enumerations | |
enum | prometheus_metric_type { PROMETHEUS_COUNTER = 0 , PROMETHEUS_GAUGE , PROMETHEUS_SUMMARY , PROMETHEUS_HISTOGRAM } |
Prometheus metric types. More... | |
Functions | |
int | prometheus_collector_register_metric (struct prometheus_collector *collector, struct prometheus_metric *metric) |
Register a metric with a Prometheus collector. | |
const void * | prometheus_collector_get_metric (struct prometheus_collector *collector, const char *name) |
Get a metric from a Prometheus collector. | |
int | prometheus_collector_walk_metrics (struct prometheus_collector_walk_context *ctx, uint8_t *buffer, size_t buffer_size) |
Walk through all metrics in a Prometheus collector and format them into a buffer. | |
static int | prometheus_collector_walk_init (struct prometheus_collector_walk_context *ctx, struct prometheus_collector *collector) |
Initialize the walker context to walk through all metrics. | |
int | prometheus_counter_add (struct prometheus_counter *counter, uint64_t value) |
Increment the value of a Prometheus counter metric Increments the value of the specified counter metric by arbitrary amount. | |
static int | prometheus_counter_inc (struct prometheus_counter *counter) |
Increment the value of a Prometheus counter metric Increments the value of the specified counter metric by one. | |
int | prometheus_counter_set (struct prometheus_counter *counter, uint64_t value) |
Set the counter value to specific value. | |
int | prometheus_format_exposition (struct prometheus_collector *collector, char *buffer, size_t buffer_size) |
Format exposition data for Prometheus. | |
int | prometheus_format_one_metric (struct prometheus_metric *metric, char *buffer, size_t buffer_size, int *written) |
Format exposition data for one metric for Prometheus. | |
int | prometheus_gauge_set (struct prometheus_gauge *gauge, double value) |
Set the value of a Prometheus gauge metric. | |
int | prometheus_histogram_observe (struct prometheus_histogram *histogram, double value) |
Observe a value in a Prometheus histogram metric. | |
int | prometheus_summary_observe (struct prometheus_summary *summary, double value) |
Observes a value in a Prometheus summary metric. | |
int | prometheus_summary_observe_set (struct prometheus_summary *summary, double value, unsigned long count) |
Set the summary value to specific value. | |
#define MAX_PROMETHEUS_LABELS_PER_METRIC 1 |
#include <zephyr/net/prometheus/label.h>
#define PROMETHEUS_COLLECTOR_DEFINE | ( | _name, | |
... ) |
#include <zephyr/net/prometheus/collector.h>
Prometheus Collector definition.
This macro defines a Collector.
_name | The collector's name. |
... | Optional user callback function. If set, this function is called when the collector is scraped. The function should be of type prometheus_scrape_cb_t. Optional user data to pass to the user callback function. |
#define PROMETHEUS_COUNTER_DEFINE | ( | _name, | |
_desc, | |||
_label, | |||
_collector, | |||
... ) |
#include <zephyr/net/prometheus/counter.h>
Prometheus Counter definition.
This macro defines a Counter metric. If you want to make the counter static, then add "static" keyword before the PROMETHEUS_COUNTER_DEFINE.
_name | The counter metric name |
_desc | Counter description |
_label | Label for the metric. Additional labels can be added at runtime. |
_collector | Collector to map this metric. Can be set to NULL if it not yet known. |
... | Optional user data specific to this metric instance. |
Example usage:
#define PROMETHEUS_GAUGE_DEFINE | ( | _name, | |
_desc, | |||
_label, | |||
_collector, | |||
... ) |
#include <zephyr/net/prometheus/gauge.h>
Prometheus Gauge definition.
This macro defines a Gauge metric. If you want to make the gauge static, then add "static" keyword before the PROMETHEUS_GAUGE_DEFINE.
_name | The gauge metric name. |
_desc | Gauge description |
_label | Label for the metric. Additional labels can be added at runtime. |
_collector | Collector to map this metric. Can be set to NULL if it not yet known. |
... | Optional user data specific to this metric instance. |
Example usage:
#define PROMETHEUS_HISTOGRAM_DEFINE | ( | _name, | |
_desc, | |||
_label, | |||
_collector, | |||
... ) |
#include <zephyr/net/prometheus/histogram.h>
Prometheus Histogram definition.
This macro defines a Histogram metric. If you want to make the histogram static, then add "static" keyword before the PROMETHEUS_HISTOGRAM_DEFINE.
_name | The histogram metric name. |
_desc | Histogram description |
_label | Label for the metric. Additional labels can be added at runtime. |
_collector | Collector to map this metric. Can be set to NULL if it not yet known. |
... | Optional user data specific to this metric instance. |
Example usage:
#define PROMETHEUS_SUMMARY_DEFINE | ( | _name, | |
_desc, | |||
_label, | |||
_collector, | |||
... ) |
#include <zephyr/net/prometheus/summary.h>
Prometheus Summary definition.
This macro defines a Summary metric. If you want to make the summary static, then add "static" keyword before the PROMETHEUS_SUMMARY_DEFINE.
_name | The summary metric name. |
_desc | Summary description |
_label | Label for the metric. Additional labels can be added at runtime. |
_collector | Collector to map this metric. Can be set to NULL if it not yet known. |
... | Optional user data specific to this metric instance. |
Example usage:
typedef int(* prometheus_scrape_cb_t) (struct prometheus_collector *collector, struct prometheus_metric *metric, void *user_data) |
#include <zephyr/net/prometheus/collector.h>
Callback used to scrape a collector for a specific metric.
collector | A valid pointer on the collector to scrape |
metric | A valid pointer on the metric to scrape |
user_data | A valid pointer to a user data or NULL |
#include <zephyr/net/prometheus/metric.h>
Prometheus metric types.
Enumerator | |
---|---|
PROMETHEUS_COUNTER | Prometheus Counter. |
PROMETHEUS_GAUGE | Prometheus Gauge. |
PROMETHEUS_SUMMARY | Prometheus Summary. |
PROMETHEUS_HISTOGRAM | Prometheus Histogram. |
const void * prometheus_collector_get_metric | ( | struct prometheus_collector * | collector, |
const char * | name ) |
#include <zephyr/net/prometheus/collector.h>
Get a metric from a Prometheus collector.
Retrieves the metric with the specified name from the given collector.
collector | Pointer to the collector to retrieve the metric from. |
name | Name of the metric to retrieve. |
int prometheus_collector_register_metric | ( | struct prometheus_collector * | collector, |
struct prometheus_metric * | metric ) |
#include <zephyr/net/prometheus/collector.h>
Register a metric with a Prometheus collector.
Registers the specified metric with the given collector.
collector | Pointer to the collector to register the metric with. |
metric | Pointer to the metric to register. |
-EINVAL | Invalid arguments. |
-ENOMEM | Not enough memory to register the metric. |
|
inlinestatic |
#include <zephyr/net/prometheus/collector.h>
Initialize the walker context to walk through all metrics.
ctx | Pointer to the walker context. |
collector | Pointer to the collector to walk through. |
int prometheus_collector_walk_metrics | ( | struct prometheus_collector_walk_context * | ctx, |
uint8_t * | buffer, | ||
size_t | buffer_size ) |
#include <zephyr/net/prometheus/collector.h>
Walk through all metrics in a Prometheus collector and format them into a buffer.
ctx | Pointer to the walker context. |
buffer | Pointer to the buffer to store the formatted metrics. |
buffer_size | Size of the buffer. |
int prometheus_counter_add | ( | struct prometheus_counter * | counter, |
uint64_t | value ) |
#include <zephyr/net/prometheus/counter.h>
Increment the value of a Prometheus counter metric Increments the value of the specified counter metric by arbitrary amount.
counter | Pointer to the counter metric to increment. |
value | Amount to increment the counter by. |
|
inlinestatic |
#include <zephyr/net/prometheus/counter.h>
Increment the value of a Prometheus counter metric Increments the value of the specified counter metric by one.
counter | Pointer to the counter metric to increment. |
int prometheus_counter_set | ( | struct prometheus_counter * | counter, |
uint64_t | value ) |
#include <zephyr/net/prometheus/counter.h>
Set the counter value to specific value.
The new value must be higher than the current value. This function can be used if we cannot add individual increments to the counter but need to periodically update the counter value. This function will add the difference between the new value and the old value to the counter.
counter | Pointer to the counter metric to increment. |
value | New value of the counter. |
int prometheus_format_exposition | ( | struct prometheus_collector * | collector, |
char * | buffer, | ||
size_t | buffer_size ) |
#include <zephyr/net/prometheus/formatter.h>
Format exposition data for Prometheus.
Formats the exposition data collected by the specified collector into the provided buffer. Function will format metric data according to Prometheus text-based format
collector | Pointer to the collector containing the data to format. |
buffer | Pointer to the buffer where the formatted exposition data will be stored. |
buffer_size | Size of the buffer. |
int prometheus_format_one_metric | ( | struct prometheus_metric * | metric, |
char * | buffer, | ||
size_t | buffer_size, | ||
int * | written ) |
#include <zephyr/net/prometheus/formatter.h>
Format exposition data for one metric for Prometheus.
Formats the exposition data of one specific metric into the provided buffer. Function will format metric data according to Prometheus text-based format.
metric | Pointer to the metric containing the data to format. |
buffer | Pointer to the buffer where the formatted exposition data will be stored. |
buffer_size | Size of the buffer. |
written | How many bytes have been written to the buffer. |
int prometheus_gauge_set | ( | struct prometheus_gauge * | gauge, |
double | value ) |
#include <zephyr/net/prometheus/gauge.h>
Set the value of a Prometheus gauge metric.
Sets the value of the specified gauge metric to the given value.
gauge | Pointer to the gauge metric to set. |
value | Value to set the gauge metric to. |
int prometheus_histogram_observe | ( | struct prometheus_histogram * | histogram, |
double | value ) |
#include <zephyr/net/prometheus/histogram.h>
Observe a value in a Prometheus histogram metric.
Observes the specified value in the given histogram metric.
histogram | Pointer to the histogram metric to observe. |
value | Value to observe in the histogram metric. |
int prometheus_summary_observe | ( | struct prometheus_summary * | summary, |
double | value ) |
#include <zephyr/net/prometheus/summary.h>
Observes a value in a Prometheus summary metric.
Observes the specified value in the given summary metric.
summary | Pointer to the summary metric to observe. |
value | Value to observe in the summary metric. |
int prometheus_summary_observe_set | ( | struct prometheus_summary * | summary, |
double | value, | ||
unsigned long | count ) |
#include <zephyr/net/prometheus/summary.h>
Set the summary value to specific value.
The new value must be higher than the current value. This function can be used if we cannot add individual increments to the summary but need to periodically update the counter value. This function will add the difference between the new value and the old value to the summary fields.
summary | Pointer to the summary metric to increment. |
value | New value of the summary. |
count | New counter value of the summary. |