1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

API: support metrics for prometheus.(#2899) (#3189)

* API: support metrics for prometheus.

* Metrics: optimize metrics statistics info.

* Refine: remove redundant code.

* Refine: fix metrics srs_streams param.

* Metrics: add major param.

* Metrics: refine params and metric comments.

* For #2899: API: Support exporter for Prometheus. v5.0.67

Co-authored-by: winlin <winlin@vip.126.com>
This commit is contained in:
chundonglinlin 2022-09-27 15:39:26 +08:00 committed by GitHub
parent e31f3b0e64
commit 981cab40d3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 236 additions and 10 deletions

View file

@ -2227,6 +2227,7 @@ srs_error_t SrsConfig::check_normal_config()
&& n != "inotify_auto_reload" && n != "auto_reload_for_docker" && n != "tcmalloc_release_rate"
&& n != "query_latest_version" && n != "first_wait_for_qlv" && n != "threads"
&& n != "circuit_breaker" && n != "is_full" && n != "in_docker" && n != "tencentcloud_cls"
&& n != "exporter"
) {
return srs_error_new(ERROR_SYSTEM_CONFIG_INVALID, "illegal directive %s", n.c_str());
}
@ -3563,6 +3564,63 @@ bool SrsConfig::get_tencentcloud_apm_debug_logging()
return SRS_CONF_PERFER_FALSE(conf->arg0());
}
bool SrsConfig::get_exporter_enabled()
{
SRS_OVERWRITE_BY_ENV_BOOL("SRS_EXPORTER_ENABLED");
static bool DEFAULT = false;
SrsConfDirective* conf = root->get("exporter");
if (!conf) {
return DEFAULT;
}
conf = conf->get("enabled");
if (!conf) {
return DEFAULT;
}
return SRS_CONF_PERFER_FALSE(conf->arg0());
}
string SrsConfig::get_exporter_label()
{
SRS_OVERWRITE_BY_ENV_STRING("SRS_EXPORTER_LABEL");
static string DEFAULT = "";
SrsConfDirective* conf = root->get("exporter");
if (!conf) {
return DEFAULT;
}
conf = conf->get("label");
if (!conf) {
return DEFAULT;
}
return conf->arg0();
}
string SrsConfig::get_exporter_tag()
{
SRS_OVERWRITE_BY_ENV_STRING("SRS_EXPORTER_TAG");
static string DEFAULT = "";
SrsConfDirective* conf = root->get("exporter");
if (!conf) {
return DEFAULT;
}
conf = conf->get("tag");
if (!conf) {
return DEFAULT;
}
return conf->arg0();
}
vector<SrsConfDirective*> SrsConfig::get_stream_casters()
{
srs_assert(root);