forked from github-starred/komodo
further improve SearchLog
This commit is contained in:
@@ -130,7 +130,7 @@ impl Resolve<GetLog, User> for State {
|
|||||||
impl Resolve<SearchLog, User> for State {
|
impl Resolve<SearchLog, User> for State {
|
||||||
async fn resolve(
|
async fn resolve(
|
||||||
&self,
|
&self,
|
||||||
SearchLog { deployment, search }: SearchLog,
|
SearchLog { deployment, terms }: SearchLog,
|
||||||
user: User,
|
user: User,
|
||||||
) -> anyhow::Result<Log> {
|
) -> anyhow::Result<Log> {
|
||||||
let Deployment {
|
let Deployment {
|
||||||
@@ -148,7 +148,7 @@ impl Resolve<SearchLog, User> for State {
|
|||||||
}
|
}
|
||||||
let server = Server::get_resource(&server_id).await?;
|
let server = Server::get_resource(&server_id).await?;
|
||||||
periphery_client(&server)?
|
periphery_client(&server)?
|
||||||
.request(api::container::GetContainerLogSearch { name, search })
|
.request(api::container::GetContainerLogSearch { name, terms })
|
||||||
.await
|
.await
|
||||||
.context("failed at call to periphery")
|
.context("failed at call to periphery")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ impl Resolve<GetContainerLogSearch> for State {
|
|||||||
_: (),
|
_: (),
|
||||||
) -> anyhow::Result<Log> {
|
) -> anyhow::Result<Log> {
|
||||||
Ok(
|
Ok(
|
||||||
docker::container::container_log_search(&req.name, &req.search)
|
docker::container::container_log_search(&req.name, &req.terms)
|
||||||
.await,
|
.await,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -108,10 +108,7 @@ impl Resolve<GetContainerStatsList> for State {
|
|||||||
|
|
||||||
#[async_trait::async_trait]
|
#[async_trait::async_trait]
|
||||||
impl Resolve<StartContainer> for State {
|
impl Resolve<StartContainer> for State {
|
||||||
#[instrument(
|
#[instrument(name = "StartContainer", skip(self))]
|
||||||
name = "StartContainer",
|
|
||||||
skip(self)
|
|
||||||
)]
|
|
||||||
async fn resolve(
|
async fn resolve(
|
||||||
&self,
|
&self,
|
||||||
req: StartContainer,
|
req: StartContainer,
|
||||||
@@ -125,10 +122,7 @@ impl Resolve<StartContainer> for State {
|
|||||||
|
|
||||||
#[async_trait::async_trait]
|
#[async_trait::async_trait]
|
||||||
impl Resolve<StopContainer> for State {
|
impl Resolve<StopContainer> for State {
|
||||||
#[instrument(
|
#[instrument(name = "StopContainer", skip(self))]
|
||||||
name = "StopContainer",
|
|
||||||
skip(self)
|
|
||||||
)]
|
|
||||||
async fn resolve(
|
async fn resolve(
|
||||||
&self,
|
&self,
|
||||||
req: StopContainer,
|
req: StopContainer,
|
||||||
@@ -147,10 +141,7 @@ impl Resolve<StopContainer> for State {
|
|||||||
|
|
||||||
#[async_trait::async_trait]
|
#[async_trait::async_trait]
|
||||||
impl Resolve<RemoveContainer> for State {
|
impl Resolve<RemoveContainer> for State {
|
||||||
#[instrument(
|
#[instrument(name = "RemoveContainer", skip(self))]
|
||||||
name = "RemoveContainer",
|
|
||||||
skip(self)
|
|
||||||
)]
|
|
||||||
async fn resolve(
|
async fn resolve(
|
||||||
&self,
|
&self,
|
||||||
req: RemoveContainer,
|
req: RemoveContainer,
|
||||||
@@ -169,10 +160,7 @@ impl Resolve<RemoveContainer> for State {
|
|||||||
|
|
||||||
#[async_trait::async_trait]
|
#[async_trait::async_trait]
|
||||||
impl Resolve<RenameContainer> for State {
|
impl Resolve<RenameContainer> for State {
|
||||||
#[instrument(
|
#[instrument(name = "RenameContainer", skip(self))]
|
||||||
name = "RenameContainer",
|
|
||||||
skip(self)
|
|
||||||
)]
|
|
||||||
async fn resolve(
|
async fn resolve(
|
||||||
&self,
|
&self,
|
||||||
req: RenameContainer,
|
req: RenameContainer,
|
||||||
@@ -192,10 +180,7 @@ impl Resolve<RenameContainer> for State {
|
|||||||
|
|
||||||
#[async_trait::async_trait]
|
#[async_trait::async_trait]
|
||||||
impl Resolve<PruneContainers> for State {
|
impl Resolve<PruneContainers> for State {
|
||||||
#[instrument(
|
#[instrument(name = "PruneContainers", skip(self))]
|
||||||
name = "PruneContainers",
|
|
||||||
skip(self)
|
|
||||||
)]
|
|
||||||
async fn resolve(
|
async fn resolve(
|
||||||
&self,
|
&self,
|
||||||
_: PruneContainers,
|
_: PruneContainers,
|
||||||
@@ -209,10 +194,7 @@ impl Resolve<PruneContainers> for State {
|
|||||||
|
|
||||||
#[async_trait::async_trait]
|
#[async_trait::async_trait]
|
||||||
impl Resolve<Deploy> for State {
|
impl Resolve<Deploy> for State {
|
||||||
#[instrument(
|
#[instrument(name = "Deploy", skip(self))]
|
||||||
name = "Deploy",
|
|
||||||
skip(self)
|
|
||||||
)]
|
|
||||||
async fn resolve(
|
async fn resolve(
|
||||||
&self,
|
&self,
|
||||||
Deploy {
|
Deploy {
|
||||||
|
|||||||
@@ -30,10 +30,12 @@ pub async fn container_log(container_name: &str, tail: u64) -> Log {
|
|||||||
#[instrument(level = "debug")]
|
#[instrument(level = "debug")]
|
||||||
pub async fn container_log_search(
|
pub async fn container_log_search(
|
||||||
container_name: &str,
|
container_name: &str,
|
||||||
search: &str,
|
terms: &[String],
|
||||||
) -> Log {
|
) -> Log {
|
||||||
let command =
|
let command = format!(
|
||||||
format!("docker logs {container_name} --tail 5000 | grep {search}");
|
"docker logs {container_name} --tail 5000 | grep -E '{}'",
|
||||||
|
terms.join("|")
|
||||||
|
);
|
||||||
run_monitor_command("get container log grep", command).await
|
run_monitor_command("get container log grep", command).await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ pub struct SearchLog {
|
|||||||
/// Id or name
|
/// Id or name
|
||||||
#[serde(alias = "id", alias = "name")]
|
#[serde(alias = "id", alias = "name")]
|
||||||
pub deployment: String,
|
pub deployment: String,
|
||||||
pub search: String,
|
pub terms: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[typeshare]
|
#[typeshare]
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ fn default_tail() -> u64 {
|
|||||||
#[response(Log)]
|
#[response(Log)]
|
||||||
pub struct GetContainerLogSearch {
|
pub struct GetContainerLogSearch {
|
||||||
pub name: String,
|
pub name: String,
|
||||||
pub search: String,
|
pub terms: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|||||||
Reference in New Issue
Block a user