The issue
I’m working on getting historical data into Loki. But when I enter some historical loglines (let’s say from 2021-12-09) into the DB, it does not show up immediately when I query it using eg logcli
.
After lots of fiddling, I’ve found that I can at least force it to show up by adding a final logline in the same stream with the data of now().
My setup
- Docker, running Loki latest (2.4.1), with Grafana as dash, and logcli (latest) for barebones querying.
- Linux Mint 20.2
How to reproduce
- Enter a couple of loglines with a timestamp sometime in the past (eg
2021-12-09T00:00:00.000000+00:00
), with the static label ‘application=hist_test’ - Verify with
logcli
that label 'hist_tes;t is available:logcli labels application
- See that no loglines are available:
logcli query '{application="hist_test"}' --since 200h
- Enter one more logline with timestamp from now (at the moment, that would be something like
2021-12-14T14:58:14.488133+00:00
) - Verify that this last logline is now available, but the older ones not yet:
logcli query '{application="hist_test"}' --since 200h
- Wait a couple of seconds (10? 20? 60? I don’t know yet).
- Verify that all loglines are now available:
logcli query '{application="hist_test"}' --since 200h
Repeated querying have shown me that sometime during the waiting period (step 6), the last logline disappears again, only to show up together with the older loglines.
home$ ./logcli query '{application="hist_test"}' --since 500h
2021-12-14T14:26:42+01:00 {} [INFO] this is my testing line
home$ ./logcli query '{application="hist_test"}' --since 500h
2021-12-14T14:26:42+01:00 {} [INFO] this is my testing line
home$ ./logcli query '{application="hist_test"}' --since 500h
home$ ./logcli query '{application="hist_test"}' --since 500h
home$ ./logcli query '{application="hist_test"}' --since 500h
<snip>
home$ ./logcli query '{application="hist_test"}' --since 500h
home$ ./logcli query '{application="hist_test"}' --since 500h
home$ ./logcli query '{application="hist_test"}' --since 500h
home$ ./logcli query '{application="hist_test"}' --since 500h
2021-12-14T14:26:42+01:00 {} [INFO] this is my testing line
2021-12-09T01:00:00+01:00 {} [INFO] 127.0.0.1:59640 - - [09/Dec/2021:00:00:00 +0000] "Historical log line"
I have the idea that this might have to do with max_chunk_size, max_chunk_age, out of order data, etc… But not sure yet. Anybody that can shed any light on this, please let me know.