@@ -19,6 +19,7 @@ use crate::http::ingest::HttpIngestExtensions;
1919use crate :: http:: public:: HttpPublicExtensions ;
2020use crate :: http:: ui:: HttpUiExtensions ;
2121use crate :: plugin:: SubscriptionPlugin ;
22+ use axum_prometheus:: { Handle , MakeDefaultHandle } ;
2223use clap:: { Parser , Subcommand } ;
2324use migration:: { Migrator , MigratorTrait } ;
2425use notifico_attachment:: AttachmentPlugin ;
@@ -70,6 +71,9 @@ struct Args {
7071 #[ clap( long, env = "NOTIFICO_PUBLIC_BIND" , default_value = "[::]:8002" ) ]
7172 public : SocketAddr ,
7273
74+ #[ clap( long, env = "NOTIFICO_METRICS_BIND" ) ]
75+ metrics : Option < SocketAddr > ,
76+
7377 #[ command( subcommand) ]
7478 command : Commands ,
7579}
@@ -94,6 +98,8 @@ async fn main() {
9498 . with ( EnvFilter :: from_default_env ( ) )
9599 . init ( ) ;
96100
101+ let prometheus_handle = Handle :: make_default_handle ( Handle :: default ( ) ) ; // Registers Prometheus as default metrics recorder
102+
97103 debug ! ( "Config: {:#?}" , args) ;
98104
99105 match args. command {
@@ -200,6 +206,10 @@ async fn main() {
200206 let transport_registry = Arc :: new ( transport_registry) ;
201207
202208 // Spawn HTTP servers
209+ if let Some ( metrics_bind) = args. metrics {
210+ info ! ( "Starting HTTP metrics server on {}" , metrics_bind) ;
211+ http:: metrics:: start ( metrics_bind, prometheus_handle) . await ;
212+ }
203213 if components. is_empty ( ) || components. contains ( COMPONENT_INGEST ) {
204214 info ! ( "Starting HTTP ingest server on {}" , args. ingest) ;
205215 let ext = HttpIngestExtensions {
0 commit comments