feat: added loki streams processing at POST /loki/push #94
+1,996
−318
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Split Loki Push Requests based on labels/structured metadata
This PR adds a new subpath to
POST /loki/pushthat accepts Loki Ingester Push.It also splits the streams of logs via their labels or structured metadata.
A new configuration option
target_lokican be used to configure the Loki endpoint to send the streams to.The new subpath has its own metrics (named
streamsinstead oftimeseries).I tried to keep the common code within processor.go but needed to split the logic between logs and metrics. The old code can be found in processor_metrics_test.go and handler_metrics.go. The new files for logs are almost identical to the metrics counterpart except for the differing datatypes.
There is also a very minor performance improvement in https://github.com/MrWong99/cortex-tenant/blob/loki/handler_metrics.go#L228 as the old code iterated the outer loop over and over. It will now break on first match but to keep it compatible to the old code I reversed the
cfg.Tenant.LabelListafter it has been read.Sorry for the bigger Pull Request...
We faced the same issue with Label -> Header conversion with Grafana Loki.
I looked at the cortex-tenant code and it seemed straightforward to add this fuctionality, so I did.