Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(prom)!: rename prometheus(remote storage) to prom-store and promql(HTTP server) to prometheus #1931

Merged
merged 3 commits into from Jul 12, 2023
Merged

Conversation

etolbakov
Copy link
Collaborator

…ql(HTTP server) to prometheus

I hereby agree to the terms of the GreptimeDB CLA

What's changed and what's your intention?

Perform renaming according to the following rule:

  • prometheus(remote storage) -> prom-store
  • promql(HTTP) - > prometheus

Checklist

  • I have written the necessary rustdoc comments.
  • I have added the necessary unit tests and integration tests.

Refer to a related PR or issue link (optional)

#1127

@etolbakov etolbakov marked this pull request as ready for review July 10, 2023 22:41
@waynexia waynexia added the breaking-change This pull request contains breaking changes. label Jul 11, 2023
@github-actions github-actions bot removed the breaking-change This pull request contains breaking changes. label Jul 11, 2023
@waynexia
Copy link
Member

Breaking change about config:

  • [prometheus_options] -> [prometheus_options]
  • [prom_options] -> [prometheus_options]

cc @sunng87

config/frontend.example.toml Outdated Show resolved Hide resolved
src/servers/src/prometheus.rs Outdated Show resolved Hide resolved
@sunng87 sunng87 changed the title chore(prom): rename prometheus(remote storage) to prom-store and prom… !chore(prom): rename prometheus(remote storage) to prom-store and prom… Jul 11, 2023
@sunng87 sunng87 added this to the v0.4 milestone Jul 11, 2023
@sunng87 sunng87 added Doc update required This change requires document update on https://github.com/GreptimeTeam/docs and removed Invalid PR Title labels Jul 11, 2023
@sunng87
Copy link
Member

sunng87 commented Jul 11, 2023

cc @zyy17 @daviderli614 @shuiyisong we will need to address this in 0.4 upgrade

@sunng87 sunng87 changed the title !chore(prom): rename prometheus(remote storage) to prom-store and prom… chore!(prom): rename prometheus(remote storage) to prom-store and prom… Jul 11, 2023
@sunng87 sunng87 changed the title chore!(prom): rename prometheus(remote storage) to prom-store and prom… chore(prom)!: rename prometheus(remote storage) to prom-store and prom… Jul 11, 2023
@github-actions github-actions bot added breaking-change This pull request contains breaking changes. and removed Invalid PR Title labels Jul 11, 2023
@codecov
Copy link

codecov bot commented Jul 11, 2023

Codecov Report

Merging #1931 (e627883) into develop (c615fb2) will decrease coverage by 0.62%.
The diff coverage is 87.17%.

❗ Current head e627883 differs from pull request most recent head ffc90ae. Consider uploading reports for the commit ffc90ae to get more accurate results

@@             Coverage Diff             @@
##           develop    #1931      +/-   ##
===========================================
- Coverage    86.24%   85.63%   -0.62%     
===========================================
  Files          611      613       +2     
  Lines        98849    99319     +470     
===========================================
- Hits         85255    85054     -201     
- Misses       13594    14265     +671     

@etolbakov
Copy link
Collaborator Author

Breaking change about config:

  • [prometheus_options] -> [prometheus_options]
  • [prom_options] -> [prometheus_options]

cc @sunng87

Just would like to confirm the renaming:

existing config value new config value(according to this PR)
prometheus_options prom_store_options
prom_options prometheus_options

@waynexia waynexia requested a review from killme2008 July 11, 2023 07:30
@daviderli614
Copy link
Member

I will change greptimedb-operator this value in the next feature.

@waynexia
Copy link
Member

I've checked the actual diff and the logic is unchanged

