File tree Expand file tree Collapse file tree 4 files changed +24
-2
lines changed Expand file tree Collapse file tree 4 files changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -307,6 +307,12 @@ Options:
307
307
[env: OTLP_SERVICE_NAME=]
308
308
[default: text-embeddings-inference.server]
309
309
310
+ --prometheus-port <PORT>
311
+ The Prometheus metrics port to listen on
312
+
313
+ [env: PROMETHEUS_PORT=]
314
+ [default: 9000]
315
+
310
316
--cors-allow-origin <CORS_ALLOW_ORIGIN>
311
317
Unused for gRPC servers
312
318
Original file line number Diff line number Diff line change @@ -63,6 +63,7 @@ pub async fn run(
63
63
api_key : Option < String > ,
64
64
otlp_endpoint : Option < String > ,
65
65
otlp_service_name : String ,
66
+ prometheus_port : u16 ,
66
67
cors_allow_origin : Option < Vec < String > > ,
67
68
) -> Result < ( ) > {
68
69
let model_id_path = Path :: new ( & model_id) ;
@@ -314,7 +315,7 @@ pub async fn run(
314
315
}
315
316
} ;
316
317
317
- let prom_builder = prometheus:: prometheus_builer ( info. max_input_length ) ?;
318
+ let prom_builder = prometheus:: prometheus_builer ( addr , prometheus_port , info. max_input_length ) ?;
318
319
319
320
#[ cfg( all( feature = "grpc" , feature = "http" ) ) ]
320
321
compile_error ! ( "Features `http` and `grpc` cannot be enabled at the same time." ) ;
Original file line number Diff line number Diff line change @@ -164,6 +164,10 @@ struct Args {
164
164
#[ clap( default_value = "text-embeddings-inference.server" , long, env) ]
165
165
otlp_service_name : String ,
166
166
167
+ /// The Prometheus port to listen on.
168
+ #[ clap( default_value = "9000" , long, short, env) ]
169
+ prometheus_port : u16 ,
170
+
167
171
/// Unused for gRPC servers
168
172
#[ clap( long, env) ]
169
173
cors_allow_origin : Option < Vec < String > > ,
@@ -227,6 +231,7 @@ async fn main() -> Result<()> {
227
231
args. api_key ,
228
232
args. otlp_endpoint ,
229
233
args. otlp_service_name ,
234
+ args. prometheus_port ,
230
235
args. cors_allow_origin ,
231
236
)
232
237
. await ?;
Original file line number Diff line number Diff line change
1
+ use std:: net:: SocketAddr ;
2
+
1
3
use metrics_exporter_prometheus:: { BuildError , Matcher , PrometheusBuilder } ;
2
4
3
- pub ( crate ) fn prometheus_builer ( max_input_length : usize ) -> Result < PrometheusBuilder , BuildError > {
5
+ pub ( crate ) fn prometheus_builer (
6
+ addr : SocketAddr ,
7
+ port : u16 ,
8
+ max_input_length : usize ,
9
+ ) -> Result < PrometheusBuilder , BuildError > {
10
+ let mut addr = addr;
11
+ addr. set_port ( port) ;
12
+
4
13
// Duration buckets
5
14
let duration_matcher = Matcher :: Suffix ( String :: from ( "duration" ) ) ;
6
15
let n_duration_buckets = 35 ;
@@ -30,6 +39,7 @@ pub(crate) fn prometheus_builer(max_input_length: usize) -> Result<PrometheusBui
30
39
31
40
// Prometheus handler
32
41
PrometheusBuilder :: new ( )
42
+ . with_http_listener ( addr)
33
43
. set_buckets_for_metric ( duration_matcher, & duration_buckets) ?
34
44
. set_buckets_for_metric ( input_length_matcher, & input_length_buckets) ?
35
45
. set_buckets_for_metric ( batch_size_matcher, & batch_size_buckets) ?
You can’t perform that action at this time.
0 commit comments