<p dir="ltr"><br>
On 29 Jun 2015 1:50 am, "Ludovic Gasc" <<a href="mailto:gmludo@gmail.com">gmludo@gmail.com</a>> wrote:<br>
> In fact, the issue shouldn't be our brains, but it was clearly a time consuming task, and we have too much directly paid-work to take care.<br>
><br>
> Don't be wrong: I don't say that ELK doesn't work, only it's time consuming with a high level of logs.<br>
> I'm pretty sure that a lot of people are happy with ELK, it's cool for them ;-)<br>
><br>
> It's like Oracle and PostgreSQL databases: Where with Oracle you need a full-time DBA, with PostgreSQL: apt-get install postgresql<br>
> With this last sentence, I'm totally caricatural, but only to show where I see an issue that should be fixed, at least for us.<br>
> (FYI, in a previous professional life, I've maintained Oracle, MySQL and PostgreSQL servers for several clients, I know a little bit the subject).</p>
<p dir="ltr">This discrepancy in manageability between services like PostgreSQL & more complex setups like the ELK stack is why Red Hat started working on Nulecule as part of Project Atomic: <a href="http://rhelblog.redhat.com/2015/06/23/announcing-yum-rpm-for-containerized-applications-nulecule-atomic-app/">http://rhelblog.redhat.com/2015/06/23/announcing-yum-rpm-for-containerized-applications-nulecule-atomic-app/</a><br></p>
<p dir="ltr">There's still some work to be done making sure the related tools support Debian and derivatives properly, but "the ELK stack is too hard to install & maintain" is a distro level software management problem to be solved, rather than something to try to work around at the language level.</p>
<p dir="ltr">Cheers,<br>
Nick.<br><br></p>
<p dir="ltr">><br>
> From my point of view, the features in journald are enough to replace most usages of ELK, at least for us, and, contrary to ELK, journald is already installed in all latest Linux distributions, even in Debian Jessie. You have almost no maintenance cost.<br>
><br>
>> More importantly, when you drop logstash-forwarder, how are you intending to get the messages to the upstream server? You don't want to make your log calls synchronously wait for acknowledgement before returning. So you need some kind of buffering. And just buffering in memory doesn't work: if your service shuts down unexpectedly, you've lost the last batch of log messages which would tell you why it went down (plus, if the network goes down temporarily, your memory use becomes unbounded). You can of course buffer to disk, but then you've just reintroduced the same need for some kind of intermediate storage format you were trying to eliminate—and it doesn't really solve the problem, because if your service shuts down, the last messages won't get sent until it starts up again. So you could write a separate simple store-and-forward daemon that either reads those file buffers or listens on localhost UDP… but then you've just recreated logstash-forwarder.<br>
><br>
><br>
> In the past, we used directly a local rsyslog to play this role on each VM, connected directly with the Python daemons via a datagram UNIX socket.<br>
> See a logging config file example:<br>
> <a href="https://github.com/Eyepea/cookiecutter-API-Hour/blob/master/%7B%7Bcookiecutter.app_name%7D%7D/etc/%7B%7Bcookiecutter.app_name%7D%7D/api_hour/logging.ini#L21">https://github.com/Eyepea/cookiecutter-API-Hour/blob/master/%7B%7Bcookiecutter.app_name%7D%7D/etc/%7B%7Bcookiecutter.app_name%7D%7D/api_hour/logging.ini#L21</a><br>
><br>
> Now, it's journald that plays this role, also via a datagram UNIX socket.<br>
>  <br>
>><br>
>> And even if you wanted to do all that, I don't see why you couldn't do it all with structlog. They recommend using an already-working workflow instead of designing a different one from scratch, but it's just a recommendation.<br>
><br>
><br>
> You're right: Don't reinvent the wheel.<br>
> However, if I follow your argument in another context: instead of to create AsyncIO, Guido should integrate Twisted in Python ?<br>
> As an end-user of Twisted and AsyncIO, it isn't for the pleasure or to be fancy that we migrated from Twisted to AsyncIO ;-)<br>
> To me, the expression should be: "Don't reinvent the wheel, except if you can provide a more efficient wheel"<br>
><br>
> Now, in the context of logging: Please let me to try another approach, maybe I'll waste my time, or maybe I'll find an interesting gold nugget, who knows before to dig ?<br>
> You can think I'm trying to be only different from the "ELK" standard, and it's possible, who knows ?<br>
><br>
> If I revive this thread, it isn't to troll you, but because I'm interested in by your opinion.<br>
> I may found a better approach that doesn't need a CPython patch and it's more powerful.<br>
><br>
> In the source code of logging package, I've found this:<br>
> <a href="https://github.com/python/cpython/blob/master/Lib/logging/__init__.py#L269">https://github.com/python/cpython/blob/master/Lib/logging/__init__.py#L269</a><br>
> BTW, this approach should have more promotion: I didn't know you can use a dict to replace text in a log message, I thought only strings.<br>
><br>
> Now, instead of to use extra parameter, I use directly this feature.<br>
><br>
> For the developer, instead to write this:<br>
><br>
> logger.debug('Receive a create_or_update request from "%s" account', account_id)<br>
><br>
> he writes this:<br>
><br>
> logger.debug('Receive a create_or_update request from "%(account_id)s" account',<br>
>             {'request_id': request.request_id,<br>
>             'account_id': account_id,<br>
>             'aiohttp_request': request,<br>
>             'payload': payload})<br>
><br>
> With that, you can write logs as usual in your source code, and use the handler you want.<br>
><br>
> However, if you use the systemDream handler, all metadata with your log will be sent to journald:<br>
> <a href="https://github.com/Eyepea/systemDream/blob/master/src/systemdream/journal/handler.py#L79">https://github.com/Eyepea/systemDream/blob/master/src/systemdream/journal/handler.py#L79</a><br>
><br>
> The another bonus of this approach is that you can use an element of your dict to improve your log message.<br>
> With my previous approach with extra parameter, you must pass two times the values.<br>
> The cherry on the cake is that extra can be used for something else.<br>
> And the bonus of bonus, for the developers who already use this logging feature, they are already journald compliant without to know.<br>
><br>
> I see no drawbacks of this approach, except that the developers who already use this feature: he must be consistent in the key names of the dict to be useful with journald.<br>
><br>
> I'm very interested in by your feedbacks, maybe I've missed something.<br>
><br>
> If anybody doesn't find an issue, I'll push this pattern also in the official Python binding of journald, systemDream is only my laboratory to experiment around systemd/journald (and secondarily, it's impossible to setup the official Python binding of systemd/journald in a pyvenv, at least to me).<br>
><br>
> I'll publish also a step-by-step tutorial for the new comers on my blog.<br>
><br>
> Thanks for your attention.<br>
> --<br>
> Ludovic Gasc (GMLudo)<br>
> <a href="http://www.gmludo.eu/">http://www.gmludo.eu/</a><br>
><br>
> _______________________________________________<br>
> Python-ideas mailing list<br>
> <a href="mailto:Python-ideas@python.org">Python-ideas@python.org</a><br>
> <a href="https://mail.python.org/mailman/listinfo/python-ideas">https://mail.python.org/mailman/listinfo/python-ideas</a><br>
> Code of Conduct: <a href="http://python.org/psf/codeofconduct/">http://python.org/psf/codeofconduct/</a><br>
</p>