GithubHelp home page GithubHelp logo

Usage Question about logparser HOT 4 CLOSED

java8964 avatar java8964 commented on June 13, 2024
Usage Question

from logparser.

Comments (4)

nielsbasjes avatar nielsbasjes commented on June 13, 2024
  1. The root cause of the parse error is that in the regex I generate I expect the firstline to look like this:
    (?:[a-zA-Z-_]+ .*(?: HTTP/[0-9]+\\.[0-9]+)?)|-

The value \x16\x03\x01 does not match that pattern so the parsing for that line fails.
I just had a look and I think I fixed it (it now allows the firstline to be .*).
Can you verify please?

  1. The code you posted looks fine and is how I intended it to be used.
    I ran this code by simply parsing the same line 2146891 times and this took approx 48 seconds on my laptop (i7). So yes, slower but not that slow.

Yes, internally I generate a regex for the first parsing layer.
You got to see it as part of the error in the previous question.

The regex is created as 'tightly as possible'. So for example for the IP address the regex is quite elaborate because I want to trip the 'wrong format' situation an still allow both ipv4 and ipv6. This system is slower than 'just a regex' and perhaps there is room to make it faster. Yet this is one of those balances between 'ease of use' vs 'maximum speed'.

from logparser.

nielsbasjes avatar nielsbasjes commented on June 13, 2024

One remark on the way you use the code: The parser will ONLY call the setter if it actually has the field.
So if you extract a field that is sometimes present and sometimes it is not you may have 'old values' in your record.
I recommend you include a method to clear the values before you pass it again into the parser.

If for example I add this

        @Field("HTTP.METHOD:request.firstline.method")
        public void setMethod(String method) {
            this.method = method;
        }

And then first call it with the 'normal firstline' and the with the "\x16\x03\x01" I would see in both records the method being "GET". In the first record it was extracted, in the second record it was not there so nothing was set and the old value wat not overwritten.

from logparser.

java8964 avatar java8964 commented on June 13, 2024

Yes. This issue is gone in version of 3.1-SNAPSHOT from master. When do you plan to release it? For the performance, we may use this library as a additional logic to parse the data if the plan REGEX cannot handle it, so it won't impact the performance too much

from logparser.

nielsbasjes avatar nielsbasjes commented on June 13, 2024

I just released version 3.1 that includes these changes.
Should be in maven central in a few hours or so.

from logparser.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.