res_prometheus: Add Asterisk channel metrics

This patch adds basic Asterisk channel statistics to the res_prometheus
module. This includes:

* asterisk_calls_sum: A running sum of the total number of
  processed calls

* asterisk_calls_count: The current number of calls

* asterisk_channels_count: The current number of channels

* asterisk_channels_state: The state of any particular channel

* asterisk_channels_duration_seconds: How long a channel has existed,
  in seconds

In all cases, enough information is provided with each channel metric
to determine a unique instance of Asterisk that provided the data, as
well as the name, type, unique ID, and - if present - linked ID of each
channel.

ASTERISK-28403

Change-Id: I0db306ec94205d4f58d1e7fbabfe04b185869f59
This commit is contained in:
Matt Jordan
2019-05-02 19:45:27 -05:00
parent 54f7f7dc20
commit 0760af71ad
7 changed files with 371 additions and 11 deletions

View File

@@ -173,13 +173,13 @@ AST_TEST_DEFINE(metric_values)
}
ast_test_status_update(test, " -> Retrieved: %s\n", ast_str_buffer(buffer));
ast_test_validate_cleanup(test, strcmp(ast_str_buffer(buffer),
ast_test_validate_cleanup(test, strstr(ast_str_buffer(buffer),
"# HELP test_counter_one A test counter\n"
"# TYPE test_counter_one counter\n"
"test_counter_one 1\n"
"# HELP test_counter_two A test counter\n"
"# TYPE test_counter_two counter\n"
"test_counter_two 2\n") == 0, result, metric_values_cleanup);
"test_counter_two 2\n") != NULL, result, metric_values_cleanup);
metric_values_cleanup:
prometheus_metric_unregister(&test_counter_one);
@@ -247,10 +247,10 @@ AST_TEST_DEFINE(metric_callback_register)
}
ast_test_status_update(test, " -> Retrieved: %s\n", ast_str_buffer(buffer));
ast_test_validate(test, strcmp(ast_str_buffer(buffer),
ast_test_validate(test, strstr(ast_str_buffer(buffer),
"# HELP test_counter A test counter\n"
"# TYPE test_counter counter\n"
"test_counter 0\n") == 0);
"test_counter 0\n") != NULL);
prometheus_callback_unregister(&callback);