Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add function label_replace. #3047

Merged
merged 2 commits into from
Dec 8, 2020
Merged

Conversation

cyriltovena
Copy link
Contributor

You might be wondering why do we need label_replace when we already have label_format.

Well for two reasons:

  1. It's nice to have something similar to Prometheus, so users building metric queries will feel right at home.
  2. Interestingly, they are quite different in how they execute. label_format executes for every log line, however label_replace execute for every sample. Since you aggregate log lines into samples then label_replace is way more efficient at scale.

Signed-off-by: Cyril Tovena cyril.tovena@gmail.com

You might be wondering why do we need label_replace when we already have label_format.
Well for two reasons:

1. It's nice to have something similar to Prometheus, so users building metric queries will feel right at home.
2. Interestingly, they are quite different in how they execute. label_format executes for every log line, however label_replace execute for every sample. Since you aggregate log lines into sample then label_replace is way more efficient at scale.

Signed-off-by: Cyril Tovena <cyril.tovena@gmail.com>
@cyriltovena
Copy link
Contributor Author

Fixes #2883

Signed-off-by: Cyril Tovena <cyril.tovena@gmail.com>
@codecov-io
Copy link

Codecov Report

Merging #3047 (5d966a9) into master (4e7a123) will increase coverage by 0.06%.
The diff coverage is 91.52%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3047      +/-   ##
==========================================
+ Coverage   62.78%   62.85%   +0.06%     
==========================================
  Files         186      186              
  Lines       15847    15906      +59     
==========================================
+ Hits         9949     9997      +48     
- Misses       4974     4983       +9     
- Partials      924      926       +2     
Impacted Files Coverage Δ
pkg/logql/lex.go 90.90% <ø> (ø)
pkg/logql/ast.go 86.48% <88.88%> (+0.18%) ⬆️
pkg/logql/evaluator.go 91.77% <93.75%> (+0.12%) ⬆️
pkg/querier/queryrange/limits.go 91.66% <0.00%> (-4.17%) ⬇️
pkg/querier/queryrange/downstreamer.go 95.29% <0.00%> (-2.36%) ⬇️
pkg/storage/stores/shipper/compactor/table.go 60.27% <0.00%> (-1.37%) ⬇️

@cyriltovena cyriltovena merged commit 3f0800d into grafana:master Dec 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants