Loki disk space inflation

I have same problem with u. So I just want to make sure if Loki could fix these problems in recent version.

At first I delete chunk files by shell, by it cause high cpu used while deleting files. Sometimes it may show error log like ‘cant find file in /loki/chunks/fake/**’ as well.

And I check the code in Loki 2.5.0 named ‘DeleteChunks’:

func (c *store) DeleteChunk(ctx context.Context, from, through model.Time, userID, chunkID string, metric labels.Labels, partiallyDeletedInterval *model.Interval) error {
	metricName := metric.Get(model.MetricNameLabel)
	if metricName == "" {
		return ErrMetricNameLabelMissing
	}

	chunkWriteEntries, err := c.schema.GetWriteEntries(from, through, userID, metricName, metric, chunkID)
	if err != nil {
		return errors.Wrapf(err, "when getting index entries to delete for chunkID=%s", chunkID)
	}

	return c.deleteChunk(ctx, userID, chunkID, metric, chunkWriteEntries, partiallyDeletedInterval, func(chunk Chunk) error {
		return c.PutOne(ctx, chunk.From, chunk.Through, chunk)
	})
}

I think Loki only delete table information but not the chunk file.

Did u try some way to delete the chunk files?

1 Like