Receive log files via API
-
I'm developing a plugin for filtering messages and need to parse log files. Is it possible to receive a log file via API?
-
Keith Staff
Alexander,
Are there any particular log files you are wishing to parse? Many of MDaemon's internal plugins will export HRESULT WINAPI HrMDPluginGetLogfilePath( LPSTR psz, DWORD cch );
-
Thank you for your answer. I can only use the webservice xml api. In my work I use routing, smtp, av, antispam logs and etc. We are talking about files such as:
MDaemon-2024-05-14-Routing.log
MDaemon-2024-05-14-SMTP-(in).log
MDaemon-2024-05-14-Screening.log
-
Keith Staff
The XML API does not currently expose those log file pathnames or stream that log content. I can add that to the wishlist for a future version. At this time, I don't know of a way for the API itself to get those logs, as MD doesn't expose an API to retrieve them, but that would be included in the development.
-
This would be great, because logs are the only source of detailed information that can be used to analyze/parse a large amount of consolidated data. As an example, consolidate IP addresses from the file of failed authorization attempts, which block on an external firewall and so on
-
Keith Staff
Okay, will Wishlist this for a future version. v24.5 is a remote possibility, but v.25 is likely,
-
@Alexander Vasiliev as an interim solution, I wrote a simple PoC REST service that exposes a webservice to list and download MDaemon log files.
The service must be installed on the machine that has MDaemon.
If you have to expose it on the public network, you will have to put a reverse proxy handling https in front of it, because the
/api/logs
webservices are protected and you will first have to authenticate with credentials on/api/auth
to get a JWT.
-
@Emanuele I really appreciate the addition of this method, but it seems to be difficult for me
-
@Alexander Vasiliev no problem. I have been wanting to try writing a REST server for MDaemon for a long time (at least since 2016) and your question simply provided me with the opportunity to do so. Maybe now the project will evolve on its own with new APIs.
I think I can imagine your difficulty: MDaemon's web APIs are inspired by SOAP, whereas the REST ones are completely different in terms of both the basic idea and the data format on the wire: just to make life easier for you, I had added the OpenAPI document, but evidently the paradigm shift is still too onerous.
Time permitting, I might try to write some client projects using this REST API, so as to provide complete examples of the data flow from a user application to MDaemon and back. If so, I will announce them in this forum, for those who wish to try them out.
-
Keith Staff
@Alexander
In MDaemon v24.5, see the new "FileTransfer" operation, which allows you to list and download files from spcific directories.