Giter Site home page Giter Site logo

Comments (8)

driskell avatar driskell commented on July 3, 2024

I think current behaviour is that the last line will be buffered as never 'complete',

Files are currently treated as streams of lines that are constantly being written. So if we hit a line without EOL (end of line, \n) we wait. The main problem is non-line buffering in a lot of logging systems. They tend to write out in blocks of fixed size, and almost always end up with a half-written line with no EOL. Thus we have to wait until the next block is written in order to process the data and this could be a long time.

I think the best solution is to try ensure the application logs EOL at the end.

I'm not sure there's a way courier could handle this situation. It would need to understand the XML so when it opened a file it could ensure all data was logged, otherwise if it opened it a moment too soon it may catch it mid-write.

from log-courier.

java2kus avatar java2kus commented on July 3, 2024

I absolutely agree with you that log-courier cannot send an event when the file is being written and its a bit difficult to track this scenario within the code. The use-case I am talking about in the above example is searching for a pattern i.e. end of a soap envelope </soap:Envelope> . As soon as I hit the pattern, all the lines that were buffered into my multiline buffer need to be flushed as an event. Though I mentioned this as a EOL problem, its completely not related to EOL since, there is already a pattern match on the above.

Since there is no way for log-courier to know or understand the xml in a generic manner, is there anyway to provide a configuration parameter that will alter the behavior of log-courier multiline codec to emit the event on end of file on a pattern match. Let me know what you think.

Overall, log-courier is a fantastic piece of software! I have been using log-forwarder in my environment and have started experimenting with log-courier in the past couple of weeks with some awesome results.

from log-courier.

driskell avatar driskell commented on July 3, 2024

The issue is not that the multiline buffer is not flushing, but that it isn't even receiving the </soap:Envelope> bit. The codecs only receive complete lines, and emit events (which are created from one or more lines). Until a line is complete it sits in the file read buffer which is deeper in the code. So it's definitely an EOL issue since the pattern matching in the codec will only be run against complete lines.

The best and (in my opinion) correct fix here would be to get the application to log EOL at the end. Text files like logs should always end like this, and most editors will correct it. Though I fear that's out of the question for you by the sounds of it. :-(

Failing fixing at source, it could be worth trying to match the previous line (which is complete) instead of </soap:Envelope>. This end tag could then be added back in by Logstash if its absolutely required. This way it's a temporary fix for a specific problem.

I'm just really reluctant to add an option to log-courier as it won't be straight forward and it does seem a very specific problem. Hopefully this is understandable :-)

from log-courier.

java2kus avatar java2kus commented on July 3, 2024

Sure Jason. I do understand. I have implemented a very ugly hack in log-courier (or else I would have submitted a pull request) to solve that problem. The only reason why I was checking on this is because its a valid use case. The multi-line filter in logstash had a similar behavior. In order to prevent the premature flushing issue, the `maxmillis elapsed`` feature was implemented to flush the buffer in logstash (currently the default is set to 5 seconds). Please find below the logstash jira issue below:

https://logstash.jira.com/browse/LOGSTASH-271

from log-courier.

java2kus avatar java2kus commented on July 3, 2024

Also, I forgot to mention in the above, that its not related to EOF but EOL. By mistake I wrote EOL in the previous comment. Also, the logic is very much required in the what => "previous" case also.

from log-courier.

driskell avatar driskell commented on July 3, 2024

Hi @java2kus

Log Courier multiline codec has "previous timeout" which is the equivalent of the max millis in Logstash.

However, it won't flush the closing tag you have because it won't be in the codec buffer - it's not a finished line.

I'm pretty sure the lack of new line would have the same behaviour in logstash. It wouldn't reach the codec and would never be flushed.

from log-courier.

driskell avatar driskell commented on July 3, 2024

I can see it happens in logstash too I think though it looks old:
https://logstash.jira.com/plugins/servlet/mobile#issue/LOGSTASH-2124

from log-courier.

driskell avatar driskell commented on July 3, 2024

I will close this as I believe the issue lies with the logger, not the shipper, and working around it inside the shipper would be complex and extra code I need to maintain for little benefit globally.

from log-courier.

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.