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

feat(pipeline): transform support on_failure #4123

Merged
merged 61 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
63491d9
chore: add log http ingester scaffold
paomian May 22, 2024
4d2ec3b
chore: add some example code
paomian May 22, 2024
2e51c16
chore: add log inserter
paomian May 27, 2024
fbc66ec
chore: add log handler file
paomian May 27, 2024
cd4d83d
chore: add pipeline lib
paomian May 27, 2024
2bc1937
chore: import log handler
paomian May 29, 2024
2b16ef9
chore: add pipelime http handler
paomian May 29, 2024
f1350cd
chore: add pipeline private table
paomian May 30, 2024
1d52cad
chore: add pipeline API
paomian May 31, 2024
8c69abb
chore: improve error handling
paomian May 31, 2024
7e0a9ad
Merge branch 'main' into feat/log-handler
shuiyisong Jun 3, 2024
73432dc
chore: merge main
shuiyisong Jun 3, 2024
9d7284c
Merge pull request #6 from shuiyisong/chore/merge_main
paomian Jun 3, 2024
1a03b7e
chore: add multi content type support for log handler
paomian Jun 3, 2024
a2f1230
Merge branch 'main' into feat/log-handler
shuiyisong Jun 4, 2024
6a0998d
refactor: remove servers dep on pipeline
shuiyisong Jun 3, 2024
443eaf9
refactor: move define_into_tonic_status to common-error
shuiyisong Jun 3, 2024
c8ce4ee
refactor: bring in pipeline 3eb890c551b8d7f60c4491fcfec18966e2b210a4
shuiyisong Jun 4, 2024
eb9cd22
chore: fix typo
shuiyisong Jun 4, 2024
8d0595c
refactor: bring in pipeline a95c9767d7056ab01dd8ca5fa1214456c6ffc72c
shuiyisong Jun 4, 2024
061b14e
chore: fix typo and license header
shuiyisong Jun 4, 2024
c152472
refactor: move http event handler to a separate file
shuiyisong Jun 4, 2024
ddea3c1
chore: add test for pipeline
paomian Jun 4, 2024
162e92f
Merge branch 'main' into feat/log-handler
shuiyisong Jun 4, 2024
5a7a5be
chore: update
shuiyisong Jun 4, 2024
423e51e
chore: fmt
shuiyisong Jun 4, 2024
51df233
Merge pull request #7 from shuiyisong/refactor/log_handler
paomian Jun 4, 2024
8066eb3
refactor: bring in pipeline 7d2402701877901871dd1294a65ac937605a6a93
shuiyisong Jun 4, 2024
e2a2e50
refactor: move `pipeline_operator` to `pipeline` crate
shuiyisong Jun 4, 2024
209a1a3
chore: minor update
shuiyisong Jun 4, 2024
c110adb
refactor: bring in pipeline 1711f4d46687bada72426d88cda417899e0ae3a4
shuiyisong Jun 5, 2024
1047dd7
chore: add log
shuiyisong Jun 5, 2024
2ff2fda
chore: add log
shuiyisong Jun 5, 2024
8b6a652
chore: remove open hook
shuiyisong Jun 5, 2024
6ca15ad
Merge pull request #8 from shuiyisong/refactor/log
paomian Jun 5, 2024
1298b0a
chore: minor update
shuiyisong Jun 5, 2024
ea548b0
chore: fix fmt
shuiyisong Jun 5, 2024
fb13278
Merge pull request #9 from shuiyisong/refactor/log
paomian Jun 5, 2024
6c88b89
chore: minor update
shuiyisong Jun 5, 2024
eeed85e
chore: rename desc for pipeline table
shuiyisong Jun 5, 2024
f77d20b
refactor: remove updated_at in pipelines
shuiyisong Jun 5, 2024
38ed6bb
Merge pull request #10 from shuiyisong/chore/polish_code
paomian Jun 5, 2024
5815675
chore: add more content type support for log inserter api
paomian Jun 5, 2024
c84ef0e
Merge pull request #11 from paomian/feat/log-handler-v2
paomian Jun 5, 2024
2e69655
chore: introduce pipeline crate
shuiyisong Jun 5, 2024
ca9525d
Merge branch 'chore/introduce_pipeline' into feat/log-handler
shuiyisong Jun 5, 2024
85a4c32
Merge branch 'main' into feat/log-handler
shuiyisong Jun 6, 2024
77ef015
chore: update upload pipeline api
paomian Jun 6, 2024
43a57a7
chore: fix by pr commit
paomian Jun 6, 2024
3560285
chore: add some doc for pub fn/struct
paomian Jun 6, 2024
4872c8a
chore: some minro fix
paomian Jun 6, 2024
11933b0
chore: add pipeline version support
paomian Jun 6, 2024
92a2bda
chore: impl log pipeline version
paomian Jun 7, 2024
29eb2db
transform on_failure
yuanbohan Jun 8, 2024
3f8b9ce
chore: merge main
shuiyisong Jun 11, 2024
e764564
chore: merge main
shuiyisong Jun 12, 2024
6bec090
chore: merge log-handler
shuiyisong Jun 12, 2024
4236f87
chore: add test
shuiyisong Jun 12, 2024
cbb2337
chore: move test to a separate file
shuiyisong Jun 12, 2024
6968150
chore: merge log-handler
shuiyisong Jun 17, 2024
83e59b1
chore: add comment
shuiyisong Jun 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
chore: add log http ingester scaffold
  • Loading branch information
