Querying logs crashes browser

I’ve implemented central monitoring on my EC2 instance (c5.xlarge) using Grafana and Loki. Approximately 10 other EC2 instances are configured to send logs to it using Promtail. In the Loki configuration, I’ve set log retentions for up to 1 year.

However, I’m facing an issue where, when I set the time range to more than 1 month, it causes my browser to crash, and the EC2 CPU usage spikes to 100% during queries. This seems to be particularly problematic for system logs and a couple of application logs, which can generate up to 100,000 lines of logs in about an hour, though not consistently – sporadically.

I’m uncertain whether upgrading to a more powerful EC2 instance type would resolve this issue, or if it’s a matter of optimizing the Loki configuration. Any advice on how to address this performance challenge would be greatly appreciated.

Problem is that it looks like you are loading content of log lines into browser. Each log line needs memory, cpu, … Browser will crash, when there is too much log lines.
You don’t need to see content of log lines usually - so use only a metric query and draw log line count on the graph.
But users want to see log content sometimes - for that use another panel where you will limit number of log lines (e.g. 100 only).

User still see log count and it can explore them. E.g. there was unusuall log count peak at 21:30, so user will zoom to that period and can explore content of 100 log lines in the panel below:

So users can select any time range and browser will still load only constant number of log lines → that won’t overload a browser.