Skip to content

Commit

Permalink
Merge branch 'main' into helm/overrides-exporter
Browse files Browse the repository at this point in the history
  • Loading branch information
bentonam authored Jan 8, 2025
2 parents 8c20a32 + f2fc0c2 commit e94213f
Show file tree
Hide file tree
Showing 45 changed files with 2,364 additions and 73 deletions.
4 changes: 2 additions & 2 deletions clients/cmd/docker-driver/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ WORKDIR /src/loki
ARG GOARCH
RUN make clean && make BUILD_IN_CONTAINER=false GOARCH=${GOARCH} clients/cmd/docker-driver/docker-driver

FROM alpine:3.21.0 AS temp
FROM alpine:3.21.1 AS temp

ARG GOARCH

RUN apk add --update --no-cache --arch=${GOARCH} ca-certificates tzdata

FROM --platform=linux/${GOARCH} alpine:3.21.0
FROM --platform=linux/${GOARCH} alpine:3.21.1

COPY --from=temp /etc/ca-certificates.conf /etc/ca-certificates.conf
COPY --from=temp /usr/share/ca-certificates /usr/share/ca-certificates
Expand Down
2 changes: 1 addition & 1 deletion clients/cmd/promtail/Dockerfile.debug
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ WORKDIR /src/loki
RUN make clean && make BUILD_IN_CONTAINER=false PROMTAIL_JOURNAL_ENABLED=true promtail-debug


