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

feat: aggregated metric volume queries #14412

Closed
wants to merge 23 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
93cc007
feat: aggregated metric volume queries
trevorwhitney Oct 2, 2024
c78c5fa
feat: add range support to agg metric volume queries
trevorwhitney Oct 7, 2024
55b0aa1
chore: lint and format
trevorwhitney Oct 7, 2024
4ea549a
chore: fix tests, add more requestion validation
trevorwhitney Oct 8, 2024
2135959
chore: Make metric for dequeued tasks in bloom-gateway a Histogram (#…
chaudum Oct 8, 2024
103e020
fix(storage/chunk/client/aws): have GetObject check for canceled cont…
rfratto Oct 8, 2024
d5ce63e
fix(kafka): Set namespace for Loki kafka metrics (#14426)
benclive Oct 8, 2024
0592591
docs: Updated Promtail to Alloy (#14404)
Jayclifford345 Oct 8, 2024
0ee464f
feat(kafka): Enable querier to optionally query partition ingesters (…
benclive Oct 9, 2024
7e589db
chore: Log errors when processing a download task fails (#14436)
chaudum Oct 9, 2024
35bca10
fix: Revert "fix(deps): update module github.com/shirou/gopsutil/v4 t…
trevorwhitney Oct 9, 2024
8963b0e
chore: Rename new querier flag to use dashes (#14438)
benclive Oct 9, 2024
964928d
chore(operator): Update build and runtime deps (#14416)
periklis Oct 9, 2024
4a4fe50
feat(Helm): Update Loki Helm chart for restricted environments (#14440)
davidham Oct 10, 2024
3d500b8
chore: Add new field to "stats-report" log line in bloom gateway (#14…
chaudum Oct 10, 2024
92bae79
docs: remove reference to Agent Flow (#14449)
JStickler Oct 10, 2024
8e94ee6
docs: Revise the LogQL Analyzer topic (#14374)
JStickler Oct 10, 2024
b4d2567
fix(ci): updated helm diff rendering workflow (#14424)
vlad-diachenko Oct 10, 2024
5dadb6d
docs: Update alloy-otel-logs.md to correct a typo (#13827)
wcall Oct 10, 2024
887db47
fix: level detection for warning level (#14444)
trevorwhitney Oct 10, 2024
edcd09a
ci: speciy golangci-lint build tags at runtime (#14456)
trevorwhitney Oct 10, 2024
f9213a2
fix: nix build, downgrade toolchain to go1.23.1 (#14442)
trevorwhitney Oct 10, 2024
9d29b15
fix: always do a range query
trevorwhitney Oct 10, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/jsonnetfile.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"subdir": "workflows"
}
},
"version": "d900569c04b53e02de6ef208fa77cba41ec5f709"
"version": "20aac53fcb06d378b1c1101c7e4dc989466eb4ff"
}
],
"legacyImports": true
Expand Down
4 changes: 2 additions & 2 deletions .github/jsonnetfile.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"subdir": "workflows"
}
},
"version": "d900569c04b53e02de6ef208fa77cba41ec5f709",
"sum": "+uAzU+b+aJtp3k+JX5mDxuh8LNY23+cHvUOwzCQ8CS8="
"version": "20aac53fcb06d378b1c1101c7e4dc989466eb4ff",
"sum": "bo355Fm9Gm1TU13MjlXGXgrCXo4CPr7aEeTvgNFYAl8="
}
],
"legacyImports": false
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
"pull_request": {}
"push":
"branches":
- "main"
- "main"
10 changes: 8 additions & 2 deletions .github/workflows/helm-loki-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
fi
helm dependency build
for file in scenarios/*.yaml; do
cat "$file"
echo "rendering scenario $(file)"
schenario_folder=${{ github.workspace }}/output/base/$(basename $file .yaml)
mkdir $schenario_folder
helm template loki-test-chart-name . -f $file --output-dir $schenario_folder
Expand All @@ -62,9 +62,15 @@ jobs:
- name: Render Helm chart for each scenario in the PR branch
run: |
cd ${{ github.workspace }}/pr/production/helm/loki
# Check if the scenarios folder exists
if [ ! -d "scenarios" ]; then
echo "PR looks outdated because PRs branch does not have the scenarios, copying them from the base branch."
cp -r ${{ github.workspace }}/base/production/helm/loki/scenarios ./scenarios
fi

helm dependency build
for file in scenarios/*.yaml; do
cat "$file"
echo "rendering scenario $(file)"
schenario_folder=${{ github.workspace }}/output/pr/$(basename $file .yaml)
mkdir $schenario_folder
helm template loki-test-chart-name . -f $file --output-dir $schenario_folder
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -430,4 +430,4 @@
"permissions":
"contents": "write"
"id-token": "write"
"pull-requests": "write"
"pull-requests": "write"
2 changes: 1 addition & 1 deletion .github/workflows/minor-release-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -828,4 +828,4 @@ name: "Prepare Minor Release PR from Weekly"
permissions:
contents: "write"
id-token: "write"
pull-requests: "write"
pull-requests: "write"
7 changes: 4 additions & 3 deletions .github/workflows/nix-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,30 @@ on:
pull_request:
paths:
- "flake.nix"
- "go.mod"
- "nix/**"
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v22
- uses: cachix/install-nix-action@v30
with:
nix_path: nixpkgs=channel:nixos-unstable
- run: nix run --print-build-logs .#lint
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v22
- uses: cachix/install-nix-action@v30
with:
nix_path: nixpkgs=channel:nixos-unstable
- run: nix run --print-build-logs .#test
packages:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v22
- uses: cachix/install-nix-action@v30
with:
nix_path: nixpkgs=channel:nixos-unstable
- run: nix build --print-build-logs .#promtail
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/operator-bundle.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
strategy:
fail-fast: false
matrix:
go: ['1.21']
go: ['1.22']
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/operator-scorecard.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
strategy:
fail-fast: false
matrix:
go: ['1.21']
go: ['1.22']
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v4
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
strategy:
fail-fast: false
matrix:
go: ['1.21']
go: ['1.22']
steps:
- name: Install make
run: sudo apt-get install make
Expand All @@ -38,7 +38,7 @@ jobs:
strategy:
fail-fast: false
matrix:
go: ['1.21']
go: ['1.22']
steps:
- name: Install make
run: sudo apt-get install make
Expand All @@ -51,8 +51,8 @@ jobs:
- name: Lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.54.2
args: --timeout=4m
version: v1.61.0
args: --timeout=5m
working-directory: ./operator
- name: Check prometheus rules
working-directory: ./operator
Expand All @@ -64,7 +64,7 @@ jobs:
strategy:
fail-fast: false
matrix:
go: ['1.21']
go: ['1.22']
steps:
- name: Install make
run: sudo apt-get install make
Expand All @@ -85,7 +85,7 @@ jobs:
strategy:
fail-fast: false
matrix:
go: ['1.21']
go: ['1.22']
steps:
- name: Install make
run: sudo apt-get install make
Expand All @@ -106,7 +106,7 @@ jobs:
strategy:
fail-fast: false
matrix:
go: ['1.21']
go: ['1.22']
steps:
- name: Install make
run: sudo apt-get install make
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/patch-release-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -828,4 +828,4 @@ name: "Prepare Patch Release PR"
permissions:
contents: "write"
id-token: "write"
pull-requests: "write"
pull-requests: "write"
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -219,4 +219,4 @@ name: "create release"
permissions:
contents: "write"
id-token: "write"
pull-requests: "write"
pull-requests: "write"
4 changes: 1 addition & 3 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@ run:

# list of build tags, all linters use it. Default is empty list.
build-tags:
- linux
- cgo
- promtail_journal_enabled
- integration

# output configuration options
output:
formats:
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ ifeq ($(BUILD_IN_CONTAINER),true)
else
go version
golangci-lint version
GO111MODULE=on golangci-lint run -v --timeout 15m
GO111MODULE=on golangci-lint run -v --timeout 15m --build-tags linux,promtail_journal_enabled
faillint -paths "sync/atomic=go.uber.org/atomic" ./...
endif

Expand Down
2 changes: 1 addition & 1 deletion docs/sources/get-started/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ To collect logs and view your log data generally involves the following steps:
- [Configuration reference](https://grafana.com/docs/loki/<LOKI_VERSION>/configure/)
- There are [examples](https://grafana.com/docs/loki/<LOKI_VERSION>/configure/examples/) for specific Object Storage providers that you can modify.
1. Deploy [Grafana Alloy](https://grafana.com/docs/alloy/latest/) to collect logs from your applications.
1. On Kubernetes, deploy the Grafana Flow using the Helm chart. Configure Grafana Alloy to scrape logs from your Kubernetes cluster, and add your Loki endpoint details. See the following section for an example Grafana Alloy configuration file.
1. On Kubernetes, deploy Grafana Alloy using the Helm chart. Configure Grafana Alloy to scrape logs from your Kubernetes cluster, and add your Loki endpoint details. See the following section for an example Grafana Alloy configuration file.
1. Add [labels](https://grafana.com/docs/loki/<LOKI_VERSION>/get-started/labels/) to your logs following our [best practices](https://grafana.com/docs/loki/<LOKI_VERSION>/get-started/labels/bp-labels/). Most Loki users start by adding labels which describe where the logs are coming from (region, cluster, environment, etc.).
1. Deploy [Grafana](https://grafana.com/docs/grafana/latest/setup-grafana/) or [Grafana Cloud](https://grafana.com/docs/grafana-cloud/quickstart/) and configure a [Loki data source](https://grafana.com/docs/grafana/latest/datasources/loki/configure-loki-data-source/).
1. Select the [Explore feature](https://grafana.com/docs/grafana/latest/explore/) in the Grafana main menu. To [view logs in Explore](https://grafana.com/docs/grafana/latest/explore/logs-integration/):
Expand Down
96 changes: 75 additions & 21 deletions docs/sources/query/analyzer.md
Original file line number Diff line number Diff line change
@@ -1,37 +1,49 @@
---
title: LogQL Analyzer
menuTitle: LogQL Analyzer
description: The LogQL Analyzer is an inline educational tool for experimenting with writing LogQL queries.
aliases:
title: Simple LogQL simulator
menuTitle: LogQL simulator
description: The LogQL simulator is an online educational tool for experimenting with writing simple LogQL queries.
aliases:
- ../logql/analyzer/
weight: 60
weight: 200
---


<link rel="stylesheet" href="../analyzer/style.css">
<script src="../analyzer/handlebars.js"></script>

# LogQL Analyzer
# Simple LogQL simulator

The LogQL simulator is an online tool that you can use to experiment with writing simple LogQL queries and seeing the results, without needing to run an instance of Loki.

A set of example log lines are included for each of the primary log parsers supported by Loki:

- [Logfmt](https://brandur.org/logfmt)
- [JSON](https://www.json.org/json-en.html)
- Unstructured text, which can be parsed with the Loki pattern or regex parsers

The [log stream selector](https://grafana.com/docs/loki/<LOKI_VERSION>/query/log_queries/#log-stream-selector) `{job="analyze"}` is shown as an example, and it remains fixed for all possible example queries in the simulator. A log stream is a set of logs which share the same labels. In LogQL, you use a log stream selector to determine which log streams to include in a query's results.

{{< admonition type="note" >}}
This is a very limited simulator, primarily for evaluating filters and parsers. If you want to practice writing more complex queries, such as metric queries, you can use the [Explore](https://grafana.com/docs/grafana/<GRAFANA_VERSION>/explore/logs-integration/) feature in Grafana.
{{< /admonition >}}

The LogQL Analyzer is an inline tool for experimenting with writing LogQL queries.
To use the LogQL simulator:

Chose the log line format with the radio buttons.
A set of example log lines are included for each format.
1. Select a log line format using the radio buttons.

Use the provided example log lines, or copy and paste your own log lines into the example log lines box.
1. You can use the provided example log lines, or copy and paste your own log lines into the example log lines box.

Use the provided example query, or enter your own query.
The [log stream selector]({{< relref "./log_queries#log-stream-selector" >}}) remains fixed for all possible example queries.
Modify the remainder of the log line and click on the **Run query** button
to run the entered query against the example log lines.
1. Use the provided example LogQL query, or enter your own query. The [log stream selector](https://grafana.com/docs/loki/<LOKI_VERSION>/query/log_queries/#log-stream-selector) remains fixed for all possible example queries. There are additional sample queries at the end of this topic.

The results output provides details for each example log line.
Clicking on a line in the results pane expands the details, showing why the line is or is not included in the query result set.
1. Click the **Run query** button to run the entered query against the example log lines.

The results output simulates how Loki would return results for your query. You can also click each line in the results pane to expand the details, which give an explanation for why the log line is or is not included in the query result set.

<main class="logql-analyzer">
<section class="logs-source panel-container">
<div class="logs-source__header">
<div class="examples">
<span>Log line format:</span>
<span>Log line format:</span>
<span class="example">
<input type="radio" class="example-select" name="example" id="logfmt-example" checked>
<label for="logfmt-example">logfmt</label>
Expand Down Expand Up @@ -92,7 +104,6 @@ Clicking on a line in the results pane expands the details, showing why the line
<span>Line {{inc @index}}</span>
</div>
</div>

{{#if this.log_result}}
<span {{#if this.filtered_out}}class="filtered-out"{{/if}}>
{{this.log_result}}
Expand Down Expand Up @@ -158,7 +169,7 @@ Clicking on a line in the results pane expands the details, showing why the line
{{/unless}}
{{#if this.filtered_out}}
<span class="important-text">the line has been filtered out on this stage</span>
{{/if}}
{{/if}}
</div>
</div>
{{#if added_labels}}
Expand Down Expand Up @@ -196,7 +207,7 @@ level=info ts=2022-03-23T11:55:45.221254326Z caller=loki.go:355 msg="Loki starte
</script>

<script type="text/plain" id="logfmt-example-query">
| logfmt | level = "info"
| logfmt | level = "info"
</script>

[//]: # (Json parser examples)
Expand All @@ -215,7 +226,6 @@ level=info ts=2022-03-23T11:55:45.221254326Z caller=loki.go:355 msg="Loki starte
| json | level="INFO" | line_format "{{.message}}"
</script>


[//]: # (Pattern parser examples)
<script type="text/plain" id="pattern-parser-example-logs">
238.46.18.83 - - [09/Jun/2022:14:13:44 -0700] "PUT /target/next-generation HTTP/2.0" 404 19042
Expand All @@ -235,4 +245,48 @@ level=info ts=2022-03-23T11:55:45.221254326Z caller=loki.go:355 msg="Loki starte

<script src="../analyzer/script.js"> </script>

## Additional sample queries

These are some additional sample queries that you can use in the LogQL simulator.

### Logfmt

```logql
| logfmt | level = "debug"
```

Parses logfmt-formatted logs and returns only log lines where the "level" field is equal to "debug".

```logql
| logfmt | msg="server listening on addresses"
```

Parses logfmt-formatted logs and returns only log lines with the message “server listening on address.”

### JSON

```logql
| json | level="INFO" | file="SpringApplication.java" | line_format `{{.class}}`
```

Parses JSON-formatted logs, filtering for lines where the 'level' field is "INFO" and the 'file field is "SpringApplication.java", then formats the line to return only the 'class' field.

```logql
|~ `(T|t)omcat`
```

Performs a regular expression filter for the string 'tomcat' or 'Tomcat', without using a parser.

### Unstructured text

```logql
| pattern "<_> - <_> <_> \"<method> <url> <protocol>\" <status> <_> <_> \"<_>\" <_>" | method="GET"
```

Parses unstructured logs with the pattern parser, filtering for lines where the HTTP method is "GET".

```logql
| pattern "<_> - <user> <_> \"<method> <url> <protocol>\" <status> <_> <_> \"<_>\" <_>" | user=~"kling.*"
```

Parses unstructured logs with the pattern parser, extracting the 'user' field, and filtering for lines where the user field starts with "kling".
2 changes: 1 addition & 1 deletion docs/sources/query/bp-query.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ menuTitle: Query best practices
description: Describes best practices for querying in Grafana Loki.
aliases:
- ../bp-query
weight: 700
weight: 100
---
# Query best practices

Expand Down
2 changes: 1 addition & 1 deletion docs/sources/query/ip.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ menuTItle:
description: Describes how LogQL supports matching IP addresses.
aliases:
- ../logql/ip/
weight: 40
weight: 600
---

# Matching IP addresses
Expand Down
Loading
Loading