diff --git a/bin/periphery/src/helpers/docker/container.rs b/bin/periphery/src/helpers/docker/container.rs index 80f413a5a..1bb90ba11 100644 --- a/bin/periphery/src/helpers/docker/container.rs +++ b/bin/periphery/src/helpers/docker/container.rs @@ -23,6 +23,11 @@ pub async fn container_log(container_name: &str, tail: u64) -> Log { run_monitor_command("get container log", command).await } +pub async fn container_log_search(container_name: &str, search: &str) -> Log { + let command = format!("docker logs {container_name} | grep {search}"); + run_monitor_command("get container log grep", command).await +} + pub async fn container_stats( container_name: Option, ) -> anyhow::Result> { diff --git a/bin/periphery/src/requests/container.rs b/bin/periphery/src/requests/container.rs index e62c94a7d..77f1b22bb 100644 --- a/bin/periphery/src/requests/container.rs +++ b/bin/periphery/src/requests/container.rs @@ -47,6 +47,22 @@ impl Resolve for State { // +#[derive(Serialize, Deserialize, Debug, Clone, Request)] +#[response(Log)] +pub struct GetContainerLogSearch { + pub name: String, + pub search: String, +} + +#[async_trait::async_trait] +impl Resolve for State { + async fn resolve(&self, req: GetContainerLogSearch, _: ()) -> anyhow::Result { + Ok(docker::container_log_search(&req.name, &req.search).await) + } +} + +// + #[derive(Serialize, Deserialize, Debug, Clone, Request)] #[response(DockerContainerStats)] pub struct GetContainerStats {