1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
|
About these examples
====================
They should be usable, but may require extra installed dependencies.
You can try them by running the command "grok -f /path/to/file.grok".
examples/filter-example.grok
---------------------------
- This demonstrates the built in transforms in grok, quoting a string
to be safe for usage in a shell, and for json output.
- It is also a handy example for watching how to do several actions
on one line of input.
,----[ output ]
| $ grok -f examples/filter-example.grok
| Shell escaped: \$something \"testing\"
| json: { myvalue: "$something \"testing\"" }
| $something "testing"
`----
examples/errorlogcheck.grok
---------------------------
- This requires the executable "since", which is available in the
package with the same name.
- It will run "since" on /var/log/messages, which outputs any lines
since the last invocation, and notify you if any of the log lines
match the string "error". It will then stop on the first match.
examples/ifconfig.grok, examples.ip-predicate.grok
--------------------------------------------------
- These seem to be the same file.
- They will run "ifconfig", and use the built-in library of regular
expressions to match IP addresses in the output.
,----[ output ]
| $ grok -f examples/ip-predicate.grok
| Found: 192.0.2.254
| Found: 127.0.0.1
`----
examples/execrestart.grok
-------------------------
- Runs a command. The match block will restart the command after 5
seconds. This will run until killed.
,----[ output ]
| $ grok -f examples/execrestart.grok
| Mon Jun 4 00:00:17 CEST 2012
| Mon Jun 4 00:00:22 CEST 2012
| Mon Jun 4 00:00:27 CEST 2012
| ^C
`----
examples/number-predicate2.grok
-------------------------------
- This uses a regular expression called NUMBER from the library, and
matches every input against it. If it matches, and is bigger than
20, we get output.
,----[ output ]
| $ grok -f examples/number-predicate2.grok
| Got number: 33
`----
examples/nuberpredicate.grok
----------------------------
- Runs the command "seq 25", and outputs all numbers higher than 20
,----[ output ]
| $ grok -f examples/numberpredicate.grok
| Found: 21
| Found: 22
| Found: 23
| Found: 24
| Found: 25
`----
|