mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-05 20:20:07 +00:00
When monitoring Asterisk instances, it's often useful to know when an outbound registration fails, as this often maps to the notion of a trunk and having a trunk fail is usually a "bad thing". As such, this patch adds monitoring metrics that track the state of PJSIP outbound registrations. It does this by looking for the Registry events coming across the Stasis system topic, and publishing those as metrics to Prometheus. Note that while this may support other outbound registration types (IAX2, SIP, etc.) those haven't been tested. Your mileage may vary. (And why are you still using IAX2 and SIP? It's 2019 folks. Get with the program.) This patch also adds Sorcery observers to handle modifications to the underlying PJSIP outbound registration objects. This is useful when a reload is triggered that modifies the properties of an outbound registration, or when ARI push configuration is used and an object is updated or deleted. Because we rely on properties of the registration object to define the metric (label key/value pairs), we delete the relevant metric when we notice that something has changed and wait for a new Stasis message to arrive to re-create the metric. ASTERISK-28403 Change-Id: If01420e38530fc20b6dd4aa15cd281d94cd2b87e
103 lines
2.3 KiB
C
103 lines
2.3 KiB
C
/*
|
|
* Prometheus Internal API
|
|
*
|
|
* Copyright (C) 2019 Sangoma, Inc.
|
|
*
|
|
* Matt Jordan <mjordan@digium.com>
|
|
*
|
|
* See http://www.asterisk.org for more information about
|
|
* the Asterisk project. Please do not directly contact
|
|
* any of the maintainers of this project for assistance;
|
|
* the project provides a web site, mailing lists and IRC
|
|
* channels for your use.
|
|
*
|
|
* This program is free software, distributed under the terms of
|
|
* the GNU General Public License Version 2. See the LICENSE file
|
|
* at the top of the source tree.
|
|
*/
|
|
|
|
#ifndef PROMETHEUS_INTERNAL_H__
|
|
#define PROMETHEUS_INTERNAL_H__
|
|
|
|
/*!
|
|
* \file prometheus_internal
|
|
*
|
|
* \brief Prometheus Metric Internal API
|
|
*
|
|
* This module provides internal APIs for \file res_prometheus.
|
|
* It should not be used outsize of that module, and should
|
|
* typically only provide intialization functions for units that
|
|
* want to register metrics / handlers with the core API.
|
|
*/
|
|
|
|
/*!
|
|
* \brief Retrieve the amount of time it took to perform the last scrape
|
|
*
|
|
* \details Time returned is in milliseconds
|
|
*
|
|
* \retval The scrape duration, in milliseconds
|
|
*/
|
|
int64_t prometheus_last_scrape_duration_get(void);
|
|
|
|
/*!
|
|
* \brief Retrieve the timestamp when the last scrape occurred
|
|
*
|
|
* \retval The time when the last scrape occurred
|
|
*/
|
|
struct timeval prometheus_last_scrape_time_get(void);
|
|
|
|
/*!
|
|
* \brief Get the raw output of what a scrape would produce
|
|
*
|
|
* \details
|
|
* It can be useful to dump what a scrape will look like.
|
|
* This function returns the raw string representation
|
|
* of the metrics.
|
|
*
|
|
* \retval NULL on error
|
|
* \retval Malloc'd ast_str on success
|
|
*/
|
|
struct ast_str *prometheus_scrape_to_string(void);
|
|
|
|
/*!
|
|
* \brief Initialize CLI command
|
|
*
|
|
* \retval 0 success
|
|
* \retval -1 error
|
|
*/
|
|
int cli_init(void);
|
|
|
|
/*!
|
|
* \brief Initialize channel metrics
|
|
*
|
|
* \retval 0 success
|
|
* \retval -1 error
|
|
*/
|
|
int channel_metrics_init(void);
|
|
|
|
/*!
|
|
* \brief Initialize endpoint metrics
|
|
*
|
|
* \retval 0 success
|
|
* \retval -1 error
|
|
*/
|
|
int endpoint_metrics_init(void);
|
|
|
|
/*!
|
|
* \brief Initialize bridge metrics
|
|
*
|
|
* \retval 0 success
|
|
* \retval -1 error
|
|
*/
|
|
int bridge_metrics_init(void);
|
|
|
|
/*!
|
|
* \brief Initialize PJSIP outbound registration metrics
|
|
*
|
|
* \retval 0 success
|
|
* \retval -1 error
|
|
*/
|
|
int pjsip_outbound_registration_metrics_init(void);
|
|
|
|
#endif /* #define PROMETHEUS_INTERNAL_H__ */
|