Skip to content

Commit

Permalink
For ossrs#2899: API: Support exporter for Prometheus. v5.0.67
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Sep 27, 2022
1 parent 088f7c1 commit a2266dd
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 21 deletions.
4 changes: 2 additions & 2 deletions trunk/conf/full.conf
Expand Up @@ -657,12 +657,12 @@ tencentcloud_apm {
debug_logging off;
}

# Promethous exporter config.
# Prometheus exporter config.
# See https://prometheus.io/docs/instrumenting/exporters
exporter {
# Whether exporter is enabled.
# Overwrite by env SRS_EXPORTER_ENABLED
# default: off
# Default: off
enabled off;
# The logging label to category the cluster servers.
# Overwrite by env SRS_EXPORTER_LABEL
Expand Down
1 change: 1 addition & 0 deletions trunk/doc/CHANGELOG.md
Expand Up @@ -7,6 +7,7 @@ The changelog for SRS.

## SRS 5.0 Changelog

* v5.0, 2022-09-27, For [#2899](https://github.com/ossrs/srs/issues/2899): API: Support exporter for Prometheus. v5.0.67
* v5.0, 2022-09-27, For [#3167](https://github.com/ossrs/srs/issues/3167): WebRTC: Refine sequence jitter algorithm. v5.0.66
* v5.0, 2022-09-22, Fix [#3164](https://github.com/ossrs/srs/issues/3164): SRT: Choppy when audio ts gap is too large. v5.0.65
* v5.0, 2022-09-16, APM: Support distributed tracing by Tencent Cloud APM. v5.0.64
Expand Down
34 changes: 17 additions & 17 deletions trunk/src/app/srs_app_http_api.cpp
Expand Up @@ -1078,7 +1078,7 @@ srs_error_t SrsGoApiMetrics::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessa
{
// whether enabled the HTTP Metrics API.
if (!enabled_) {
return srs_api_response_code(w, r, ERROR_SYSTEM_CONFIG_EXPORTER_DISABLED);
return srs_api_response_code(w, r, ERROR_EXPORTER_DISABLED);
}

/*
Expand All @@ -1096,58 +1096,58 @@ srs_error_t SrsGoApiMetrics::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessa
std::stringstream ss;

// Build info from Config.
ss << "# HELP srs_build_info A metric with a constant '1' value labeled by build_date, version from which srs was built.\n"
<< "# TYPE srs_build_info gauge\n"
<< "srs_build_info{"
<< "build_date=\"" << SRS_BUILD_DATE << "\","
<< "major=\"" << VERSION_MAJOR << "\","
<< "version=\"" << RTMP_SIG_SRS_VERSION << "\","
<< "code=\"" << RTMP_SIG_SRS_CODE<< "\","
<< "label=\"" << label_<< "\","
<< "tag=\"" << tag_
<< "\"} 1\n";
ss << "# HELP srs_build_info A metric with a constant '1' value labeled by build_date, version from which SRS was built.\n"
<< "# TYPE srs_build_info gauge\n"
<< "srs_build_info{"
<< "build_date=\"" << SRS_BUILD_DATE << "\","
<< "major=\"" << VERSION_MAJOR << "\","
<< "version=\"" << RTMP_SIG_SRS_VERSION << "\","
<< "code=\"" << RTMP_SIG_SRS_CODE<< "\"";
if (!label_.empty()) ss << ",label=\"" << label_ << "\"";
if (!tag_.empty()) ss << ",tag=\"" << tag_ << "\"";
ss << "} 1\n";

// Dump metrics by statistic.
int64_t send_bytes, recv_bytes, nstreams, nclients, total_nclients, nerrs;
stat->dumps_metrics(send_bytes, recv_bytes, nstreams, nclients, total_nclients, nerrs);

// The total of bytes sent.
ss << "# HELP srs_send_bytes_total SRS server send bytes.\n"
ss << "# HELP srs_send_bytes_total SRS total sent bytes.\n"
<< "# TYPE srs_send_bytes_total counter\n"
<< "srs_send_bytes_total "
<< send_bytes
<< "\n";

// The total of bytes received.
ss << "# HELP srs_receive_bytes_total SRS server receive bytes.\n"
ss << "# HELP srs_receive_bytes_total SRS total received bytes.\n"
<< "# TYPE srs_receive_bytes_total counter\n"
<< "srs_receive_bytes_total "
<< recv_bytes
<< "\n";

// Current number of online streams.
ss << "# HELP srs_streams SRS server concurrent stream counts.\n"
ss << "# HELP srs_streams The number of SRS concurrent streams.\n"
<< "# TYPE srs_streams gauge\n"
<< "srs_streams "
<< nstreams
<< "\n";

// Current number of online clients.
ss << "# HELP srs_clients SRS server concurrent client counts.\n"
ss << "# HELP srs_clients The number of SRS concurrent clients.\n"
<< "# TYPE srs_clients gauge\n"
<< "srs_clients "
<< nclients
<< "\n";

// The total of clients connections.
ss << "# HELP srs_clients_total SRS server client total counts.\n"
ss << "# HELP srs_clients_total The total counts of SRS clients.\n"
<< "# TYPE srs_clients_total counter\n"
<< "srs_clients_total "
<< total_nclients
<< "\n";

// The total of clients errors.
ss << "# HELP srs_clients_errs_total SRS server clients total errors.\n"
ss << "# HELP srs_clients_errs_total The total errors of SRS clients.\n"
<< "# TYPE srs_clients_errs_total counter\n"
<< "srs_clients_errs_total "
<< nerrs
Expand Down
2 changes: 1 addition & 1 deletion trunk/src/core/srs_core_version5.hpp
Expand Up @@ -9,6 +9,6 @@

#define VERSION_MAJOR 5
#define VERSION_MINOR 0
#define VERSION_REVISION 66
#define VERSION_REVISION 67

#endif
2 changes: 1 addition & 1 deletion trunk/src/kernel/srs_kernel_error.hpp
Expand Up @@ -100,7 +100,7 @@
XX(ERROR_APM_EXCEED_SIZE , 1087, "ApmExceedSize", "APM logs exceed max size 5MB") \
XX(ERROR_APM_ENDPOINT , 1088, "ApmEndpoint", "APM endpoint is invalid") \
XX(ERROR_APM_AUTH , 1089, "ApmAuth", "APM team or token is invalid") \
XX(ERROR_SYSTEM_CONFIG_EXPORTER_DISABLED, 1090, "ConfigMetricsDisable", "Metrics API is disabled") \
XX(ERROR_EXPORTER_DISABLED , 1090, "ExporterDisable", "Prometheus exporter is disabled") \

/**************************************************/
/* RTMP protocol error. */
Expand Down

0 comments on commit a2266dd

Please sign in to comment.