cmd/logcatcher: match mincatcher output
Signed-off-by: Christine Dodrill <me@christine.website>
This commit is contained in:
parent
9065599679
commit
8b24578910
|
@ -712,12 +712,15 @@ version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"axum",
|
"axum",
|
||||||
|
"chrono",
|
||||||
"futures",
|
"futures",
|
||||||
"headers",
|
"headers",
|
||||||
"hyper",
|
"hyper",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"logtail",
|
"logtail",
|
||||||
"prometheus",
|
"prometheus",
|
||||||
|
"serde",
|
||||||
|
"serde_json",
|
||||||
"structopt",
|
"structopt",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tower",
|
"tower",
|
||||||
|
|
|
@ -10,6 +10,7 @@ anyhow = "1"
|
||||||
futures = "0.3"
|
futures = "0.3"
|
||||||
headers = "0.3"
|
headers = "0.3"
|
||||||
lazy_static = "1"
|
lazy_static = "1"
|
||||||
|
serde_json = "1"
|
||||||
structopt = "0.3"
|
structopt = "0.3"
|
||||||
tower = "0.4"
|
tower = "0.4"
|
||||||
tracing = "0.1"
|
tracing = "0.1"
|
||||||
|
@ -23,6 +24,10 @@ logtail = { path = "../../crates/logtail" }
|
||||||
version = "0.2"
|
version = "0.2"
|
||||||
features = [ "headers" ]
|
features = [ "headers" ]
|
||||||
|
|
||||||
|
[dependencies.chrono]
|
||||||
|
version = "0.4"
|
||||||
|
features = [ "serde" ]
|
||||||
|
|
||||||
[dependencies.hyper]
|
[dependencies.hyper]
|
||||||
version = "0.14"
|
version = "0.14"
|
||||||
features = [ "full" ]
|
features = [ "full" ]
|
||||||
|
@ -31,6 +36,10 @@ features = [ "full" ]
|
||||||
version = "0.12"
|
version = "0.12"
|
||||||
features = [ "process" ]
|
features = [ "process" ]
|
||||||
|
|
||||||
|
[dependencies.serde]
|
||||||
|
version = "1"
|
||||||
|
features = [ "derive" ]
|
||||||
|
|
||||||
[dependencies.tokio]
|
[dependencies.tokio]
|
||||||
version = "1"
|
version = "1"
|
||||||
features = [ "full" ]
|
features = [ "full" ]
|
||||||
|
|
|
@ -4,10 +4,12 @@ use axum::{
|
||||||
handler::{get, post},
|
handler::{get, post},
|
||||||
Router,
|
Router,
|
||||||
};
|
};
|
||||||
|
use chrono::prelude::*;
|
||||||
use headers::{Header, HeaderName, HeaderValue};
|
use headers::{Header, HeaderName, HeaderValue};
|
||||||
use hyper::http::StatusCode;
|
use hyper::http::StatusCode;
|
||||||
|
use logtail::PublicID;
|
||||||
use prometheus::{Encoder, IntGauge};
|
use prometheus::{Encoder, IntGauge};
|
||||||
use std::{convert::TryInto, io::Write, net::SocketAddr, path::PathBuf};
|
use std::{convert::TryInto, net::SocketAddr, path::PathBuf};
|
||||||
use tokio::sync::Semaphore;
|
use tokio::sync::Semaphore;
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
|
@ -108,7 +110,28 @@ async fn put_logs(
|
||||||
let compressed_body = hyper::body::to_bytes(body).await.unwrap();
|
let compressed_body = hyper::body::to_bytes(body).await.unwrap();
|
||||||
zstd::block::decompress_to_buffer(&compressed_body, &mut decompressed_body).unwrap();
|
zstd::block::decompress_to_buffer(&compressed_body, &mut decompressed_body).unwrap();
|
||||||
|
|
||||||
std::io::stdout().lock().write(&decompressed_body).unwrap();
|
let vals: Vec<serde_json::Value> = serde_json::from_slice(&decompressed_body).unwrap();
|
||||||
|
|
||||||
|
#[derive(serde::Serialize)]
|
||||||
|
pub struct Envelope {
|
||||||
|
log_id: PublicID,
|
||||||
|
collection: String,
|
||||||
|
data: serde_json::Value,
|
||||||
|
server_time: DateTime<Utc>,
|
||||||
|
}
|
||||||
|
|
||||||
|
for data in vals {
|
||||||
|
serde_json::to_writer(
|
||||||
|
std::io::stdout().lock(),
|
||||||
|
&Envelope {
|
||||||
|
log_id: private_id.as_public(),
|
||||||
|
collection: collection.clone(),
|
||||||
|
data,
|
||||||
|
server_time: Utc::now(),
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
StatusCode::NO_CONTENT
|
StatusCode::NO_CONTENT
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue