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

Exporter: Listen at port 9972 for Prometheus exporter. (#3195)

This commit is contained in:
chundonglinlin 2022-10-01 07:35:54 +08:00 committed by GitHub
parent 4ad4dd0975
commit 9525511032
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 105 additions and 4 deletions

View file

@ -2305,7 +2305,16 @@ srs_error_t SrsConfig::check_normal_config()
}
}
}
if (true) {
SrsConfDirective* conf = root->get("exporter");
for (int i = 0; conf && i < (int)conf->directives.size(); i++) {
string n = conf->at(i)->name;
if (n != "enabled" && n != "listen" && n != "label" && n != "tag") {
return srs_error_new(ERROR_SYSTEM_CONFIG_INVALID, "illegal exporter.%s", n.c_str());
}
}
}
////////////////////////////////////////////////////////////////////////
// check listen for rtmp.
////////////////////////////////////////////////////////////////////////
@ -3583,6 +3592,25 @@ bool SrsConfig::get_exporter_enabled()
return SRS_CONF_PERFER_FALSE(conf->arg0());
}
string SrsConfig::get_exporter_listen()
{
SRS_OVERWRITE_BY_ENV_STRING("SRS_EXPORTER_LISTEN");
static string DEFAULT = "9972";
SrsConfDirective* conf = root->get("exporter");
if (!conf) {
return DEFAULT;
}
conf = conf->get("listen");
if (!conf) {
return DEFAULT;
}
return conf->arg0();
}
string SrsConfig::get_exporter_label()
{
SRS_OVERWRITE_BY_ENV_STRING("SRS_EXPORTER_LABEL");