Download Logs from Loki

11/5/2020

I have a grafana Loki logs that's in my cluster. I am able to see my logs but as at the moment, the cluster is no longer in use and I would like to delete it but I still have some logs I would like to extract Loki and maybe store it locally on my system, or Azure bucket.

Is there a way to extract this logs and save locally or azure bucket. I used loki helm to setup my Loki, promethus any help is appreciated

-- King
azure
grafana
grafana-loki
kubernetes

1 Answer

4/15/2021

You could use logcli to connect to Loki. See this documentation.

Example command:

port-forward <my-loki-pod> 3100
logcli query '{ job="foo"}'  --limit=5000 --since=48h -o raw > mylog.txt
-- User12547645
Source: StackOverflow