FROM alpine:3.21.0
FROM alpine:3.21.1
RUN apk add --update --no-cache ca-certificates tzdata
COPY --from=build /src/loki/clients/cmd/promtail/promtail-debug /usr/bin/promtail-debug
COPY --from=build /usr/bin/dlv /usr/bin/dlv
Expand Down
1 change: 1 addition & 0 deletions cmd/logcli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,7 @@ func newQuery(instant bool, cmd *kingpin.CmdClause) *query.Query {
cmd.Flag("no-labels", "Do not print any labels").Default("false").BoolVar(&q.NoLabels)
cmd.Flag("exclude-label", "Exclude labels given the provided key during output.").StringsVar(&q.IgnoreLabelsKey)
cmd.Flag("include-label", "Include labels given the provided key during output.").StringsVar(&q.ShowLabelsKey)
cmd.Flag("include-common-labels", "Include common labels in output for each log line.").Default("false").BoolVar(&q.IncludeCommonLabels)
cmd.Flag("labels-length", "Set a fixed padding to labels").Default("0").IntVar(&q.FixedLabelsLen)
cmd.Flag("store-config", "Execute the current query using a configured storage from a given Loki configuration file.").Default("").StringVar(&q.LocalConfig)
cmd.Flag("remote-schema", "Execute the current query using a remote schema retrieved from the configured -schema-store.").Default("false").BoolVar(&q.FetchSchemaFromStorage)
Expand Down
1 change: 1 addition & 0 deletions docs/sources/send-data/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ These third-party clients also enable sending logs to Loki:
- [ilogtail](https://github.com/alibaba/ilogtail) (Go)
- [Log4j2 appender for Loki](https://github.com/tkowalcz/tjahzi) (Java)
- [loki-logback-appender](https://github.com/loki4j/loki-logback-appender) (Java)
- [loki-logger-handler](https://github.com/xente/loki-logger-handler) (Python 3)
- [LokiLogger.jl](https://github.com/JuliaLogging/LokiLogger.jl) (Julia)
- [mjaron-tinyloki-java](https://github.com/mjfryc/mjaron-tinyloki-java) (Java)
- [NLog-Targets-Loki](https://github.com/corentinaltepe/nlog.loki) (C#)
Expand Down
113 changes: 110 additions & 3 deletions docs/sources/send-data/lambda-promtail/_index.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
---
title: Lambda Promtail client
title: Lambda Promtail client
menuTitle: Lambda Promtail
description: Configuring the Lambda Promtail client to send logs to Loki.
aliases:
aliases:
- ../clients/lambda-promtail/
weight: 700
---

# Lambda Promtail client
# Lambda Promtail client

Grafana Loki includes [Terraform](https://www.terraform.io/) and [CloudFormation](https://aws.amazon.com/cloudformation/) for shipping Cloudwatch, Cloudtrail, VPC Flow Logs and loadbalancer logs to Loki via a [lambda function](https://aws.amazon.com/lambda/). This is done via [lambda-promtail](https://github.com/grafana/loki/blob/main/tools/lambda-promtail) which processes cloudwatch events and propagates them to Loki (or a Promtail instance) via the push-api [scrape config]({{< relref "../../send-data/promtail/configuration#loki_push_api" >}}).

Expand Down Expand Up @@ -161,6 +161,113 @@ Incoming logs can have seven special labels assigned to them which can be used i
- `__aws_s3_log_lb`: The name of the loadbalancer.
- `__aws_s3_log_lb_owner`: The Account ID of the loadbalancer owner.

## Relabeling Configuration

Lambda-promtail supports Prometheus-style relabeling through the `RELABEL_CONFIGS` environment variable. This allows you to modify, keep, or drop labels before sending logs to Loki. The configuration is provided as a JSON array of relabel configurations. The relabeling functionality follows the same principles as Prometheus relabeling - for a detailed explanation of how relabeling works, see [How relabeling in Prometheus works](https://grafana.com/blog/2022/03/21/how-relabeling-in-prometheus-works/).

Example configurations:

1. Rename a label and capture regex groups:
```json
{
"RELABEL_CONFIGS": [
{
"source_labels": ["__aws_log_type"],
"target_label": "log_type",
"action": "replace",
"regex": "(.*)",
"replacement": "${1}"
}
]
}
```

2. Keep only specific log types (useful for filtering):
```json
{
"RELABEL_CONFIGS": [
{
"source_labels": ["__aws_log_type"],
"regex": "s3_.*",
"action": "keep"
}
]
}
```

3. Drop internal AWS labels (cleanup):
```json
{
"RELABEL_CONFIGS": [
{
"regex": "__aws_.*",
"action": "labeldrop"
}
]
}
```

4. Multiple relabeling rules (combining different actions):
```json
{
"RELABEL_CONFIGS": [
{
"source_labels": ["__aws_log_type"],
"target_label": "log_type",
"action": "replace",
"regex": "(.*)",
"replacement": "${1}"
},
{
"source_labels": ["__aws_s3_log_lb"],
"target_label": "loadbalancer",
"action": "replace"
},
{
"regex": "__aws_.*",
"action": "labeldrop"
}
]
}
```

### Supported Actions

The following actions are supported, matching Prometheus relabeling capabilities:

- `replace`: Replace a label value with a new value using regex capture groups
- `keep`: Keep entries where labels match the regex (useful for filtering)
- `drop`: Drop entries where labels match the regex (useful for excluding)
- `hashmod`: Set a label to the modulus of a hash of labels (useful for sharding)
- `labelmap`: Copy labels to other labels based on regex matching
- `labeldrop`: Remove labels matching the regex pattern
- `labelkeep`: Keep only labels matching the regex pattern
- `lowercase`: Convert label values to lowercase
- `uppercase`: Convert label values to uppercase

### Configuration Fields

Each relabel configuration supports these fields (all fields are optional except for `action`):

- `source_labels`: List of label names to use as input for the action
- `separator`: String to join source label values (default: ";")
- `target_label`: Label to modify (required for replace and hashmod actions)
- `regex`: Regular expression to match against (defaults to "(.+)" for most actions)
- `replacement`: Replacement pattern for matched regex, supports ${1}, ${2}, etc. for capture groups
- `modulus`: Modulus for hashmod action
- `action`: One of the supported actions listed above

### Important Notes

1. Relabeling is applied after merging extra labels and dropping labels specified by `DROP_LABELS`.
2. If all labels are removed after relabeling, the log entry will be dropped entirely.
3. The relabeling configuration follows the same format as Prometheus's relabel_configs, making it familiar for users of Prometheus.
4. Relabeling rules are processed in order, and each rule can affect the input of subsequent rules.
5. Regular expressions in the `regex` field support full RE2 syntax.
6. For the `replace` action, if the `regex` doesn't match, the target label remains unchanged.

For more details about how relabeling works and advanced use cases, refer to the [Prometheus relabeling blog post](https://grafana.com/blog/2022/03/21/how-relabeling-in-prometheus-works/).

## Limitations

### Promtail labels
Expand Down
2 changes: 1 addition & 1 deletion docs/sources/send-data/promtail/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ Important details are:

## Loki Push API

Promtail can also be configured to receive logs from another Promtail or any Loki client by exposing the [Loki Push API](https://grafana.com/docs/loki/<LOKI_VERSION>/reference/loki-http-api#ingest-logs) with the [loki_push_api](https://grafana.com/docs/loki/<LOKI_VERSION>/reference/loki-http-api#loki_push_api) scrape config.
Promtail can also be configured to receive logs from another Promtail or any Loki client by exposing the [Loki Push API](https://grafana.com/docs/loki/<LOKI_VERSION>/reference/loki-http-api#ingest-logs) with the [Promtail loki_push_api](https://grafana.com/docs/loki/<LOKI_VERSION>/send-data/promtail/configuration/#loki_push_api) scrape config.

There are a few instances where this might be helpful:

Expand Down
10 changes: 10 additions & 0 deletions docs/sources/setup/install/helm/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,22 @@ This guide references the Loki Helm chart version 3.0 or greater and contains th

If you are installing Grafana Enterprise Logs, follow the [GEL Helm installation](https://grafana.com/docs/enterprise-logs/<ENTERPRISE_LOGS_VERSION>/setup/helm/).

## Deployment Recommendations

Loki is designed to be run in two states:
* [Monolithic](https://grafana.com/docs/loki/<LOKI_VERSION>/get-started/deployment-modes/#monolithic-mode): Recommended when you are running Loki as part of a small meta monitoring stack.
* [Microservices](https://grafana.com/docs/loki/<LOKI_VERSION>/get-started/deployment-modes/#microservices-mode): For workloads that require high availability and scalability. Loki is deployed in this mode internally at Grafana Labs.

{{< admonition type="tip" >}}
Loki can also be deployed in [Simple Scalable mode](https://grafana.com/docs/loki/<LOKI_VERSION>/get-started/deployment-modes/#simple-scalable). For the best possible experience in production, we recommend deploying Loki in *microservices* mode.
{{< /admonition >}}

## Cloud Deployment Guides

The following guides provide step-by-step instructions for deploying Loki on cloud providers:

- [Amazon EKS](https://grafana.com/docs/loki/<LOKI_VERSION>/setup/install/helm/deployment-guides/aws/)
- [Azure AKS](https://grafana.com/docs/loki/<LOKI_VERSION>/setup/install/helm/deployment-guides/azure/)

## Reference

Expand Down
3 changes: 2 additions & 1 deletion docs/sources/setup/install/helm/deployment-guides/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ keywords:

The following guides provide step-by-step instructions for deploying Loki on cloud providers:

- [Deploy Loki on AWS](https://grafana.com/docs/loki/<LOKI_VERSION>/setup/install/helm/deployment-guides/aws/)
- [Deploy Loki on AWS](https://grafana.com/docs/loki/<LOKI_VERSION>/setup/install/helm/deployment-guides/aws/)
- [Deploy Loki on Azure](https://grafana.com/docs/loki/<LOKI_VERSION>/setup/install/helm/deployment-guides/azure/)
3 changes: 0 additions & 3 deletions docs/sources/setup/install/helm/deployment-guides/aws.md
Original file line number Diff line number Diff line change
Expand Up @@ -531,9 +531,6 @@ k6 is one of the fastest ways to test your Loki deployment. This will allow you
iterations: 10,
};
**It is important to create a namespace called `loki` as our trust policy is set to allow the IAM role to be used by the `loki` service account in the `loki` namespace. This is configurable but make sure to update your service account.**
* "main" function for each VU iteration
*/
export default () => {
// Push request with 10 streams and uncompressed logs between 800KB and 2MB
var res = client.pushParameterized(10, 800 * KB, 2 * MB);
Expand Down
Loading

0 comments on commit e94213f

Please sign in to comment.