Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
Repo info
    Tito George
    Just want to check how can I use COMMONAPACHELOG
    I couldn't find a way to pass this in grok_match()
    Rodney Lopes Gomes
    @garyelephant awesome library!
    @titogeorgep late response but simply doing pygrok.grok_match('your line here', '%{COMMONAPACHELOG}') should return the parsed common apache log
    although I don't see a built in COMMONAPACHELOG entry https://github.com/garyelephant/pygrok/tree/master/pygrok/patterns

    heya. pygrok looks really useful. Just wondering tho: there seems to be two different character sets used in the pattern files. I am probably not as knowledgeable about Unicode as I probably should be these days, but it seems to be by brief experimentation that this single pattern file (grok-patterns) should be open()ed with utf-8 encoding as opposed to allowing the open() call to assume default encoding of ASCII, which leads to the classic UnicodeDecodeError whenever the pattern files are loaded, which they will be as soon as a Grok object is made.

    So, with my limited knowledge I see that these UnicodeDecodeErrors can be made to go away by passing the correct 'encoding' parameter to the open() call. Passing 'ascii' all the time unless the file name is 'grok-patterns' fixes this issue for me so I seem to be able to use pygrok with Py3k now AFAICT ATM.

    Any reason to not add this into pygrok.py? I can submit a PR if you want, but it is literally just an if statement checking the file name to be 'grok-patterns' and setting the encoding to 'utf-8' for that specific file by name, which doesn't really seem to be very solid. Happy to hear the correct way to do it?
    thx for the library. looking forward to using it more.

    sorry if that was confusing: basically the issue is that I can't really use the library in Python 3k AFAICT w/out this additional logic being added. I can't create a Grok object from a pattern if I use PyGrok in Python 3.5. Sorry If I have missed something. "best practice" AFAICT seems to indicate that the opener of external data files must always know the encoding of the file. I'm not sure if just hardcoding a specific file name as utf-8 is the right way to do it, but this does work for me for now.
    @garyelephant any word on what you'd like to see in the PR to be able to merge?
    DX DX
    @garyelephant pygrok is pretty awesome. However, I could not get it to work in python3x wonder if I miss any settings. It works fine with Python 2.7. Many thanks for your time !!!!