Created 08-04-2021 09:36 AM
Hello Experts,
I have a requirement where nifi flows imp log information should be written to MongDB, so that another application can read mongodb and display those interesting logs info on web UI.
I am looking for best way to do this.
One way I am thinking of is tail nifi log (using tail file processor) and filter for imp log and put into MongoDb using native processor.
Please suggest if any other better approaches,
thanks in advance.
Thanks
Mahendra
Created 08-04-2021 11:08 PM
Filtering like that in nifi could work though it might be a bit resource intensive depending on the logs.
Might be worth checking out a different tool specifically designed for handling logs. I've written logs to elasticsearch using logstash in the past, perhaps it could also work for writing to a mongodb.
Created 08-04-2021 12:44 PM
Your approach sounds perfectly reasonable if you only plan to use native nifi tools. I didn't fully understand what kind of filtering you meant, but simply reading the logs with the TailFile processor and sending them to mongo with the PutMongo processor sounds like it would work for your use-case.
Created 08-04-2021 10:43 PM
@Green_ Filtering means I may need to ignore some INFO level logs and consider only DEBUG or ERROR level logs... and I dont have to be using native nifi processors only.. but right way of doing is importtant.
Please suggest if you see an other way
Created 08-04-2021 11:08 PM
Filtering like that in nifi could work though it might be a bit resource intensive depending on the logs.
Might be worth checking out a different tool specifically designed for handling logs. I've written logs to elasticsearch using logstash in the past, perhaps it could also work for writing to a mongodb.
Created 08-08-2021 11:51 PM
@Green_ - Can I have a custom appender configured in logback.xml to collect logs and put that in MongoDB ? would that be possible with nifi logs ?
Created on 08-10-2021 02:11 PM - edited 08-10-2021 02:12 PM
I have found this article by Pierre V. Where he goes into deeper detail about the logback.xml file. He mentions something that might be relevant to what you're looking for - the following two passages are what caught my eye:
```
"We can also define new appenders in the log configuration file and change it according to our needs. In particular, we could be interested by the SMTP Appender that can send logs via emails based on quite a large set of conditions. Full documentation here."
"Obviously you can also configure this configuration file so that NiFi log files integrate with your existing systems. An idea could be to configure a Syslog appender to also redirect the logs to an external system."
```
I myself have never done something like this, but it sounds like a step in the right direction for directly writing logs from nifi to mongo.