Adding old logs to loki

We have old app-logs on our server that where there before we started using loki and grafana to visualise it. I was wondering that is there possibility to add older logs to grafana without creating any duplicates?

So we have log file named app.log that is now going to loki and now want to add old logs to this file without creating new filename or any duplicates?

Is there any way to too it?
Or possibly delete specific log streams?

You cannot write older log to a log stream that already has newer logs (a log stream defined as the logs with the same unique set of labels).

You can still write to the label filename = app.log, you just need to add another label to it to make it a different log stream from your currently log (say add a label old_log = true).

1 Like
  • Append old logs to the app.log carefully.
  • Use logcli to import old logs.
  • Use logcli to delete duplicates if necessary.

I managed to figure out how to delete logs. But now I need to import the old logs.

Old logs are on application server that has promtail to send them to Loki on different server. I tried emptying the app.log and then appending from old logs to it but no success.