Skip to content

Commit b55ed54

Browse files
docs: document stage-based log filtering via LOKI_STAGE_CONFIGS
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent a575822 commit b55ed54

1 file changed

Lines changed: 23 additions & 1 deletion

File tree

README.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ Then use Terraform to deploy:
5858

5959
```bash
6060
## use cloudwatch log group
61-
terraform apply -var "write_address=https://your-loki-url/loki/api/v1/push" -var "password=<basic-auth-pw>" -var "username=<basic-auth-username>" -var 'bearer_token=<bearer-token>' -var 'log_group_names=["log-group-01", "log-group-02"]' -var 'extra_labels="name1,value1,name2,value2"' -var 'drop_labels="name1,name2"' -var 'relabel_configs=[{"source_labels":["label1"],"target_label":"new_label1","action":"replace"}]' -var "tenant_id=<value>" -var 'skip_tls_verify="false"'
61+
terraform apply -var "write_address=https://your-loki-url/loki/api/v1/push" -var "password=<basic-auth-pw>" -var "username=<basic-auth-username>" -var 'bearer_token=<bearer-token>' -var 'log_group_names=["log-group-01", "log-group-02"]' -var 'extra_labels="name1,value1,name2,value2"' -var 'drop_labels="name1,name2"' -var 'relabel_configs=[{"source_labels":["label1"],"target_label":"new_label1","action":"replace"}]' -var "tenant_id=<value>" -var 'skip_tls_verify="false"' -var 'loki_stage_configs=[{"drop":{"expression":"^END RequestId:.*"}}]'
6262
```
6363

6464
```bash
@@ -79,6 +79,28 @@ aws cloudformation create-stack --stack-name lambda-promtail-stack --template-bo
7979

8080
**NOTE:** To use CloudFormation, you must build the docker image with `docker build . -f tools/lambda-promtail/Dockerfile` from the root of the Loki repository, upload it to an ECR, and pass it as the `LambdaPromtailImage` parameter to cloudformation.
8181

82+
## Filtering log lines with pipeline stages
83+
84+
`lambda-promtail` supports [Promtail pipeline stages](https://grafana.com/docs/loki/latest/send-data/promtail/stages/)
85+
via the `LOKI_STAGE_CONFIGS` environment variable (Terraform variable
86+
`loki_stage_configs`). Use a `drop` stage to discard noisy log lines by content
87+
before they are sent to Loki, reducing ingestion volume and cost.
88+
89+
For example, to drop AWS Lambda `END RequestId:` lines:
90+
91+
```json
92+
[{"drop":{"expression":"^END RequestId:.*"}}]
93+
```
94+
95+
Set it via Terraform:
96+
97+
```bash
98+
terraform apply -var 'loki_stage_configs=[{"drop":{"expression":"^END RequestId:.*"}}]' ...
99+
```
100+
101+
All Promtail stage types are supported (`drop`, `match`, `regex`, `labeldrop`,
102+
etc.). This is the recommended mechanism for content-based filtering.
103+
82104
# Appendix
83105

84106
## Golang installation

0 commit comments

Comments
 (0)