Attempt to Export Logs from Loki, query_range 413 Error

Wonder if anyone has tried to write something to export large quantity of logs from Loki. I realize you can download logs from Grafana Explorer, but it’s limited and certainly won’t work if you want to export logs spanning days.

What I am currently attempting to do is write a python script that sends API calls to /query_range endpoint on a set time frame (for example, divide 24 hours into 48 30-minute blocks / queries). Problems I’ve run into:

  1. It returns with 413 if limit is set too high (anything above 30,000) on the API string. In Loki logs we simply see context canceled. We configure max_entries_limit_per_query to be 1000000, but doesn’t seem to be honored here.

  2. Somewhat related to #1. Because Loki api doesn’t have paging, it’s hard to gauge exactly how refined the time window needs to be. Combined with the fact we can’t get API to run with any sort of reasonably large limit, it really looks like it’ll be a very inefficient process.

Any input would be appreciated.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.