Dynamic log grep example
This commit is contained in:
+3
@@ -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
|
||||
@@ -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"
|
||||
```
|
||||
Reference in New Issue
Block a user