Export Nagios Log Server data to CSV

This support forum board is for support questions relating to Nagios Log Server, our solution for managing and monitoring critical log data.
Locked
Sampath.Basireddy
Posts: 252
Joined: Wed Dec 14, 2016 12:30 pm

Export Nagios Log Server data to CSV

Post by Sampath.Basireddy »

Is there any way to export Nagios Log Server data to CSV?

I know there is an option "Export as CSV" for exporting, but if I want to export data for longer period of times or hundreds of thousands of logs, what are my options?

I tried "Export as CSV" to export upto 5000 logs, but anything more than that doesn't seem to be even loading completely.

Any help is greatly appreciated.
User avatar
cdienger
Support Tech
Posts: 5045
Joined: Tue Feb 07, 2017 11:26 am

Re: Export Nagios Log Server data to CSV

Post by cdienger »

As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Sampath.Basireddy
Posts: 252
Joined: Wed Dec 14, 2016 12:30 pm

Re: Export Nagios Log Server data to CSV

Post by Sampath.Basireddy »

Thank You @ cdienger.

I tried the java tool, but when I use it with "-query" it fails with below error message.

Code: Select all

com.google.gson.stream.MalformedJsonException: Expected name at line 1 column 2 path $.
Malformed JSON detected in query. Please check your JSON.
Please excuse me if it is a dumb question - Am assuming query in the sense, the "raw" or "services" part from json file that is exported from queries in NLS?

Here is how I ran it:

Code: Select all

java -jar nlsexport.jar -host=localhost -date_start=2019.02.26 -date_end=2019.02.26 -output_path=/home/sampath/ -output_format=csv -query='{\"query\":{\"list\":{\"0\":{\"query\":\"host:\\\"192.168.0.1\\\"\",\"id\":0,\"color\":\"#03a645\",\"alias\":\"\",\"pin\":false,\"type\":\"lucene\",\"enable\":true}},\"ids\":[0]},\"filter\":{\"list\":{\"0\":{\"from\":\"now-1d\",\"to\":\"now\",\"field\":\"@timestamp\",\"type\":\"time\",\"active\":true,\"id\":0,\"mandate\":\"must\"},\"1\":{\"type\":\"field\",\"field\":\"program\",\"query\":\"\\\"ohs-access_log\\\"\",\"mandate\":\"must\",\"active\":true,\"alias\":\"\",\"id\":1}},\"ids\":[0,1]}}'
User avatar
cdienger
Support Tech
Posts: 5045
Joined: Tue Feb 07, 2017 11:26 am

Re: Export Nagios Log Server data to CSV

Post by cdienger »

The exported version contains some escape characters that need to be removed to make it valid json. Try:

Code: Select all

java -jar nlsexport.jar -host=localhost -date_start=2019.02.26 -date_end=2019.02.26 -output_path=/home/sampath/ -output_format=csv -query='{"query":{"list":{"0":{"query":"host:192.168.0.1","id":0,"color":"#03a645","alias":"","pin":false,"type":"lucene","enable":true}},"ids":[0]},"filter":{"list":{"0":{"from":"now-1d","to":"now","field":"@timestamp","type":"time","active":true,"id":0,"mandate":"must"},"1":{"type":"field","field":"program","query":"ohs-access_log","mandate":"must","active":true,"alias":"","id":1}},"ids":[0,1]}}'
https://jsonlint.com/ can be used to validate the json.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Sampath.Basireddy
Posts: 252
Joined: Wed Dec 14, 2016 12:30 pm

Re: Export Nagios Log Server data to CSV

Post by Sampath.Basireddy »

No luck, it is throwing error:

Code: Select all

[root@brnagiosls1 sampath]# java -jar nlsexport.jar -host=localhost -date_start=2019.03.04 -date_end=2019.03.04 -output_path=/home/sampath/ -output_format=csv -query='{"query":{"list":{"0":{"query":"host:192.168.0.1","id":0,"color":"#03a645","alias":"","pin":false,"type":"lucene","enable":true}},"ids":[0]},"filter":{"list":{"0":{"from":"now-1d","to":"now","field":"@timestamp","type":"time","active":true,"id":0,"mandate":"must"},"1":{"type":"field","field":"program","query":"ohs-access_log","mandate":"must","active":true,"alias":"","id":1}},"ids":[0,1]}}'


Creating directory /home/sampath/nls-export-1551840370649/
[1551840370937]  Writing data from [logstash-2019.03.04/syslog_json].
Exception in thread "main" java.lang.NullPointerException
	at ElasticSearch.startIndexScroll(ElasticSearch.java:252)
	at Main.doit(Main.java:123)
	at Main.<init>(Main.java:37)
	at run.doMain(run.java:97)
	at run.main(run.java:50)
[root@brnagiosls1 sampath]#
User avatar
cdienger
Support Tech
Posts: 5045
Joined: Tue Feb 07, 2017 11:26 am

Re: Export Nagios Log Server data to CSV

Post by cdienger »

It looks like the 'services' query will result in a 400 bad request message from the elasticsearch service. Use the raw query instead making sure to remove the backslashes first.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Locked