Explorar el Código

Merge pull request #840 from lionelnicolas/feature/prometheus-port

Add ability to configure prometheus listener port
Gustavo Garcia hace 3 años
padre
commit
ecdc8893ee

+ 5 - 2
README.turnserver

@@ -281,10 +281,13 @@ Flags:
 			check: across the session, all requests must have the same
 			check: across the session, all requests must have the same
 			main ORIGIN attribute value (if the ORIGIN was
 			main ORIGIN attribute value (if the ORIGIN was
 			initially used by the session).
 			initially used by the session).
- --prometheus		Enable prometheus metrics. By default it is
-			disabled. Would listen on port 9641 unther the path /metrics
+
+--prometheus		Enable prometheus metrics. By default it is
+			disabled. Would listen on port 9641 under the path /metrics
 			also the path / on this port can be used as a health check
 			also the path / on this port can be used as a health check
 
 
+--prometheus-port	Prometheus listener port (Default: 9641).
+
 -h			Help.
 -h			Help.
 
 
 Options with values:
 Options with values:

+ 5 - 2
man/man1/turnserver.1

@@ -422,13 +422,16 @@ The flag that sets the origin consistency
 check: across the session, all requests must have the same
 check: across the session, all requests must have the same
 main ORIGIN attribute value (if the ORIGIN was
 main ORIGIN attribute value (if the ORIGIN was
 initially used by the session).
 initially used by the session).
-.RS
 .TP
 .TP
 .B
 .B
 \fB\-\-prometheus\fP
 \fB\-\-prometheus\fP
 Enable prometheus metrics. By default it is
 Enable prometheus metrics. By default it is
-disabled. Would listen on port 9641 unther the path /metrics
+disabled. Would listen on port 9641 under the path /metrics
 also the path / on this port can be used as a health check
 also the path / on this port can be used as a health check
+.TP
+.B
+\fB\-\-prometheus\-port\fP
+Prometheus listener port (Default: 9641).
 .RE
 .RE
 .TP
 .TP
 .B
 .B

+ 8 - 1
src/apps/relay/mainrelay.c

@@ -173,6 +173,7 @@ TURN_CREDENTIALS_NONE, /* ct */
 0, /* user_quota */
 0, /* user_quota */
 #if !defined(TURN_NO_PROMETHEUS)
 #if !defined(TURN_NO_PROMETHEUS)
 0, /* prometheus disabled by default */
 0, /* prometheus disabled by default */
+DEFAULT_PROM_SERVER_PORT, /* prometheus port */
 #endif
 #endif
 ///////////// Users DB //////////////
 ///////////// Users DB //////////////
 { (TURN_USERDB_TYPE)0, {"\0"}, {0,NULL, {NULL,0}} },
 { (TURN_USERDB_TYPE)0, {"\0"}, {0,NULL, {NULL,0}} },
@@ -557,8 +558,9 @@ static char Usage[] = "Usage: turnserver [options]\n"
 "						The connection string has the same parameters as redis-userdb connection string.\n"
 "						The connection string has the same parameters as redis-userdb connection string.\n"
 #endif
 #endif
 #if !defined(TURN_NO_PROMETHEUS)
 #if !defined(TURN_NO_PROMETHEUS)
-" --prometheus					Enable prometheus metrics. It is disabled by default. If it is enabled it will listen on port 9641 unther the path /metrics\n"
+" --prometheus					Enable prometheus metrics. It is disabled by default. If it is enabled it will listen on port 9641 under the path /metrics\n"
 "						also the path / on this port can be used as a health check\n"
 "						also the path / on this port can be used as a health check\n"
+" --prometheus-port		<port>		Prometheus metrics port (Default: 9641).\n"
 #endif
 #endif
 " --use-auth-secret				TURN REST API flag.\n"
 " --use-auth-secret				TURN REST API flag.\n"
 "						Flag that sets a special authorization option that is based upon authentication secret\n"
 "						Flag that sets a special authorization option that is based upon authentication secret\n"
@@ -787,6 +789,7 @@ enum EXTRA_OPTS {
 	CHANNEL_LIFETIME_OPT,
 	CHANNEL_LIFETIME_OPT,
 	PERMISSION_LIFETIME_OPT,
 	PERMISSION_LIFETIME_OPT,
 	PROMETHEUS_OPT,
 	PROMETHEUS_OPT,
+	PROMETHEUS_PORT_OPT,
 	AUTH_SECRET_OPT,
 	AUTH_SECRET_OPT,
 	NO_AUTH_PINGS_OPT,
 	NO_AUTH_PINGS_OPT,
 	NO_DYNAMIC_IP_LIST_OPT,
 	NO_DYNAMIC_IP_LIST_OPT,
@@ -902,6 +905,7 @@ static const struct myoption long_options[] = {
 #endif
 #endif
 #if !defined(TURN_NO_PROMETHEUS)
 #if !defined(TURN_NO_PROMETHEUS)
 				{ "prometheus", optional_argument, NULL, PROMETHEUS_OPT },
 				{ "prometheus", optional_argument, NULL, PROMETHEUS_OPT },
+				{ "prometheus-port", optional_argument, NULL, PROMETHEUS_PORT_OPT },
 #endif
 #endif
 				{ "use-auth-secret", optional_argument, NULL, AUTH_SECRET_OPT },
 				{ "use-auth-secret", optional_argument, NULL, AUTH_SECRET_OPT },
 				{ "static-auth-secret", required_argument, NULL, STATIC_AUTH_SECRET_VAL_OPT },
 				{ "static-auth-secret", required_argument, NULL, STATIC_AUTH_SECRET_VAL_OPT },
@@ -1534,6 +1538,9 @@ static void set_option(int c, char *value)
 	case PROMETHEUS_OPT:
 	case PROMETHEUS_OPT:
 		turn_params.prometheus = 1;
 		turn_params.prometheus = 1;
 		break;
 		break;
+	case PROMETHEUS_PORT_OPT:
+		turn_params.prometheus_port = atoi(value);
+		break;
 #endif
 #endif
 	case AUTH_SECRET_OPT:
 	case AUTH_SECRET_OPT:
 		turn_params.use_auth_secret_with_timestamp = 1;
 		turn_params.use_auth_secret_with_timestamp = 1;

+ 2 - 1
src/apps/relay/mainrelay.h

@@ -318,7 +318,8 @@ typedef struct _turn_params_ {
   vint total_quota;
   vint total_quota;
   vint user_quota;
   vint user_quota;
   #if !defined(TURN_NO_PROMETHEUS)
   #if !defined(TURN_NO_PROMETHEUS)
-  int  prometheus;
+  int prometheus;
+  int prometheus_port;
   #endif
   #endif
 
 
 
 

+ 1 - 1
src/apps/relay/prom_server.c

@@ -60,7 +60,7 @@ int start_prometheus_server(void){
   promhttp_set_active_collector_registry(NULL);
   promhttp_set_active_collector_registry(NULL);
 
 
 
 
-  struct MHD_Daemon *daemon = promhttp_start_daemon(MHD_USE_SELECT_INTERNALLY, DEFAULT_PROM_SERVER_PORT, NULL, NULL);
+  struct MHD_Daemon *daemon = promhttp_start_daemon(MHD_USE_SELECT_INTERNALLY, turn_params.prometheus_port, NULL, NULL);
   if (daemon == NULL) {
   if (daemon == NULL) {
     return -1;
     return -1;
   }
   }