Skip to content

Commit

Permalink
Merge branch 'main' into log-4700-operator
Browse files Browse the repository at this point in the history
  • Loading branch information
periklis authored Dec 11, 2023
2 parents 95a4ced + 8dde7b9 commit a9173dd
Show file tree
Hide file tree
Showing 190 changed files with 10,709 additions and 3,718 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

##### Enhancements

* [11319](https://github.com/grafana/loki/pull/11319) **someStrangerFromTheAbyss**: Helm: Add extraContainers to the write pods.
* [11243](https://github.com/grafana/loki/pull/11243) **kavirajk**: Inflight-logging: Add extra metadata to inflight requests logging.
* [11110](https://github.com/grafana/loki/pull/11003) **MichelHollands**: Change the default of the `metrics-namespace` flag to 'loki'.
* [11086](https://github.com/grafana/loki/pull/11086) **kandrew5**: Helm: Allow topologySpreadConstraints
Expand Down Expand Up @@ -37,6 +38,8 @@
* [10727](https://github.com/grafana/loki/pull/10727) **sandeepsukhani** Native otlp ingestion support
* [11051](https://github.com/grafana/loki/pull/11051) Refactor to not use global logger in modules
* [10956](https://github.com/grafana/loki/pull/10956) **jeschkies** do not wrap requests but send pure Protobuf from frontend v2 via scheduler to querier when `-frontend.encoding=protobuf`.
* [10417](https://github.com/grafana/loki/pull/10417) **jeschkies** shard `quantile_over_time` range queries using probabilistic data structures.
* [11284](https://github.com/grafana/loki/pull/11284) **ashwanthgoli** Config: Adds `frontend.max-query-capacity` to tune per-tenant query capacity.

##### Fixes
* [11074](https://github.com/grafana/loki/pull/11074) **hainenber** Fix panic in lambda-promtail due to mishandling of empty DROP_LABELS env var.
Expand Down Expand Up @@ -83,6 +86,8 @@

#### Jsonnet

* [11312](https://github.com/grafana/loki/pull/11312) **sentoz**: Loki ksonnet: Do not generate configMap for consul if you are using memberlist

* [11020](https://github.com/grafana/loki/pull/11020) **ashwanthgoli**: Loki ksonnet: Do not generate table-manager manifests if shipper store is in-use.

* [10784](https://github.com/grafana/loki/pull/10894) **slim-bean** Update index gateway client to use a headless service.
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ PLUGIN_ARCH ?=
define build-rootfs
rm -rf clients/cmd/docker-driver/rootfs || true
mkdir clients/cmd/docker-driver/rootfs
docker build -t rootfsimage -f clients/cmd/docker-driver/Dockerfile .
docker build --build-arg $(BUILD_IMAGE) -t rootfsimage -f clients/cmd/docker-driver/Dockerfile .

ID=$$(docker create rootfsimage true) && \
(docker export $$ID | tar -x -C clients/cmd/docker-driver/rootfs) && \
Expand Down
2 changes: 1 addition & 1 deletion clients/cmd/docker-driver/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG BUILD_IMAGE=grafana/loki-build-image:0.29.3
ARG BUILD_IMAGE=grafana/loki-build-image:0.31.2
# Directories in this file are referenced from the root of the project not this folder
# This file is intended to be called from the root like so:
# docker build -t grafana/loki -f cmd/loki/Dockerfile .
Expand Down
2 changes: 2 additions & 0 deletions clients/cmd/fluent-bit/loki_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build cgo

package main

import (
Expand Down
2 changes: 1 addition & 1 deletion clients/cmd/fluent-bit/out_grafana_loki.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func FLBPluginInit(ctx unsafe.Pointer) int {

level.Info(logger).Log("[flb-go]", "Starting fluent-bit-go-loki", "version", version.Info())
paramLogger := log.With(logger, "[flb-go]", "provided parameter")
level.Info(paramLogger).Log("URL", conf.clientConfig.URL)
level.Info(paramLogger).Log("URL", conf.clientConfig.URL.Redacted())
level.Info(paramLogger).Log("TenantID", conf.clientConfig.TenantID)
level.Info(paramLogger).Log("BatchWait", fmt.Sprintf("%.3fs", conf.clientConfig.BatchWait.Seconds()))
level.Info(paramLogger).Log("BatchSize", conf.clientConfig.BatchSize)
Expand Down
12 changes: 9 additions & 3 deletions docs/sources/alert/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,16 +202,22 @@ Another great use case is alerting on high cardinality sources. These are things

Creating these alerts in LogQL is attractive because these metrics can be extracted at _query time_, meaning we don't suffer the cardinality explosion in our metrics store.

> **Note** As an example, we can use LogQL v2 to help Loki to monitor _itself_, alerting us when specific tenants have queries that take longer than 10s to complete! To do so, we'd use the following query: `sum by (org_id) (rate({job="loki-prod/query-frontend"} |= "metrics.go" | logfmt | duration > 10s [1m]))`
{{% admonition type="note" %}}
As an example, we can use LogQL v2 to help Loki to monitor _itself_, alerting us when specific tenants have queries that take longer than 10s to complete! To do so, we'd use the following query: `sum by (org_id) (rate({job="loki-prod/query-frontend"} |= "metrics.go" | logfmt | duration > 10s [1m])
{{% /admonition %}}`.

## Interacting with the Ruler

### Cortextool
Because the rule files are identical to Prometheus rule files, we can interact with the Loki Ruler via [`cortextool`](https://github.com/grafana/cortex-tools#rules). The CLI is in early development, but it works with both Loki and Cortex. Pass the `--backend=loki` option when using it with Loki.

> **Note:** Not all commands in cortextool currently support Loki.
{{% admonition type="note" %}}
Not all commands in cortextool currently support Loki.
{{% /admonition %}}

> **Note:** cortextool was intended to run against multi-tenant Loki, commands need an `--id=` flag set to the Loki instance ID or set the environment variable `CORTEX_TENANT_ID`. If Loki is running in single tenant mode, the required ID is `fake` (yes we know this might seem alarming but it's totally fine, no it can't be changed)
{{% admonition type="note" %}}
cortextool was intended to run against multi-tenant Loki, commands need an `--id=` flag set to the Loki instance ID or set the environment variable `CORTEX_TENANT_ID`. If Loki is running in single tenant mode, the required ID is `fake`.
{{% /admonition %}}

An example workflow is included below:

Expand Down
41 changes: 41 additions & 0 deletions docs/sources/configure/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,11 @@ results_cache:
# CLI flag: -querier.parallelise-shardable-queries
[parallelise_shardable_queries: <boolean> | default = true]
# A comma-separated list of LogQL vector and range aggregations that should be
# sharded
# CLI flag: -querier.shard-aggregations
[shard_aggregations: <string> | default = ""]
# Cache index stats query results.
# CLI flag: -querier.cache-index-stats-results
[cache_index_stats_results: <boolean> | default = false]
Expand Down Expand Up @@ -1838,6 +1843,21 @@ client:
# CLI flag: -bloom-gateway-client.log-gateway-requests
[log_gateway_requests: <boolean> | default = false]
results_cache:
# The cache block configures the cache backend.
# The CLI flags prefix for this block configuration is:
# bloom-gateway-client.cache
[cache: <cache_config>]
# Use compression in cache. The default is an empty value '', which disables
# compression. Supported values are: 'snappy' and ''.
# CLI flag: -bloom-gateway-client.cache.compression
[compression: <string> | default = ""]
# Flag to control whether to cache bloom gateway client requests/responses.
# CLI flag: -bloom-gateway-client.cache_results
[cache_results: <boolean> | default = false]
# Number of workers to use for filtering chunks concurrently.
# CLI flag: -bloom-gateway.worker-concurrency
[worker_concurrency: <int> | default = 4]
Expand Down Expand Up @@ -2768,6 +2788,22 @@ The `limits_config` block configures global and per-tenant limits in Loki.
# CLI flag: -frontend.max-queriers-per-tenant
[max_queriers_per_tenant: <int> | default = 0]

# How much of the available query capacity ("querier" components in distributed
# mode, "read" components in SSD mode) can be used by a single tenant. Allowed
# values are 0.0 to 1.0. For example, setting this to 0.5 would allow a tenant
# to use half of the available queriers for processing the query workload. If
# set to 0, query capacity is determined by frontend.max-queriers-per-tenant.
# When both frontend.max-queriers-per-tenant and frontend.max-query-capacity are
# configured, smaller value of the resulting querier replica count is
# considered: min(frontend.max-queriers-per-tenant, ceil(querier_replicas *
# frontend.max-query-capacity)). *All* queriers will handle requests for the
# tenant if neither limits are applied. This option only works with queriers
# connecting to the query-frontend / query-scheduler, not when using downstream
# URL. Use this feature in a multi-tenant setup where you need to limit query
# capacity for certain tenants.
# CLI flag: -frontend.max-query-capacity
[max_query_capacity: <float> | default = 0]

# Number of days of index to be kept always downloaded for queries. Applies only
# to per user index in boltdb-shipper index store. 0 to disable.
# CLI flag: -store.query-ready-index-num-days
Expand Down Expand Up @@ -3012,6 +3048,10 @@ shard_streams:
# CLI flag: -bloom-gateway.blocks-downloading-parallelism
[bloom_gateway_blocks_downloading_parallelism: <int> | default = 50]

# Interval for computing the cache key in the Bloom Gateway.
# CLI flag: -bloom-gateway.cache-key-interval
[bloom_gateway_cache_key_interval: <duration> | default = 15m]

# Allow user to send structured metadata in push payload.
# CLI flag: -validation.allow-structured-metadata
[allow_structured_metadata: <boolean> | default = false]
Expand Down Expand Up @@ -4217,6 +4257,7 @@ The TLS configuration.

The cache block configures the cache backend. The supported CLI flags `<prefix>` used to reference this configuration block are:

- `bloom-gateway-client.cache`
- `frontend`
- `frontend.index-stats-results-cache`
- `frontend.volume-results-cache`
Expand Down
2 changes: 1 addition & 1 deletion docs/sources/get-started/labels/structured-metadata.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ description: Attaching metadata to logs.
# What is structured metadata

{{% admonition type="warning" %}}
Structured metadata is an experimental feature and is subject to change in future releases of Grafana Loki. This feature is not yet available for Cloud Logs users.
Structured metadata is an experimental feature and is subject to change in future releases of Grafana Loki.
{{% /admonition %}}

{{% admonition type="warning" %}}
Expand Down
7 changes: 5 additions & 2 deletions docs/sources/operations/automatic-stream-sharding.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,17 @@ per-stream rate limit.
shard_streams:
enabled: true
```
2. Optionally lower the `desired_rate` in bytes if you find that the system is still hitting the `per_stream_rate_limit`:
1. Optionally lower the `desired_rate` in bytes if you find that the system is still hitting the `per_stream_rate_limit`:
```yaml
limits_config:
shard_streams:
enabled: true
desired_rate: 2097152 #2MiB
```
3. Optionally enable `logging_enabled` for debugging stream sharding. **Note**: this may affect the ingestion performance of Loki.
1. Optionally enable `logging_enabled` for debugging stream sharding.
{{% admonition type="note" %}}
This may affect the ingestion performance of Loki.
{{% /admonition %}}
```yaml
limits_config:
shard_streams:
Expand Down
2 changes: 1 addition & 1 deletion docs/sources/operations/loki-canary/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ artificial log lines,
such that Loki Canary forms information about the performance of the Loki cluster.
The information is available as Prometheus time series metrics.

{{< figure max-width="75%" src="./loki-canary-block.png">}}
{{< figure max-width="75%" src="./loki-canary-block.png" alt="Loki canary">}}

Loki Canary writes a log to a file and stores the timestamp in an internal
array. The contents look something like this:
Expand Down
4 changes: 3 additions & 1 deletion docs/sources/operations/scalability.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ this will result in far lower `ruler` resource usage because the majority of the
The LogQL queries coming from the `ruler` will be executed against the given `query-frontend` service.
Requests will be load-balanced across all `query-frontend` IPs if the `dns:///` prefix is used.

> **Note:** Queries that fail to execute are _not_ retried.
{{% admonition type="note" %}}
Queries that fail to execute are _not_ retried.
{{% /admonition %}}

### Limits and Observability

Expand Down
4 changes: 3 additions & 1 deletion docs/sources/operations/storage/logs-deletion.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ Log entry deletion relies on configuration of the custom logs retention workflow
Enable log entry deletion by setting `retention_enabled` to true in the compactor's configuration and setting and `deletion_mode` to `filter-only` or `filter-and-delete` in the runtime config.
`delete_request_store` also needs to be configured when retention is enabled to process delete requests, this determines the storage bucket that stores the delete requests.

> **Warning:** Be very careful when enabling retention. It is strongly recommended that you also enable versioning on your objects in object storage to allow you to recover from accidental misconfiguration of a retention setting. If you want to enable deletion but not not want to enforce retention, configure the `retention_period` setting with a value of `0s`.
{{% admonition type="warning" %}}
Be very careful when enabling retention. It is strongly recommended that you also enable versioning on your objects in object storage to allow you to recover from accidental misconfiguration of a retention setting. If you want to enable deletion but not not want to enforce retention, configure the `retention_period` setting with a value of `0s`.
{{% /admonition %}}

Because it is a runtime configuration, `deletion_mode` can be set per-tenant, if desired.

Expand Down
2 changes: 1 addition & 1 deletion docs/sources/query/template_functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,7 @@ Examples:

```template
{{ default "-" "" }} // output: -
{{ default "" "foo" }} // output: foo
{{ default "-" "foo" }} // output: foo
```

Example of a query to print a `-` if the `http_request_headers_x_forwarded_for` label is empty:
Expand Down
9 changes: 7 additions & 2 deletions docs/sources/reference/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ weight: 100
Loki exposes an HTTP API for pushing, querying, and tailing log data, as well
as for viewing and managing cluster information.

**Note that authorization is not part of the Loki API.**
{{% admonition type="note" %}}
Note that authorization is not part of the Loki API.
Authorization needs to be done separately, for example, using an open-source load-balancer such as NGINX.
{{% /admonition %}}

## Endpoints

Expand Down Expand Up @@ -1291,7 +1293,10 @@ DELETE /loki/api/v1/delete
Query parameters:

- `request_id=<request_id>`: Identifies the delete request to cancel; IDs are found using the `delete` endpoint.
- `force=<boolean>`: When the `force` query parameter is true, partially completed delete requests will be canceled. NOTE: some data from the request may still be deleted and the deleted request will be listed as 'processed'
- `force=<boolean>`: When the `force` query parameter is true, partially completed delete requests will be canceled.
{{% admonition type="note" %}}
some data from the request may still be deleted and the deleted request will be listed as 'processed'.
{{% /admonition %}}

A 204 response indicates success.

Expand Down
4 changes: 3 additions & 1 deletion docs/sources/release-notes/cadence.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ naming scheme: `MAJOR`.`MINOR`.`PATCH`.
- `MINOR` (roughly once a quarter): these releases include new features which generally do not break backwards-compatibility, but from time to time we might introduce _minor_ breaking changes, and we will specify these in our upgrade docs.
- `PATCH` (roughly once or twice a month): these releases include bug and security fixes which do not break backwards-compatibility.

> **NOTE:** While our naming scheme resembles [Semantic Versioning](https://semver.org/), at this time we do not strictly follow its
{{% admonition type="note" %}}
While our naming scheme resembles [Semantic Versioning](https://semver.org/), at this time we do not strictly follow its
guidelines to the letter. Our goal is to provide regular releases that are as stable as possible, and we take backwards-compatibility
seriously. As with any software, always read the [release notes](/release-notes) and the [upgrade guide](/upgrading) whenever
choosing a new version of Loki to install.
{{% /admonition %}}

New releases are based of a [weekly release](#weekly-releases) which we have vetted for stability over a number of weeks.

Expand Down
4 changes: 2 additions & 2 deletions docs/sources/release-notes/v2-3.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ List of security fixes for 2.3.x.

* [4020](https://github.com/grafana/loki/pull/4020) **simonswine**: Restrict path segments in TenantIDs (CVE-2021-36156 CVE-2021-36157).

**Note** Exploitation of this vulnerability requires the ability for an attacker to craft and send directly to Loki an `X-Scope-OrgID` header, end users should not have the ability to create and send this header directly to Loki as it controls access to tenants and is important to control setting of this header for proper tenant isolation and security. We always recommend having a proxy or gateway be responsible for setting the `X-Scope-OrgID`.

{{% admonition type="note" %}}
Exploitation of this vulnerability requires the ability for an attacker to craft and send directly to Loki an `X-Scope-OrgID` header, end users should not have the ability to create and send this header directly to Loki as it controls access to tenants and is important to control setting of this header for proper tenant isolation and security. We always recommend having a proxy or gateway be responsible for setting the `X-Scope-OrgID`.{{% /admonition %}}

## Bug fixes

Expand Down
24 changes: 14 additions & 10 deletions docs/sources/send-data/docker-driver/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,11 @@ docker run --log-driver=loki \
--log-opt loki-batch-size=400 \
grafana/grafana
```

> **Note**: The Loki logging driver still uses the json-log driver in combination with sending logs to Loki, this is mainly useful to keep the `docker logs` command working.
> You can adjust file size and rotation using the respective log option `max-size` and `max-file`. Keep in mind that default values for these options are not taken from json-log configuration.
> You can deactivate this behavior by setting the log option `no-file` to true.
{{% admonition type="note" %}}
The Loki logging driver still uses the json-log driver in combination with sending logs to Loki, this is mainly useful to keep the `docker logs` command working.
You can adjust file size and rotation using the respective log option `max-size` and `max-file`. Keep in mind that default values for these options are not taken from json-log configuration.
You can deactivate this behavior by setting the log option `no-file` to true.
{{% /admonition %}}

## Change the default logging driver

Expand Down Expand Up @@ -64,10 +65,11 @@ Options for the logging driver can also be configured with `log-opts` in the
}
}
```

> **Note**: log-opt configuration options in daemon.json must be provided as
{{% admonition type="note" %}}
log-opt configuration options in daemon.json must be provided as
> strings. Boolean and numeric values (such as the value for loki-batch-size in
> the example above) must therefore be enclosed in quotes (`"`).
{{% /admonition %}}

After changing `daemon.json`, restart the Docker daemon for the changes to take
effect. All **newly created** containers from that host will then send logs to Loki via the driver.
Expand Down Expand Up @@ -102,9 +104,9 @@ docker-compose -f docker-compose.yaml up

Once deployed, the Grafana service will send its logs to Loki.

> **Note**: stack name and service name for each swarm service and project name
> and service name for each compose service are automatically discovered and
> sent as Loki labels, this way you can filter by them in Grafana.
{{% admonition type="note" %}}
Stack name and service name for each swarm service and project name and service name for each compose service are automatically discovered and sent as Loki labels, this way you can filter by them in Grafana.
{{% /admonition %}}

## Labels

Expand Down Expand Up @@ -148,7 +150,9 @@ services:
- "3000:3000"
```
> Note the `loki-pipeline-stages: |` allowing to keep the indentation correct.
{{% admonition type="note" %}}
Note the `loki-pipeline-stages: |` letting you keep the indentation correct.
{{% /admonition %}}

When using docker run you can also pass the value via a string parameter like such:

Expand Down
4 changes: 3 additions & 1 deletion docs/sources/send-data/fluentd/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ services:
## Usage
**Note**: use either `<label>...</label>` or `extra_labels` to set at least one label.
{{% admonition type="note" %}}
Use either `<label>...</label>` or `extra_labels` to set at least one label.
{{% /admonition %}}

In your Fluentd configuration, add `@type loki`. Additional configuration is optional. Default values would look like this:

Expand Down
Loading

0 comments on commit a9173dd

Please sign in to comment.