Forked from https://github.com/garyelephant/pygrok as it seems to be dead. If pygrok becomes active again this fork may be closed.
Python implementaion of Jordan Sissel’s Grok.
Install
pip install yalp_grok
Basic Usage
>>> import yalp_grok as pygrok
>>> text = 'gary is male, 25 years old and weighs 68.5 kilograms'
>>> pattern = '%{WORD:name} is %{WORD:gender}, %{NUMBER:age} years old and
weighs %{NUMBER:weight} kilograms'
>>> print pygrok.grok_match(text, pattern)
{'gender': 'male', 'age': '25', 'name': 'gary', 'weight': '68.5'}
Reusing Patterns
Since compiling a pattern can be time consuming, patterns can be compiled once and then reused for searching.
>>> import yalp_grok as pygrok
>>> pattern = "%{COMMONAPACHELOG}"
>>> compiled_pattern = pygrok.compile_pattern(pattern)
>>> with open('/var/log/apache/access.log', 'r') as log_file
... matches = [pygrok.grok_search(line, compiled_pattern) for line in log_file]
Release files for yalp_grok 0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| yalp_grok-0.3.tar.gz | 15.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| yalp_grok-0.3-py2-none-any.whl | Python 2 | none | any | Details |
Total release size: 31.2 kB
Release files / yalp_grok-0.3.tar.gz
| Download URL | yalp_grok-0.3.tar.gz |
|---|---|
| Size | 15.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1f84883acaa3317adbb2c52031c2161798ee64a557425adc39aaa8bb8d53a681
|
|
BLAKE2b-256 checksum How to use checksums |
6e93266d77b6e41586bddd69a19a2f3761747e2c0457fcc0efa5e12e88174d01
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / yalp_grok-0.3-py2-none-any.whl
| Download URL | yalp_grok-0.3-py2-none-any.whl |
|---|---|
| Size | 15.9 kB |
| Tags | Python 2 |
|
SHA-256 checksum How to use checksums |
57ed83cd3eaef613da5b9ef442decd8e06b62707edcac00dac301a3115befeaa
|
|
BLAKE2b-256 checksum How to use checksums |
c90244716d0d0e2cc15de3f623efb5938116da1cbf272e227aadddc5c2d737b0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |