Skip to content

Commit

Permalink
fix: missing pre_write check on prometheus remote write (#4460)
Browse files Browse the repository at this point in the history
fix: missing pre_write check on prometheus remote write
  • Loading branch information
shuiyisong authored Jul 30, 2024
1 parent 7896201 commit 567f510
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/frontend/src/instance/prom_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,10 @@ impl PromStoreProtocolHandler for Instance {
.as_ref()
.check_permission(ctx.current_user(), PermissionReq::PromStoreWrite)
.context(AuthSnafu)?;
let interceptor_ref = self
.plugins
.get::<PromStoreProtocolInterceptorRef<servers::error::Error>>();
interceptor_ref.pre_write(&request, ctx.clone())?;

let output = if with_metric_engine {
let physical_table = ctx
Expand Down
10 changes: 7 additions & 3 deletions src/servers/src/interceptor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
use std::borrow::Cow;
use std::sync::Arc;

use api::prom_store::remote::{ReadRequest, WriteRequest};
use api::prom_store::remote::ReadRequest;
use api::v1::greptime_request::Request;
use api::v1::RowInsertRequests;
use async_trait::async_trait;
Expand Down Expand Up @@ -360,7 +360,7 @@ pub trait PromStoreProtocolInterceptor {

fn pre_write(
&self,
_write_req: &WriteRequest,
_write_req: &RowInsertRequests,
_ctx: QueryContextRef,
) -> Result<(), Self::Error> {
Ok(())
Expand All @@ -377,7 +377,11 @@ pub type PromStoreProtocolInterceptorRef<E> =
impl<E: ErrorExt> PromStoreProtocolInterceptor for Option<PromStoreProtocolInterceptorRef<E>> {
type Error = E;

fn pre_write(&self, write_req: &WriteRequest, ctx: QueryContextRef) -> Result<(), Self::Error> {
fn pre_write(
&self,
write_req: &RowInsertRequests,
ctx: QueryContextRef,
) -> Result<(), Self::Error> {
if let Some(this) = self {
this.pre_write(write_req, ctx)
} else {
Expand Down

0 comments on commit 567f510

Please sign in to comment.