blue-yonder / bonfire

A CLI Graylog Client with Follow Mode
BSD 3-Clause "New" or "Revised" License
72 stars 26 forks source link

Error running Bonfire #33

Closed pm9448 closed 2 years ago

pm9448 commented 3 years ago

Command: bonfire --host myhost --port 9000 --endpoint /api --stream "Linux Syslog" --username test --search-from "2021-07-07 00:00:00" --search-to "now" --output output_log.txt

Getting the following error: Traceback (most recent call last): File "/home/pm9448/.local/bin/bonfire", line 8, in sys.exit(run()) File "/home/pm9448/.local/lib/python3.6/site-packages/click/core.py", line 722, in call return self.main(args, kwargs) File "/home/pm9448/.local/lib/python3.6/site-packages/click/core.py", line 697, in main rv = self.invoke(ctx) File "/home/pm9448/.local/lib/python3.6/site-packages/click/core.py", line 895, in invoke return ctx.invoke(self.callback, ctx.params) File "/home/pm9448/.local/lib/python3.6/site-packages/click/core.py", line 535, in invoke return callback(args, **kwargs) File "/home/pm9448/.local/lib/python3.6/site-packages/bonfire/cli.py", line 199, in run run_logprint(gl_api, q, formatter, follow, interval, latency, output) File "/home/pm9448/.local/lib/python3.6/site-packages/bonfire/output.py", line 45, in run_logprint if isinstance(output, basestring): NameError: name 'basestring' is not defined

Any suggestions?

valentin-krasontovitsch commented 3 years ago

thanks for pointing this out!

seems like I missed some "basestring" comparisons when updating to python3 / removing the six package.

gonna try to fix and test, and let you know when to reinstall and try again.

valentin-krasontovitsch commented 3 years ago

just out of curiosity: it seems the responsible line only gets triggered when a file is supplied that the logs (bonfire's output) should be written to. Is that correct, are you trying to write logs to a file?

If that is so - I've been toying with the idea of scraping that option, as I don't think it's necessary to have. in my opinion, you can just redirect to a file using your good ol' linux redirects in the shell.

would that break things for you? are there use-cases where a shell redirection is not optimal / the "output to file" option of bonfire is important?

pm9448 commented 3 years ago

Yes I mistakenly used the -o option while trying to search for range instead of just limiting to a tail operation. bonfire --host 10.0.0.70 --port 9000 --endpoint /api --stream "Linux Syslog" --username bogus --search-from "2021-07-07 00:00:00" --search-to "now" --output output_log.txt

However, after realizing my mistake, I was able to get bonfire to pull data successfully. My issue has now changed, is there a way to include fields in the request? Such as source and message? I was hoping to prepend the fqdn (source) to the message.

pm9448 commented 3 years ago

By the way, this utility (Bonfire) has so much potential in light of the scarcity of other querying solutions to Graylog Open. Thank you for maintaining this utility! My need for this stems from having to regularly export logs for remote delivery. But I need the export process to be automated (cron, ansible, etc).

valentin-krasontovitsch commented 3 years ago

oh silly me just noticed that you posted your invocation 🤦‍♂️ anywho thanks for answering : )

right, cool, happy to hear that the issue got resolved and also glad that you caught this bug!

about the fields - you can indeed have graylog return more than just the message field. just use the -e option: if I remember correctly, you should be able to append

-e source -e message

and will get both source and message field for every log

thank you so much for saying that, i was kind of thinking that this might be a dead project without users 😅 if there's anything lacking in the tool for your purposes of automating things with ansible / cron, feel free to open another issue.

valentin-krasontovitsch commented 2 years ago

I'm gonna go ahead and close this issue, partly since I think I answered your qestion, and partly due to inactivty. Feel free to comment here if you still have (the same) problems, or open a new issue.