{"id":21753,"library":"pygrok","title":"pygrok","description":"A Python library to parse strings and extract information from structured/unstructured data using Grok patterns (similar to logstash grok). Current version is 1.0.0, with a major API redesign in v1.0.0 that breaks compatibility with older versions. Release cadence is sporadic, with most updates in 2015-2016.","status":"active","version":"1.0.0","language":"python","source_language":"en","source_url":"https://github.com/garyelephant/pygrok","tags":["grok","pattern-matching","log-parsing","text-extraction"],"install":[{"cmd":"pip install pygrok","lang":"bash","label":"pip"}],"dependencies":[],"imports":[{"note":"In v1.0.0, the main class is exported directly from pygrok.","wrong":"from pygrok.grok import Grok","symbol":"Grok","correct":"from pygrok import Grok"}],"quickstart":{"code":"from pygrok import Grok\ngrok = Grok('%{IP:client_ip}')\ntext = '192.168.0.1'\nprint(grok.match(text))","lang":"python","description":"Basic usage: compile a pattern and match against a string."},"warnings":[{"fix":"Upgrade to v1.0.0 and use `from pygrok import Grok`.","message":"v1.0.0 introduced a completely new API. Old code using `Grok(pattern)` and `grok.match(text)` is no longer compatible. The new API uses `Grok('%{PATTERN:name}')` and returns a dict from `match()`. No support for `%{PATTERN}` (without a field name) in v1.0.0? Actually v1.0.0 still supports it. But the class `Grok` is now the main entry point.","severity":"breaking","affected_versions":"<1.0.0"},{"fix":"Change to `from pygrok import Grok`.","message":"Older versions (0.x) used `pygrok.grok.Grok`. This import path is removed in v1.0.0.","severity":"deprecated","affected_versions":"<1.0.0"},{"fix":"Use `result = grok.match(text); if result: ...`.","message":"The `match()` method returns `None` if no match, not an empty dict. Always check for `None` before accessing results.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Use `from pygrok import Grok`.","cause":"Using wrong import path in v1.0.0; old code uses `from pygrok.grok import Grok`.","error":"AttributeError: module 'pygrok' has no attribute 'Grok'"},{"fix":"Reinstall with `pip install pygrok` (v1.0.0) and use `from pygrok import Grok`.","cause":"Installation of old version or using outdated import with v1.0.0.","error":"ImportError: No module named pygrok.grok"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}