Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…into sidecar-branch
  • Loading branch information
Sheikh-Abubaker committed Oct 15, 2024
2 parents 74c3c3c + 5d57a03 commit b0678f3
Show file tree
Hide file tree
Showing 272 changed files with 4,173 additions and 13,866 deletions.
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 clients/cmd/fluentd/docker/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
source 'https://rubygems.org'

gem 'fluentd', '1.15.3'
gem 'fluent-plugin-multi-format-parser', '~>1.0.0'
gem 'fluent-plugin-multi-format-parser', '~>1.1.0'
1 change: 0 additions & 1 deletion clients/pkg/promtail/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ type Config struct {

// UnmarshalYAML implements the yaml.Unmarshaler interface.
func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error {
*c = Config{}
// We want to set c to the defaults and then overwrite it with the input.
// To make unmarshal fill the plain data struct rather than calling UnmarshalYAML
// again, we have to hide it using a type indirection.
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".
Loading

0 comments on commit b0678f3

Please sign in to comment.