From 3f7b4782ea5e14fefac4d3d989c5a0f14dfc43ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roberto=20Abdelkader=20Mart=C3=ADnez=20P=C3=A9rez?= Date: Mon, 27 Jan 2020 16:31:49 +0100 Subject: [PATCH] Dynamic log grep example --- examples/basic/02_FixLogGrep/README.md | 2 +- .../03_DynamicLogGrep/DynamicLogGrep.pow | 3 +++ examples/basic/03_DynamicLogGrep/README.md | 21 +++++++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) create mode 100755 examples/basic/03_DynamicLogGrep/DynamicLogGrep.pow create mode 100644 examples/basic/03_DynamicLogGrep/README.md diff --git a/examples/basic/02_FixLogGrep/README.md b/examples/basic/02_FixLogGrep/README.md index d15cc43..4d77e03 100644 --- a/examples/basic/02_FixLogGrep/README.md +++ b/examples/basic/02_FixLogGrep/README.md @@ -12,7 +12,7 @@ $ kapow server FixLogGrep.pow ## How to consume it ``` -$ curl http://apache-host:8080/apache-errors +$ curl http://localhost:8080/apache-errors [Fri Feb 01 22:07:57.154391 2019] [core:info] [pid 7:tid 140284200093440] [client 172.17.0.1:50756] AH00128: File does not exist: /usr/var/www/mysite/favicon.ico [Fri Feb 01 22:07:57.808291 2019] [core:info] [pid 8:tid 140284216878848] [client 172.17.0.1:50758] AH00128: File does not exist: /usr/var/www/mysite/favicon.ico [Fri Feb 01 22:07:57.878149 2019] [core:info] [pid 8:tid 140284208486144] [client 172.17.0.1:50758] AH00128: File does not exist: /usr/var/www/mysite/favicon.ico diff --git a/examples/basic/03_DynamicLogGrep/DynamicLogGrep.pow b/examples/basic/03_DynamicLogGrep/DynamicLogGrep.pow new file mode 100755 index 0000000..066125a --- /dev/null +++ b/examples/basic/03_DynamicLogGrep/DynamicLogGrep.pow @@ -0,0 +1,3 @@ +kapow route add /apache-logs - <<-'EOF' + cat /var/log/apache2/access.log | grep -- "$(kapow get /request/params/pattern)" | kapow set /response/body +EOF diff --git a/examples/basic/03_DynamicLogGrep/README.md b/examples/basic/03_DynamicLogGrep/README.md new file mode 100644 index 0000000..7fdf5c5 --- /dev/null +++ b/examples/basic/03_DynamicLogGrep/README.md @@ -0,0 +1,21 @@ +# Dynamic Log Grep as a Service + +A simple service that exposes log entries that matches **with a given text** on our Apache Web Server. + +## How to run it + +``` +$ kapow server DynamicLogGrep.pow +``` + + +## How to consume it + +``` +$ curl http://localhost:8080/apache-logs?pattern=Chrome +70.127.254.161 - - [17/May/2015:22:05:19 +0000] "GET /reset.css HTTP/1.1" 200 1015 "http://www.semicomplete.com/projects/xdotool/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537.36" +70.127.254.161 - - [17/May/2015:22:05:27 +0000] "GET /style2.css HTTP/1.1" 200 4877 "http://www.semicomplete.com/projects/xdotool/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537.36" +70.127.254.161 - - [17/May/2015:22:05:19 +0000] "GET /images/jordan-80.png HTTP/1.1" 200 6146 "http://www.semicomplete.com/projects/xdotool/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537.36" +70.127.254.161 - - [17/May/2015:22:05:25 +0000] "GET /images/web/2009/banner.png HTTP/1.1" 200 52315 "http://www.semicomplete.com/projects/xdotool/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537.36" +70.127.254.161 - - [17/May/2015:22:05:56 +0000] "GET /favicon.ico HTTP/1.1" 200 3638 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537.36" +```