paomian committed May 27, 2024
commit 63491d9770669b344802cc105263ca86ba520c61
3 changes: 3 additions & 0 deletions src/frontend/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ where
Some(self.instance.clone()),
);

builder = builder
.with_log_ingest_handler(ServerGrpcQueryHandlerAdapter::arc(self.instance.clone()));

if let Some(user_provider) = self.plugins.get::<UserProviderRef>() {
builder = builder.with_user_provider(user_provider);
}
Expand Down
1 change: 1 addition & 0 deletions src/servers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ tower = { workspace = true, features = ["full"] }
tower-http = { version = "0.4", features = ["full"] }
urlencoding = "2.1"
zstd.workspace = true
#pipeline = { git = "https://github.com/GreptimeTeam/pipeline.git", rev = "3cdbe92239303b3208ddd71a7ff7630730c91ad5" }

[target.'cfg(not(windows))'.dependencies]
tikv-jemalloc-ctl = { version = "0.5", features = ["use_std"] }
Expand Down
18 changes: 18 additions & 0 deletions src/servers/src/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ use crate::http::prometheus::{
use crate::metrics::http_metrics_layer;
use crate::metrics_handler::MetricsHandler;
use crate::prometheus_handler::PrometheusHandlerRef;
use crate::query_handler::grpc::ServerGrpcQueryHandlerRef;
use crate::query_handler::sql::ServerSqlQueryHandlerRef;
use crate::query_handler::{
InfluxdbLineProtocolHandlerRef, OpenTelemetryProtocolHandlerRef, OpentsdbProtocolHandlerRef,
Expand Down Expand Up @@ -587,6 +588,17 @@ impl HttpServerBuilder {
}
}

// FIXME(qtang): This is a temporary solution to handle the log ingest metrics.
pub fn with_log_ingest_handler(self, handler: ServerGrpcQueryHandlerRef) -> Self {
Self {
router: self.router.nest(
&format!("/{HTTP_API_VERSION}/event"),
HttpServer::route_log(handler),
),
..self
}
}

pub fn with_plugins(self, plugins: Plugins) -> Self {
Self { plugins, ..self }
}
Expand Down Expand Up @@ -699,6 +711,12 @@ impl HttpServer {
.with_state(metrics_handler)
}

fn route_log<S>(grpc_handler: ServerGrpcQueryHandlerRef) -> Router<S> {
Router::new()
.route("/logs", routing::get(handler::log_ingester))
.with_state(grpc_handler)
}

fn route_sql<S>(api_state: ApiState) -> ApiRouter<S> {
ApiRouter::new()
.api_route(
Expand Down
26 changes: 26 additions & 0 deletions src/servers/src/http/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use std::env;
use std::time::Instant;

use aide::transform::TransformOperation;
use api::v1::RowInsertRequests;
use axum::extract::{Json, Query, State};
use axum::response::{IntoResponse, Response};
use axum::{Extension, Form};
Expand Down Expand Up @@ -44,6 +45,7 @@ use crate::http::{
HttpResponse, ResponseFormat,
};
use crate::metrics_handler::MetricsHandler;
use crate::query_handler::grpc::ServerGrpcQueryHandlerRef;
use crate::query_handler::sql::ServerSqlQueryHandlerRef;

#[derive(Debug, Default, Serialize, Deserialize, JsonSchema)]
Expand All @@ -64,6 +66,30 @@ pub struct SqlQuery {
pub epoch: Option<String>,
pub limit: Option<usize>,
}
/// handler to log ingester
#[axum_macros::debug_handler]
pub async fn log_ingester(
State(_state): State<ServerGrpcQueryHandlerRef>,
Query(_query_params): Query<SqlQuery>,
Extension(_query_ctx): Extension<QueryContextRef>,
Json(_payload): Json<Value>,
) -> String {
// TODO (paomian): implement log ingester
// transform payload to RowInsertRequest
// maybe we need a new trait for log ingester like `LogIngester` instead of `ServerGrpcQueryHandlerRef`
// let request = pileline::transform(payload);
// state.do_query(payload, query_ctx).await.to_string();
let _processors = _payload["processors"].as_str().unwrap();
let _data = _payload["data"].as_array().unwrap();

let insert_request =
api::v1::greptime_request::Request::RowInserts(RowInsertRequests::default());
let insert_result = _state.do_query(insert_request, _query_ctx).await;
match insert_result {
Ok(_) => String::from("ok"),
Err(e) => e.to_string(),
}
}

/// Handler to execute sql
#[axum_macros::debug_handler]
Expand Down