@@ -6,8 +6,17 @@ use std::path::PathBuf;
66#[ derive( Parser , Debug ) ]
77#[ command( name = "asap-planner" , about = "ASAP Query Planner" ) ]
88struct Args {
9- #[ arg( long = "input_config" ) ]
10- input_config : PathBuf ,
9+ /// Path to a hand-authored YAML workload config. Mutually exclusive with --query-log.
10+ #[ arg( long = "input_config" , conflicts_with = "query_log" ) ]
11+ input_config : Option < PathBuf > ,
12+
13+ /// Path to a Prometheus query log file (newline-delimited JSON). Mutually exclusive with --input_config.
14+ #[ arg( long = "query-log" , conflicts_with = "input_config" ) ]
15+ query_log : Option < PathBuf > ,
16+
17+ /// Path to a metrics config YAML (required when using --query-log).
18+ #[ arg( long = "metrics-config" , requires = "query_log" ) ]
19+ metrics_config : Option < PathBuf > ,
1120
1221 #[ arg( long = "output_dir" ) ]
1322 output_dir : PathBuf ,
@@ -71,20 +80,33 @@ fn main() -> anyhow::Result<()> {
7180 range_duration : args. range_duration ,
7281 step : args. step ,
7382 } ;
74- let controller = Controller :: from_file ( & args. input_config , opts) ?;
83+ let controller = match ( args. input_config , args. query_log ) {
84+ ( Some ( config_path) , None ) => Controller :: from_file ( & config_path, opts) ?,
85+ ( None , Some ( log_path) ) => {
86+ let metrics_path = args
87+ . metrics_config
88+ . expect ( "--metrics-config is required when using --query-log" ) ;
89+ Controller :: from_query_log ( & log_path, & metrics_path, opts) ?
90+ }
91+ _ => anyhow:: bail!(
92+ "exactly one of --input_config or --query-log must be provided for PromQL mode"
93+ ) ,
94+ } ;
7595 controller. generate_to_dir ( & args. output_dir ) ?;
7696 }
7797 QueryLanguage :: sql | QueryLanguage :: elastic_sql => {
7898 let interval = args. data_ingestion_interval . ok_or_else ( || {
7999 anyhow:: anyhow!( "--data-ingestion-interval is required for SQL mode" )
80100 } ) ?;
101+ let config_path = args
102+ . input_config
103+ . ok_or_else ( || anyhow:: anyhow!( "--input_config is required for SQL mode" ) ) ?;
81104 let opts = SQLRuntimeOptions {
82105 streaming_engine : engine,
83106 query_evaluation_time : None ,
84107 data_ingestion_interval : interval,
85108 } ;
86- SQLController :: from_file ( & args. input_config , opts) ?
87- . generate_to_dir ( & args. output_dir ) ?;
109+ SQLController :: from_file ( & config_path, opts) ?. generate_to_dir ( & args. output_dir ) ?;
88110 }
89111 QueryLanguage :: elastic_querydsl => {
90112 anyhow:: bail!( "ElasticQueryDSL is not yet supported" ) ;
0 commit comments