Sometimes Loki and Promtail would be rebuild in k8s for updating config or collect old logs, and I find that many directory are under /loki/chunks/fake.
I know that ‘fake’ was the orgID configuration, and I want to know what is the files under the path ‘/loki/chunks/fake’?
The index is the index of log labels, and the chunk are the actual logs grouped in specific set of labels. When reading logs loki first narrow down the chunk files to read by search for relevant labels in the index file, therefore the index file is essentially how you find what chunks to read.
If you have an error of missing chunk file that means either the chunk was removed outside of Loki, or some sort of misconfiguration that resulted in incorrect storage of files.
appearance
500 Internal Server Error: [open /loki/chunks/fake/c7bcc606af799e49/MThmNTBmNjYwOWU6MThmNTI3NDM1M2I6MjkxNDIwZGY=: no such file or directory
]
process
1.I rebuilded Loki on May 8th
2.When I query the logs after May 8th, everything is nice. When I query logs before May 8th, Loki show me the error response.
3.I have been sure that the ‘/c7bcc606af799e49’ path does not exist.
4.I havn’t changed the static label in promtail, and I can see that by requesting loki api.
What confuses me is that:
1.If Loki know to find the chunk file ‘/loki/chunks/fake/c7bcc606af799e49/MThmNTBmNjYwOWU6MThmNTI3NDM1M2I6MjkxNDIwZGY=’ , it means the index file are providing services normally.
2.I have seen that chunks files were saved under the path ‘/loki/chunks/fake’, how is the directory ‘/c7bcc606af799e49’ produced?
3.I don’t delete any chunks files or remove them, and I,m sure about that the nobhub path is same before I rebuilded Loki, and I can find the chunks files. It’s that ‘/c7bcc606af799e49’ was calculate by some way or configuration?
The path where the chunks are stored are calculated when flushing. If I remember correctly they are hashes of the chunks being written.
One scenario is if when you rebuilt your Loki cluster and you did not power off your previous cluster cleanly you could have some chunks not fully flushed.
It means the content about the log? Or calculated by labels?
That’s so many directoried under /loki/chunks/fake, I really want to sure the rule about calculating the hash value, but I can’t find these in the program code.
And Loki put chunk in this way:
func (o *Client) PutChunks(ctx context.Context, chunks chunk.Chunk) error {
var (
chunkKeys string
chunkBufs byte
)
for i := range chunks {
...
for i := range chunkBufs {
go func(i int) {
incomingErrors <- o.store.PutObject(ctx, chunkKeys[i], bytes.NewReader(chunkBufs[i]))
}(i)
}
...