Initial metrics support based on Prometheus (#1571)
* Initial metrics support based on Prometheus
This commit introduces initial support for metrics in open5gs.
The metrics code is added as libogsmetrics (lib/metrics/), with a well
defined opaque API to manage different types of metrics, allowing for
different implementations for different technologies to scrap the
metrics (placed as lib/metrics/<impl>/. The implementation is right now
selected at build time, in order to be able to opt-out the related dependencies
for users not interested in the features. 2 implementations are already
provided in this commit to start with:
* void: Default implementation. Empty stubs, acts as a NOOP.
* prometheus: open5gs processes become Prometheus servers, offering
states through an http server to the Prometheus scrappers. Relies on
libprom (prometheus-client-ci [1] project) to track the metrics and format
them during export, and libmicrohttpd to make the export possible through
HTTP.
[1] https://github.com/digitalocean/prometheus-client-c
The prometheus-client-c is not well maintained nowadays in upstream, and
furthermore it uses a quite peculiar mixture of build systems (autolib
on the main dir, cmake for libprom in a subdir). This makes it difficult
to have it widely available in distros, and difficult to find it if it
is installed in the system. Hence, the best is to include it as a
meson subproject like we already do for freeDiameter. An open5gs fork is
requried in order to have an extra patch adding a top-level
CMakeList.txt in order to be able to includ eit from open5gs's meson
build. Furthermore, this allows adding bugfixes to the subproject if any
are found in the future.
* [SMF] Initial metrics support
* [SMF] Add metrics at gtp_node level
* docs: Add tutorial documenting metrics with Prometheus
2022-06-07 20:51:02 +00:00
|
|
|
#ifndef SMF_METRICS_H
|
|
|
|
#define SMF_METRICS_H
|
|
|
|
|
|
|
|
#include "ogs-metrics.h"
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* GLOBAL */
|
|
|
|
typedef enum smf_metric_type_global_s {
|
2022-06-23 13:03:34 +00:00
|
|
|
SMF_METR_GLOB_CTR_GTP_NEW_NODE_FAILED = 0,
|
|
|
|
SMF_METR_GLOB_CTR_GN_RX_PARSE_FAILED,
|
Initial metrics support based on Prometheus (#1571)
* Initial metrics support based on Prometheus
This commit introduces initial support for metrics in open5gs.
The metrics code is added as libogsmetrics (lib/metrics/), with a well
defined opaque API to manage different types of metrics, allowing for
different implementations for different technologies to scrap the
metrics (placed as lib/metrics/<impl>/. The implementation is right now
selected at build time, in order to be able to opt-out the related dependencies
for users not interested in the features. 2 implementations are already
provided in this commit to start with:
* void: Default implementation. Empty stubs, acts as a NOOP.
* prometheus: open5gs processes become Prometheus servers, offering
states through an http server to the Prometheus scrappers. Relies on
libprom (prometheus-client-ci [1] project) to track the metrics and format
them during export, and libmicrohttpd to make the export possible through
HTTP.
[1] https://github.com/digitalocean/prometheus-client-c
The prometheus-client-c is not well maintained nowadays in upstream, and
furthermore it uses a quite peculiar mixture of build systems (autolib
on the main dir, cmake for libprom in a subdir). This makes it difficult
to have it widely available in distros, and difficult to find it if it
is installed in the system. Hence, the best is to include it as a
meson subproject like we already do for freeDiameter. An open5gs fork is
requried in order to have an extra patch adding a top-level
CMakeList.txt in order to be able to includ eit from open5gs's meson
build. Furthermore, this allows adding bugfixes to the subproject if any
are found in the future.
* [SMF] Initial metrics support
* [SMF] Add metrics at gtp_node level
* docs: Add tutorial documenting metrics with Prometheus
2022-06-07 20:51:02 +00:00
|
|
|
SMF_METR_GLOB_CTR_GN_RX_CREATEPDPCTXREQ,
|
|
|
|
SMF_METR_GLOB_CTR_GN_RX_DELETEPDPCTXREQ,
|
|
|
|
SMF_METR_GLOB_CTR_S5C_RX_PARSE_FAILED,
|
|
|
|
SMF_METR_GLOB_CTR_S5C_RX_CREATESESSIONREQ,
|
|
|
|
SMF_METR_GLOB_CTR_S5C_RX_DELETESESSIONREQ,
|
2022-12-07 07:44:57 +00:00
|
|
|
SMF_METR_GLOB_CTR_SM_N4SESSIONESTABREQ,
|
|
|
|
SMF_METR_GLOB_CTR_SM_N4SESSIONREPORT,
|
|
|
|
SMF_METR_GLOB_CTR_SM_N4SESSIONREPORTSUCC,
|
Initial metrics support based on Prometheus (#1571)
* Initial metrics support based on Prometheus
This commit introduces initial support for metrics in open5gs.
The metrics code is added as libogsmetrics (lib/metrics/), with a well
defined opaque API to manage different types of metrics, allowing for
different implementations for different technologies to scrap the
metrics (placed as lib/metrics/<impl>/. The implementation is right now
selected at build time, in order to be able to opt-out the related dependencies
for users not interested in the features. 2 implementations are already
provided in this commit to start with:
* void: Default implementation. Empty stubs, acts as a NOOP.
* prometheus: open5gs processes become Prometheus servers, offering
states through an http server to the Prometheus scrappers. Relies on
libprom (prometheus-client-ci [1] project) to track the metrics and format
them during export, and libmicrohttpd to make the export possible through
HTTP.
[1] https://github.com/digitalocean/prometheus-client-c
The prometheus-client-c is not well maintained nowadays in upstream, and
furthermore it uses a quite peculiar mixture of build systems (autolib
on the main dir, cmake for libprom in a subdir). This makes it difficult
to have it widely available in distros, and difficult to find it if it
is installed in the system. Hence, the best is to include it as a
meson subproject like we already do for freeDiameter. An open5gs fork is
requried in order to have an extra patch adding a top-level
CMakeList.txt in order to be able to includ eit from open5gs's meson
build. Furthermore, this allows adding bugfixes to the subproject if any
are found in the future.
* [SMF] Initial metrics support
* [SMF] Add metrics at gtp_node level
* docs: Add tutorial documenting metrics with Prometheus
2022-06-07 20:51:02 +00:00
|
|
|
SMF_METR_GLOB_GAUGE_UES_ACTIVE,
|
|
|
|
SMF_METR_GLOB_GAUGE_BEARERS_ACTIVE,
|
|
|
|
SMF_METR_GLOB_GAUGE_GTP1_PDPCTXS_ACTIVE,
|
|
|
|
SMF_METR_GLOB_GAUGE_GTP2_SESSIONS_ACTIVE,
|
|
|
|
SMF_METR_GLOB_GAUGE_GTP_PEERS_ACTIVE,
|
|
|
|
_SMF_METR_GLOB_MAX,
|
|
|
|
} smf_metric_type_global_t;
|
|
|
|
extern ogs_metrics_inst_t *smf_metrics_inst_global[_SMF_METR_GLOB_MAX];
|
2022-11-21 13:06:29 +00:00
|
|
|
int smf_metrics_init_inst_global(void);
|
|
|
|
int smf_metrics_free_inst_global(void);
|
Initial metrics support based on Prometheus (#1571)
* Initial metrics support based on Prometheus
This commit introduces initial support for metrics in open5gs.
The metrics code is added as libogsmetrics (lib/metrics/), with a well
defined opaque API to manage different types of metrics, allowing for
different implementations for different technologies to scrap the
metrics (placed as lib/metrics/<impl>/. The implementation is right now
selected at build time, in order to be able to opt-out the related dependencies
for users not interested in the features. 2 implementations are already
provided in this commit to start with:
* void: Default implementation. Empty stubs, acts as a NOOP.
* prometheus: open5gs processes become Prometheus servers, offering
states through an http server to the Prometheus scrappers. Relies on
libprom (prometheus-client-ci [1] project) to track the metrics and format
them during export, and libmicrohttpd to make the export possible through
HTTP.
[1] https://github.com/digitalocean/prometheus-client-c
The prometheus-client-c is not well maintained nowadays in upstream, and
furthermore it uses a quite peculiar mixture of build systems (autolib
on the main dir, cmake for libprom in a subdir). This makes it difficult
to have it widely available in distros, and difficult to find it if it
is installed in the system. Hence, the best is to include it as a
meson subproject like we already do for freeDiameter. An open5gs fork is
requried in order to have an extra patch adding a top-level
CMakeList.txt in order to be able to includ eit from open5gs's meson
build. Furthermore, this allows adding bugfixes to the subproject if any
are found in the future.
* [SMF] Initial metrics support
* [SMF] Add metrics at gtp_node level
* docs: Add tutorial documenting metrics with Prometheus
2022-06-07 20:51:02 +00:00
|
|
|
|
|
|
|
static inline void smf_metrics_inst_global_set(smf_metric_type_global_t t, int val)
|
|
|
|
{ ogs_metrics_inst_set(smf_metrics_inst_global[t], val); }
|
|
|
|
static inline void smf_metrics_inst_global_add(smf_metric_type_global_t t, int val)
|
|
|
|
{ ogs_metrics_inst_add(smf_metrics_inst_global[t], val); }
|
|
|
|
static inline void smf_metrics_inst_global_inc(smf_metric_type_global_t t)
|
|
|
|
{ ogs_metrics_inst_inc(smf_metrics_inst_global[t]); }
|
|
|
|
static inline void smf_metrics_inst_global_dec(smf_metric_type_global_t t)
|
|
|
|
{ ogs_metrics_inst_dec(smf_metrics_inst_global[t]); }
|
|
|
|
|
|
|
|
/* GTP NODE */
|
|
|
|
typedef enum smf_metric_type_gtp_node_s {
|
|
|
|
SMF_METR_GTP_NODE_CTR_GN_RX_PARSE_FAILED = 0,
|
|
|
|
SMF_METR_GTP_NODE_CTR_GN_RX_CREATEPDPCTXREQ,
|
|
|
|
SMF_METR_GTP_NODE_CTR_GN_RX_DELETEPDPCTXREQ,
|
|
|
|
SMF_METR_GTP_NODE_CTR_S5C_RX_PARSE_FAILED,
|
|
|
|
SMF_METR_GTP_NODE_CTR_S5C_RX_CREATESESSIONREQ,
|
|
|
|
SMF_METR_GTP_NODE_CTR_S5C_RX_DELETESESSIONREQ,
|
|
|
|
_SMF_METR_GTP_NODE_MAX,
|
|
|
|
} smf_metric_type_gtp_node_t;
|
|
|
|
int smf_metrics_init_inst_gtp_node(ogs_metrics_inst_t **inst, const char *addr);
|
|
|
|
int smf_metrics_free_inst_gtp_node(ogs_metrics_inst_t **inst);
|
|
|
|
|
|
|
|
static inline void smf_metrics_inst_gtp_node_set(
|
|
|
|
ogs_metrics_inst_t **inst, smf_metric_type_gtp_node_t t, int val)
|
|
|
|
{ ogs_metrics_inst_set(inst[t], val); }
|
|
|
|
static inline void smf_metrics_inst_gtp_node_add(
|
|
|
|
ogs_metrics_inst_t **inst, smf_metric_type_gtp_node_t t, int val)
|
|
|
|
{ ogs_metrics_inst_add(inst[t], val); }
|
|
|
|
static inline void smf_metrics_inst_gtp_node_inc(
|
|
|
|
ogs_metrics_inst_t **inst, smf_metric_type_gtp_node_t t)
|
|
|
|
{ ogs_metrics_inst_inc(inst[t]); }
|
|
|
|
static inline void smf_metrics_inst_gtp_node_dec(
|
|
|
|
ogs_metrics_inst_t **inst, smf_metric_type_gtp_node_t t)
|
|
|
|
{ ogs_metrics_inst_dec(inst[t]); }
|
|
|
|
|
2022-12-07 07:44:57 +00:00
|
|
|
/* BY SLICE */
|
|
|
|
typedef enum smf_metric_type_by_slice_s {
|
|
|
|
SMF_METR_GAUGE_SM_SESSIONNBR = 0,
|
2023-05-09 10:58:25 +00:00
|
|
|
SMF_METR_CTR_SM_PDUSESSIONCREATIONREQ,
|
|
|
|
SMF_METR_CTR_SM_PDUSESSIONCREATIONSUCC,
|
2022-12-07 07:44:57 +00:00
|
|
|
_SMF_METR_BY_SLICE_MAX,
|
|
|
|
} smf_metric_type_by_slice_t;
|
|
|
|
|
|
|
|
void smf_metrics_inst_by_slice_add(
|
|
|
|
ogs_plmn_id_t *plmn, ogs_s_nssai_t *snssai,
|
|
|
|
smf_metric_type_by_slice_t t, int val);
|
|
|
|
|
|
|
|
/* BY SLICE and 5QI */
|
|
|
|
typedef enum smf_metric_type_by_5qi_s {
|
|
|
|
SMF_METR_GAUGE_SM_QOSFLOWNBR = 0,
|
|
|
|
_SMF_METR_BY_5QI_MAX,
|
|
|
|
} smf_metric_type_by_5qi_t;
|
|
|
|
|
|
|
|
void smf_metrics_inst_by_5qi_add(
|
|
|
|
ogs_plmn_id_t *plmn, ogs_s_nssai_t *snssai,
|
|
|
|
uint8_t fiveqi, smf_metric_type_by_5qi_t t, int val);
|
|
|
|
|
|
|
|
/* BY CAUSE */
|
|
|
|
typedef enum smf_metric_type_by_cause_s {
|
|
|
|
SMF_METR_CTR_SM_N4SESSIONESTABFAIL = 0,
|
2023-05-09 10:58:25 +00:00
|
|
|
SMF_METR_CTR_SM_PDUSESSIONCREATIONFAIL,
|
2022-12-07 07:44:57 +00:00
|
|
|
_SMF_METR_BY_CAUSE_MAX,
|
|
|
|
} smf_metric_type_by_cause_t;
|
|
|
|
|
|
|
|
void smf_metrics_inst_by_cause_add(
|
2023-05-09 10:58:25 +00:00
|
|
|
int cause, smf_metric_type_by_cause_t t, int val);
|
2023-01-20 12:16:45 +00:00
|
|
|
void smf_metrics_init(void);
|
|
|
|
void smf_metrics_final(void);
|
Initial metrics support based on Prometheus (#1571)
* Initial metrics support based on Prometheus
This commit introduces initial support for metrics in open5gs.
The metrics code is added as libogsmetrics (lib/metrics/), with a well
defined opaque API to manage different types of metrics, allowing for
different implementations for different technologies to scrap the
metrics (placed as lib/metrics/<impl>/. The implementation is right now
selected at build time, in order to be able to opt-out the related dependencies
for users not interested in the features. 2 implementations are already
provided in this commit to start with:
* void: Default implementation. Empty stubs, acts as a NOOP.
* prometheus: open5gs processes become Prometheus servers, offering
states through an http server to the Prometheus scrappers. Relies on
libprom (prometheus-client-ci [1] project) to track the metrics and format
them during export, and libmicrohttpd to make the export possible through
HTTP.
[1] https://github.com/digitalocean/prometheus-client-c
The prometheus-client-c is not well maintained nowadays in upstream, and
furthermore it uses a quite peculiar mixture of build systems (autolib
on the main dir, cmake for libprom in a subdir). This makes it difficult
to have it widely available in distros, and difficult to find it if it
is installed in the system. Hence, the best is to include it as a
meson subproject like we already do for freeDiameter. An open5gs fork is
requried in order to have an extra patch adding a top-level
CMakeList.txt in order to be able to includ eit from open5gs's meson
build. Furthermore, this allows adding bugfixes to the subproject if any
are found in the future.
* [SMF] Initial metrics support
* [SMF] Add metrics at gtp_node level
* docs: Add tutorial documenting metrics with Prometheus
2022-06-07 20:51:02 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* SMF_METRICS_H */
|