Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Real-time JSON export #2696

Open
igorhrcek opened this issue Jul 26, 2024 · 3 comments
Open

Real-time JSON export #2696

igorhrcek opened this issue Jul 26, 2024 · 3 comments

Comments

@igorhrcek
Copy link

Hi!

Would it be possible to obtain a real-time JSON export? I am using a Prometheus for monitoring and I would like to pull JSON, that GoAccess already makes, convert it into Prometheus metrics and store within it to use for alerting and Grafana charts.

Now, there is option to export data into JSON format, and I've seen an example linked in Readme that provides JSON output, but I am unsure how to get it on my instance. I am currently running GoAccess like this:

goaccess access.log --log-format=COMBINED --real-time-html -o /var/www/userdata/web/public/public_html/report.html

Thank you!

@allinurl
Copy link
Owner

Great question! A few options come to mind: you could try reading from the named pipe under /tmp, though I’m not entirely sure if that would work. An easier method might be to use something like websocat to read directly from the WebSocket, for example, with websocat ws://your_goaccess_server:7890. You might even be able to do it with curl. It’s also possible to handle this with JavaScript if needed.

For a more direct approach, we’d need to tweak the real-time HTML output format and possibly add something like --real-time-json. However, I'm not sure where the output should be directed.

@igorhrcek
Copy link
Author

Having --real-time-json would be great even if it is redirected to a file. Alternatively, maybe you could register URL endpoints that would provide JSON/HTML/CSV output without a need to write to a file on disk?

@0bi-w6n-K3nobi
Copy link
Contributor

0bi-w6n-K3nobi commented Sep 23, 2024

Hi everybody.
Well, I see ... I think it's very weird write something like JSON at real-time into file on disk.
How to you read this? -- I.E. -- What is moment (in time) that JSON is complete and valid?
Remembering that, at time in time, it is rewrite from scratch !
So, I agree with @allinurl that be use websocket entry, or (in future) create specific entry-point (or API) for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants