servers/
prometheus_handler.rs1use std::sync::Arc;
18use std::time::SystemTime;
19
20use async_trait::async_trait;
21use catalog::CatalogManagerRef;
22use common_query::Output;
23use promql_parser::label::Matcher;
24use query::parser::PromQuery;
25use session::context::QueryContextRef;
26
27use crate::error::Result;
28
29pub const PROMETHEUS_API_VERSION: &str = "v1";
30
31pub type PrometheusHandlerRef = Arc<dyn PrometheusHandler + Send + Sync>;
32
33#[async_trait]
34pub trait PrometheusHandler {
35 async fn do_query(&self, query: &PromQuery, query_ctx: QueryContextRef) -> Result<Output>;
36
37 async fn query_metric_names(
39 &self,
40 matchers: Vec<Matcher>,
41 ctx: &QueryContextRef,
42 ) -> Result<Vec<String>>;
43
44 async fn query_label_values(
45 &self,
46 metric: String,
47 label_name: String,
48 matchers: Vec<Matcher>,
49 start: SystemTime,
50 end: SystemTime,
51 ctx: &QueryContextRef,
52 ) -> Result<Vec<String>>;
53
54 fn catalog_manager(&self) -> CatalogManagerRef;
55}