prom.rs to prometheus.rs
Renamed src/servers/src/prom.rs to src/servers/src/prometheus.rs
src/servers/src/prometheus.rs --- 1/20 --- Text (14 errors, exceeded DFT_PARSE_ERROR_LIMIT)
57 };                                                                                                     57 };
58 use crate::http::authorize::HttpAuth;                                                                  58 use crate::http::authorize::HttpAuth;
59 use crate::http::track_metrics;                                                                        59 use crate::http::track_metrics;
60 use crate::prometheus::{FIELD_COLUMN_NAME, TIMESTAMP_COLUMN_NAME};                                     60 use crate::prom_store::{FIELD_COLUMN_NAME, TIMESTAMP_COLUMN_NAME};
61 use crate::server::Server;                                                                             61 use crate::server::Server;
62                                                                                                        62 
63 pub const PROM_API_VERSION: &str = "v1";                                                               63 pub const PROMETHEUS_API_VERSION: &str = "v1";
64                                                                                                        64 
65 pub type PromHandlerRef = Arc<dyn PromHandler + Send + Sync>;                                          65 pub type PrometheusHandlerRef = Arc<dyn PrometheusHandler + Send + Sync>;
66                                                                                                        66 
67 #[async_trait]                                                                                         67 #[async_trait]
68 pub trait PromHandler {                                                                                68 pub trait PrometheusHandler {
69     async fn do_query(&self, query: &PromQuery, query_ctx: QueryContextRef) -> Result<Output>;         69     async fn do_query(&self, query: &PromQuery, query_ctx: QueryContextRef) -> Result<Output>;
70 }                                                                                                      70 }
71                                                                                                        71 
72 /// PromServer represents PrometheusServer which handles the compliance with prometheus HTTP API       72 /// PromServer represents PrometheusServer which handles the compliance with prometheus HTTP API
73 pub struct PromServer {                                                                                73 pub struct PrometheusServer {
74     query_handler: PromHandlerRef,                                                                     74     query_handler: PrometheusHandlerRef,
75     shutdown_tx: Mutex<Option<Sender<()>>>,                                                            75     shutdown_tx: Mutex<Option<Sender<()>>>,
76     user_provider: Option<UserProviderRef>,                                                            76     user_provider: Option<UserProviderRef>,
77 }                                                                                                      77 }
78                                                                                                        78 
79 impl PromServer {                                                                                      79 impl PrometheusServer {
80     pub fn create_server(query_handler: PromHandlerRef) -> Box<Self> {                                 80     pub fn create_server(query_handler: PrometheusHandlerRef) -> Box<Self> {
81         Box::new(PromServer {                                                                          81         Box::new(PrometheusServer {
82             query_handler,                                                                             82             query_handler,
83             shutdown_tx: Mutex::new(None),                                                             83             shutdown_tx: Mutex::new(None),
84             user_provider: None,                                                                       84             user_provider: None,

Renamed src/servers/src/prom.rs to src/servers/src/prometheus.rs
src/servers/src/prometheus.rs --- 2/20 --- Text (14 errors, exceeded DFT_PARSE_ERROR_LIMIT)
105             .with_state(self.query_handler.clone());                                                  105             .with_state(self.query_handler.clone());
106                                                                                                       106 
107         Router::new()                                                                                 107         Router::new()
108             .nest(&format!("/api/{PROM_API_VERSION}"), router)                                        108             .nest(&format!("/api/{PROMETHEUS_API_VERSION}"), router)
109             // middlewares                                                                            109             // middlewares
110             .layer(                                                                                   110             .layer(
111                 ServiceBuilder::new()                                                                 111                 ServiceBuilder::new()

Renamed src/servers/src/prom.rs to src/servers/src/prometheus.rs
src/servers/src/prometheus.rs --- 3/20 --- Text (14 errors, exceeded DFT_PARSE_ERROR_LIMIT)
122     }                                                                                                 122     }
123 }                                                                                                     123 }
124                                                                                                       124 
125 pub const PROM_SERVER: &str = "PROM_SERVER";                                                          125 pub const PROMETHEUS_SERVER: &str = "PROMETHEUS_SERVER";
126                                                                                                       126 
127 #[async_trait]                                                                                        127 #[async_trait]
128 impl Server for PromServer {                                                                          128 impl Server for PrometheusServer {
129     async fn shutdown(&self) -> Result<()> {                                                          129     async fn shutdown(&self) -> Result<()> {
130         let mut shutdown_tx = self.shutdown_tx.lock().await;                                          130         let mut shutdown_tx = self.shutdown_tx.lock().await;
131         if let Some(tx) = shutdown_tx.take() {                                                        131         if let Some(tx) = shutdown_tx.take() {

Renamed src/servers/src/prom.rs to src/servers/src/prometheus.rs
src/servers/src/prometheus.rs --- 4/20 --- Text (14 errors, exceeded DFT_PARSE_ERROR_LIMIT)
166     }                                                                                                 166     }
167                                                                                                       167 
168     fn name(&self) -> &str {                                                                          168     fn name(&self) -> &str {
169         PROM_SERVER                                                                                   169         PROMETHEUS_SERVER
170     }                                                                                                 170     }
171 }                                                                                                     171 }
172                                                                                                       172 

Renamed src/servers/src/prom.rs to src/servers/src/prometheus.rs
src/servers/src/prometheus.rs --- 5/20 --- Text (14 errors, exceeded DFT_PARSE_ERROR_LIMIT)
189                                                                                                       189 
190 #[derive(Debug, Serialize, Deserialize, JsonSchema, PartialEq)]                                       190 #[derive(Debug, Serialize, Deserialize, JsonSchema, PartialEq)]
191 #[serde(untagged)]                                                                                    191 #[serde(untagged)]
192 pub enum PromResponse {                                                                               192 pub enum PrometheusResponse {
193     PromData(PromData),                                                                               193     PromData(PromData),
194     Labels(Vec<String>),                                                                              194     Labels(Vec<String>),
195     Series(Vec<HashMap<String, String>>),                                                             195     Series(Vec<HashMap<String, String>>),
196     LabelValues(Vec<String>),                                                                         196     LabelValues(Vec<String>),
197 }                                                                                                     197 }
198                                                                                                       198 
199 impl Default for PromResponse {                                                                       199 impl Default for PrometheusResponse {
200     fn default() -> Self {                                                                            200     fn default() -> Self {
201         PromResponse::PromData(Default::default())                                                    201         PrometheusResponse::PromData(Default::default())
202     }                                                                                                 202     }
203 }                                                                                                     203 }
204                                                                                                       204 
205 #[derive(Debug, Default, Serialize, Deserialize, JsonSchema, PartialEq)]                              205 #[derive(Debug, Default, Serialize, Deserialize, JsonSchema, PartialEq)]
206 pub struct PromJsonResponse {                                                                         206 pub struct PrometheusJsonResponse {
207     pub status: String,                                                                               207     pub status: String,
208     pub data: PromResponse,                                                                           208     pub data: PrometheusResponse,
209     #[serde(skip_serializing_if = "Option::is_none")]                                                 209     #[serde(skip_serializing_if = "Option::is_none")]
210     pub error: Option<String>,                                                                        210     pub error: Option<String>,
211     #[serde(skip_serializing_if = "Option::is_none")]                                                 211     #[serde(skip_serializing_if = "Option::is_none")]

Renamed src/servers/src/prom.rs to src/servers/src/prometheus.rs
src/servers/src/prometheus.rs --- 6/20 --- Text (14 errors, exceeded DFT_PARSE_ERROR_LIMIT)
215     pub warnings: Option<Vec<String>>,                                                                215     pub warnings: Option<Vec<String>>,
216 }                                                                                                     216 }
217                                                                                                       217 
218 impl PromJsonResponse {                                                                               218 impl PrometheusJsonResponse {
219     pub fn error<S1, S2>(error_type: S1, reason: S2) -> Json<Self>                                    219     pub fn error<S1, S2>(error_type: S1, reason: S2) -> Json<Self>
220     where                                                                                             220     where
221         S1: Into<String>,                                                                             221         S1: Into<String>,
222         S2: Into<String>,                                                                             222         S2: Into<String>,
223     {                                                                                                 223     {
224         Json(PromJsonResponse {                                                                       224         Json(PrometheusJsonResponse {
225             status: "error".to_string(),                                                              225             status: "error".to_string(),
226             data: PromResponse::default(),                                                            226             data: PrometheusResponse::default(),
227             error: Some(reason.into()),                                                               227             error: Some(reason.into()),
228             error_type: Some(error_type.into()),                                                      228             error_type: Some(error_type.into()),
229             warnings: None,                                                                           229             warnings: None,
230         })                                                                                            230         })
231     }                                                                                                 231     }
232                                                                                                       232 
233     pub fn success(data: PromResponse) -> Json<Self> {                                                233     pub fn success(data: PrometheusResponse) -> Json<Self> {
234         Json(PromJsonResponse {                                                                       234         Json(PrometheusJsonResponse {
235             status: "success".to_string(),                                                            235             status: "success".to_string(),
236             data,                                                                                     236             data,
237             error: None,                                                                              237             error: None,

Renamed src/servers/src/prom.rs to src/servers/src/prometheus.rs
src/servers/src/prometheus.rs --- 7/20 --- Text (14 errors, exceeded DFT_PARSE_ERROR_LIMIT)
280                 if err.status_code() == StatusCode::TableNotFound                                     280                 if err.status_code() == StatusCode::TableNotFound
281                     || err.status_code() == StatusCode::TableColumnNotFound                           281                     || err.status_code() == StatusCode::TableColumnNotFound
282                 {                                                                                     282                 {
283                     Self::success(PromResponse::PromData(PromData {                                   283                     Self::success(PrometheusResponse::PromData(PromData {
284                         result_type: result_type_string,                                              284                         result_type: result_type_string,
285                         ..Default::default()                                                          285                         ..Default::default()
286                     }))                                                                               286                     }))

Renamed src/servers/src/prom.rs to src/servers/src/prometheus.rs
src/servers/src/prometheus.rs --- 8/20 --- Text (14 errors, exceeded DFT_PARSE_ERROR_LIMIT)
296         batches: RecordBatches,                                                                       296         batches: RecordBatches,
297         metric_name: String,                                                                          297         metric_name: String,
298         result_type: ValueType,                                                                       298         result_type: ValueType,
299     ) -> Result<PromResponse> {                                                                       299     ) -> Result<PrometheusResponse> {
300         // infer semantic type of each column from schema.                                            300         // infer semantic type of each column from schema.
301         // TODO(ruihang): wish there is a better way to do this.                                      301         // TODO(ruihang): wish there is a better way to do this.
302         let mut timestamp_column_index = None;                                                        302         let mut timestamp_column_index = None;

Renamed src/servers/src/prom.rs to src/servers/src/prometheus.rs
src/servers/src/prometheus.rs --- 9/20 --- Text (14 errors, exceeded DFT_PARSE_ERROR_LIMIT)
405             .collect::<Result<Vec<_>>>()?;                                                            405             .collect::<Result<Vec<_>>>()?;
406                                                                                                       406 
407         let result_type_string = result_type.to_string();                                             407         let result_type_string = result_type.to_string();
408         let data = PromResponse::PromData(PromData {                                                  408         let data = PrometheusResponse::PromData(PromData {
409             result_type: result_type_string,                                                          409             result_type: result_type_string,
410             result,                                                                                   410             result,
411         });                                                                                           411         });

Renamed src/servers/src/prom.rs to src/servers/src/prometheus.rs
src/servers/src/prometheus.rs --- 10/20 --- Text (14 errors, exceeded DFT_PARSE_ERROR_LIMIT)
424                                                                                                       424 
425 #[axum_macros::debug_handler]                                                                         425 #[axum_macros::debug_handler]
426 pub async fn instant_query(                                                                           426 pub async fn instant_query(
427     State(handler): State<PromHandlerRef>,                                                            427     State(handler): State<PrometheusHandlerRef>,
428     Query(params): Query<InstantQuery>,                                                               428     Query(params): Query<InstantQuery>,
429     Form(form_params): Form<InstantQuery>,                                                            429     Form(form_params): Form<InstantQuery>,
430 ) -> Json<PromJsonResponse> {                                                                         430 ) -> Json<PrometheusJsonResponse> {
431     // Extract time from query string, or use current server time if not specified.                   431     // Extract time from query string, or use current server time if not specified.
432     let time = params                                                                                 432     let time = params
433         .time                                                                                         433         .time

Renamed src/servers/src/prom.rs to src/servers/src/prometheus.rs
src/servers/src/prometheus.rs --- 11/20 --- Text (14 errors, exceeded DFT_PARSE_ERROR_LIMIT)
448     let result = handler.do_query(&prom_query, Arc::new(query_ctx)).await;                            448     let result = handler.do_query(&prom_query, Arc::new(query_ctx)).await;
449     let (metric_name, result_type) = match retrieve_metric_name_and_result_type(&prom_query.query) {  449     let (metric_name, result_type) = match retrieve_metric_name_and_result_type(&prom_query.query) {
450         Ok((metric_name, result_type)) => (metric_name.unwrap_or_default(), result_type),             450         Ok((metric_name, result_type)) => (metric_name.unwrap_or_default(), result_type),
451         Err(err) => return PromJsonResponse::error(err.status_code().to_string(), err.to_string()),   451         Err(err) => {
...                                                                                                       452             return PrometheusJsonResponse::error(err.status_code().to_string(), err.to_string())
...                                                                                                       453         }
452     };                                                                                                454     };
453     PromJsonResponse::from_query_result(result, metric_name, result_type).await                       455     PrometheusJsonResponse::from_query_result(result, metric_name, result_type).await
454 }                                                                                                     456 }
455                                                                                                       457 
456 #[derive(Debug, Default, Serialize, Deserialize, JsonSchema)]                                         458 #[derive(Debug, Default, Serialize, Deserialize, JsonSchema)]

Renamed src/servers/src/prom.rs to src/servers/src/prometheus.rs
src/servers/src/prometheus.rs --- 12/20 --- Text (14 errors, exceeded DFT_PARSE_ERROR_LIMIT)
465                                                                                                       467 
466 #[axum_macros::debug_handler]                                                                         468 #[axum_macros::debug_handler]
467 pub async fn range_query(                                                                             469 pub async fn range_query(
468     State(handler): State<PromHandlerRef>,                                                            470     State(handler): State<PrometheusHandlerRef>,
469     Query(params): Query<RangeQuery>,                                                                 471     Query(params): Query<RangeQuery>,
470     Form(form_params): Form<RangeQuery>,                                                              472     Form(form_params): Form<RangeQuery>,
471 ) -> Json<PromJsonResponse> {                                                                         473 ) -> Json<PrometheusJsonResponse> {
472     let prom_query = PromQuery {                                                                      474     let prom_query = PromQuery {
473         query: params.query.or(form_params.query).unwrap_or_default(),                                475         query: params.query.or(form_params.query).unwrap_or_default(),
474         start: params.start.or(form_params.start).unwrap_or_default(),                                476         start: params.start.or(form_params.start).unwrap_or_default(),

Renamed src/servers/src/prom.rs to src/servers/src/prometheus.rs
src/servers/src/prometheus.rs --- 13/20 --- Text (14 errors, exceeded DFT_PARSE_ERROR_LIMIT)
483                                                                                                       485 
484     let result = handler.do_query(&prom_query, Arc::new(query_ctx)).await;                            486     let result = handler.do_query(&prom_query, Arc::new(query_ctx)).await;
485     let metric_name = match retrieve_metric_name_and_result_type(&prom_query.query) {                 487     let metric_name = match retrieve_metric_name_and_result_type(&prom_query.query) {
486         Err(err) => return PromJsonResponse::error(err.status_code().to_string(), err.to_string()),   488         Err(err) => {
...                                                                                                       489             return PrometheusJsonResponse::error(err.status_code().to_string(), err.to_string())
...                                                                                                       490         }
487         Ok((metric_name, _)) => metric_name.unwrap_or_default(),                                      491         Ok((metric_name, _)) => metric_name.unwrap_or_default(),
488     };                                                                                                492     };
489     PromJsonResponse::from_query_result(result, metric_name, ValueType::Matrix).await                 493     PrometheusJsonResponse::from_query_result(result, metric_name, ValueType::Matrix).await
490 }                                                                                                     494 }
491                                                                                                       495 
492 #[derive(Debug, Default, Serialize, JsonSchema)]                                                      496 #[derive(Debug, Default, Serialize, JsonSchema)]

Renamed src/servers/src/prom.rs to src/servers/src/prometheus.rs
src/servers/src/prometheus.rs --- 14/20 --- Text (14 errors, exceeded DFT_PARSE_ERROR_LIMIT)
535                                                                                                       539 
536 #[axum_macros::debug_handler]                                                                         540 #[axum_macros::debug_handler]
537 pub async fn labels_query(                                                                            541 pub async fn labels_query(
538     State(handler): State<PromHandlerRef>,                                                            542     State(handler): State<PrometheusHandlerRef>,
539     Query(params): Query<LabelsQuery>,                                                                543     Query(params): Query<LabelsQuery>,
540     Form(form_params): Form<LabelsQuery>,                                                             544     Form(form_params): Form<LabelsQuery>,
541 ) -> Json<PromJsonResponse> {                                                                         545 ) -> Json<PrometheusJsonResponse> {
542     let mut queries = params.matches.0;                                                               546     let mut queries = params.matches.0;
543     if queries.is_empty() {                                                                           547     if queries.is_empty() {
544         queries = form_params.matches.0;                                                              548         queries = form_params.matches.0;
545     }                                                                                                 549     }
546     if queries.is_empty() {                                                                           550     if queries.is_empty() {
547         return PromJsonResponse::error("Unsupported", "match[] parameter is required");               551         return PrometheusJsonResponse::error("Unsupported", "match[] parameter is required");
548     }                                                                                                 552     }
549                                                                                                       553 
550     let start = params                                                                                554     let start = params

Renamed src/servers/src/prom.rs to src/servers/src/prometheus.rs
src/servers/src/prometheus.rs --- 15/20 --- Text (14 errors, exceeded DFT_PARSE_ERROR_LIMIT)
580             if err.status_code() != StatusCode::TableNotFound                                         584             if err.status_code() != StatusCode::TableNotFound
581                 && err.status_code() != StatusCode::TableColumnNotFound                               585                 && err.status_code() != StatusCode::TableColumnNotFound
582             {                                                                                         586             {
583                 return PromJsonResponse::error(err.status_code().to_string(), err.to_string());       587                 return PrometheusJsonResponse::error(
...                                                                                                       588                     err.status_code().to_string(),
...                                                                                                       589                     err.to_string(),
...                                                                                                       590                 );
584             }                                                                                         591             }
585         }                                                                                             592         }
586     }                                                                                                 593     }

Renamed src/servers/src/prom.rs to src/servers/src/prometheus.rs
src/servers/src/prometheus.rs --- 16/20 --- Text (14 errors, exceeded DFT_PARSE_ERROR_LIMIT)
590                                                                                                       597 
591     let mut sorted_labels: Vec<String> = labels.into_iter().collect();                                598     let mut sorted_labels: Vec<String> = labels.into_iter().collect();
592     sorted_labels.sort();                                                                             599     sorted_labels.sort();
593     PromJsonResponse::success(PromResponse::Labels(sorted_labels))                                    600     PrometheusJsonResponse::success(PrometheusResponse::Labels(sorted_labels))
594 }                                                                                                     601 }
595                                                                                                       602 
596 async fn retrieve_series_from_query_result(                                                           603 async fn retrieve_series_from_query_result(

Renamed src/servers/src/prom.rs to src/servers/src/prometheus.rs
src/servers/src/prometheus.rs --- 17/20 --- Text (14 errors, exceeded DFT_PARSE_ERROR_LIMIT)
768                                                                                                       775 
769 #[axum_macros::debug_handler]                                                                         776 #[axum_macros::debug_handler]
770 pub async fn label_values_query(                                                                      777 pub async fn label_values_query(
771     State(handler): State<PromHandlerRef>,                                                            778     State(handler): State<PrometheusHandlerRef>,
772     Path(label_name): Path<String>,                                                                   779     Path(label_name): Path<String>,
773     Query(params): Query<LabelValueQuery>,                                                            780     Query(params): Query<LabelValueQuery>,
774 ) -> Json<PromJsonResponse> {                                                                         781 ) -> Json<PrometheusJsonResponse> {
775     let queries = params.matches.0;                                                                   782     let queries = params.matches.0;
776     if queries.is_empty() {                                                                           783     if queries.is_empty() {
777         return PromJsonResponse::error("Invalid argument", "match[] parameter is required");          784         return PrometheusJsonResponse::error("Invalid argument", "match[] parameter is required");
778     }                                                                                                 785     }
779                                                                                                       786 
780     let start = params.start.unwrap_or_else(yesterday_rfc3339);                                       787     let start = params.start.unwrap_or_else(yesterday_rfc3339);

Renamed src/servers/src/prom.rs to src/servers/src/prometheus.rs
src/servers/src/prometheus.rs --- 18/20 --- Text (14 errors, exceeded DFT_PARSE_ERROR_LIMIT)
799             if err.status_code() != StatusCode::TableNotFound                                         806             if err.status_code() != StatusCode::TableNotFound
800                 && err.status_code() != StatusCode::TableColumnNotFound                               807                 && err.status_code() != StatusCode::TableColumnNotFound
801             {                                                                                         808             {
802                 return PromJsonResponse::error(err.status_code().to_string(), err.to_string());       809                 return PrometheusJsonResponse::error(
...                                                                                                       810                     err.status_code().to_string(),
...                                                                                                       811                     err.to_string(),
...                                                                                                       812                 );
803             }                                                                                         813             }
804         }                                                                                             814         }
805     }                                                                                                 815     }
806                                                                                                       816 
807     let mut label_values: Vec<_> = label_values.into_iter().collect();                                817     let mut label_values: Vec<_> = label_values.into_iter().collect();
808     label_values.sort();                                                                              818     label_values.sort();
809     PromJsonResponse::success(PromResponse::LabelValues(label_values))                                819     PrometheusJsonResponse::success(PrometheusResponse::LabelValues(label_values))
810 }                                                                                                     820 }
811                                                                                                       821 
812 async fn retrieve_label_values(                                                                       822 async fn retrieve_label_values(

Renamed src/servers/src/prom.rs to src/servers/src/prometheus.rs
src/servers/src/prometheus.rs --- 19/20 --- Text (14 errors, exceeded DFT_PARSE_ERROR_LIMIT)
877                                                                                                       887 
878 #[axum_macros::debug_handler]                                                                         888 #[axum_macros::debug_handler]
879 pub async fn series_query(                                                                            889 pub async fn series_query(
880     State(handler): State<PromHandlerRef>,                                                            890     State(handler): State<PrometheusHandlerRef>,
881     Query(params): Query<SeriesQuery>,                                                                891     Query(params): Query<SeriesQuery>,
882     Form(form_params): Form<SeriesQuery>,                                                             892     Form(form_params): Form<SeriesQuery>,
883 ) -> Json<PromJsonResponse> {                                                                         893 ) -> Json<PrometheusJsonResponse> {
884     let mut queries: Vec<String> = params.matches.0;                                                  894     let mut queries: Vec<String> = params.matches.0;
885     if queries.is_empty() {                                                                           895     if queries.is_empty() {
886         queries = form_params.matches.0;                                                              896         queries = form_params.matches.0;
887     }                                                                                                 897     }
888     if queries.is_empty() {                                                                           898     if queries.is_empty() {
889         return PromJsonResponse::error("Unsupported", "match[] parameter is required");               899         return PrometheusJsonResponse::error("Unsupported", "match[] parameter is required");
890     }                                                                                                 900     }
891     let start = params                                                                                901     let start = params
892         .start                                                                                        902         .start

Renamed src/servers/src/prom.rs to src/servers/src/prometheus.rs
src/servers/src/prometheus.rs --- 20/20 --- Text (14 errors, exceeded DFT_PARSE_ERROR_LIMIT)
914         let result = handler.do_query(&prom_query, query_ctx.clone()).await;                          924         let result = handler.do_query(&prom_query, query_ctx.clone()).await;
915         if let Err(err) = retrieve_series_from_query_result(result, &mut series, &table_name).await   925         if let Err(err) = retrieve_series_from_query_result(result, &mut series, &table_name).await
916         {                                                                                             926         {
917             return PromJsonResponse::error(err.status_code().to_string(), err.to_string());           927             return PrometheusJsonResponse::error(err.status_code().to_string(), err.to_string());
918         }                                                                                             928         }
919     }                                                                                                 929     }
920     PromJsonResponse::success(PromResponse::Series(series))                                           930     PrometheusJsonResponse::success(PrometheusResponse::Series(series))
921 }                                                                                                     931 }
prometheus.rs to prom-store.rs
Renamed src/servers/src/prometheus.rs to src/servers/src/prom_store.rs
src/servers/src/prom_store.rs --- 1/2 --- Rust
18 use std::collections::{BTreeMap, HashMap};                                                             18 use std::collections::{BTreeMap, HashMap};
19 use std::hash::{Hash, Hasher};                                                                         19 use std::hash::{Hash, Hasher};
20                                                                                                        20 
21 use api::prometheus::remote::label_matcher::Type as MatcherType;                                       21 use api::prom_store::remote::label_matcher::Type as MatcherType;
22 use api::prometheus::remote::{Label, Query, Sample, TimeSeries, WriteRequest};                         22 use api::prom_store::remote::{Label, Query, Sample, TimeSeries, WriteRequest};
23 use api::v1::{InsertRequest as GrpcInsertRequest, InsertRequests};                                     23 use api::v1::{InsertRequest as GrpcInsertRequest, InsertRequests};
24 use common_grpc::writer::{LinesWriter, Precision};                                                     24 use common_grpc::writer::{LinesWriter, Precision};
25 use common_recordbatch::{RecordBatch, RecordBatches};                                                  25 use common_recordbatch::{RecordBatch, RecordBatches};

Renamed src/servers/src/prometheus.rs to src/servers/src/prom_store.rs
src/servers/src/prom_store.rs --- 2/2 --- Rust
443 mod tests {                                                                                           443 mod tests {
444     use std::sync::Arc;                                                                               444     use std::sync::Arc;
445                                                                                                       445 
446     use api::prometheus::remote::LabelMatcher;                                                        446     use api::prom_store::remote::LabelMatcher;
447     use datafusion::prelude::SessionContext;                                                          447     use datafusion::prelude::SessionContext;
448     use datatypes::schema::{ColumnSchema, Schema};                                                    448     use datatypes::schema::{ColumnSchema, Schema};
449     use datatypes::vectors::{Float64Vector, StringVector, TimestampMillisecondVector};                449     use datatypes::vectors::{Float64Vector, StringVector, TimestampMillisecondVector};

Copy link
Member

@waynexia waynexia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks 🚀

@waynexia waynexia changed the title chore(prom)!: rename prometheus(remote storage) to prom-store and prom… chore(prom)!: rename prometheus(remote storage) to prom-store and promql(HTTP server) to prometheus Jul 12, 2023
Copy link
Contributor

@killme2008 killme2008 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Great job! Thank u.

@killme2008 killme2008 merged commit 674bfd8 into GreptimeTeam:develop Jul 12, 2023
18 checks passed
@etolbakov etolbakov deleted the refactor/prom-renaming branch July 12, 2023 07:12
paomian pushed a commit to paomian/greptimedb that referenced this pull request Oct 19, 2023
…mql(HTTP server) to prometheus (GreptimeTeam#1931)

* chore(prom): rename prometheus(remote storage) to prom-store and promql(HTTP server) to prometheus

* chore: apply clippy suggestions

* chore: adjust format according to rustfmt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-change This pull request contains breaking changes. Doc update required This change requires document update on https://github.com/GreptimeTeam/docs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants