{"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,"search_vec":"'-2016':47 '1.0.0':24 '2015':46 'api':28 'break':33 'cadenc':39 'compat':34 'current':21 'data':13 'extract':9,57 'grok':15,20,48 'inform':10 'librari':4 'log':53 'log-pars':52 'logstash':19 'major':27 'match':51 'older':36 'pars':6,54 'pattern':16,50 'pattern-match':49 'pygrok':1 'python':3 'redesign':29 'releas':38 'similar':17 'sporad':41 'string':7 'structured/unstructured':12 'text':56 'text-extract':55 'updat':44 'use':14 'v1.0.0':31 'version':22,37","created_at":"2026-04-27T17:01:34.029737+00:00","updated_at":"2026-04-27T17:01:34.029737+00:00","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,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"1.0.0","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/garyelephant/pygrok","docs":null,"changelog":null,"pypi":"https://pypi.org/project/pygrok/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["data","observability"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-06-28","next_check":"2026-07-28","install_tag":null}}