<p>Suggestion (disclaimer: have not tried to do what you are trying to accomplish)...see if Caddy request matchers might help:
<a href="https://caddyserver.com/docs/caddyfile/matchers" rel="nofollow noreferrer">https://caddyserver.com/docs/caddyfile/matchers</a></p>
<p>Example of configuring Loki to run with Caddy (in this case, to support TLS):
<a href="https://github.com/mikequentel/caddy-and-loki-deployment-example" rel="nofollow noreferrer">https://github.com/mikequentel/caddy-and-loki-deployment-example</a></p>

CC BY-SA 4.0
2023-08-31T02:43:50.107Z
2023-08-31T02:43:50.107Z
mikequentel
<p>I'm currently setting up a stack with <code>Grafana</code> and <code>Grafana Loki</code> to store, query, and analyze logs from different web applications. Most applications run on .NET using Serilog and the <code>Serilog.Sinks.Grafana.Loki</code>-Sink.</p>
<p>From time to time we see errors och warnings in the logs that we know are not relevant or that we want to ignore.</p>
<p>I know there are several options here but none of them are &quot;straightforward&quot;:</p>
<p><strong>1. Filtering them in the reporting web app so that they are never sent to Loki</strong></p>
<p>This would require a release of the app just to filter out logs. Does not make sense to me.</p>
<p><strong>2. Filter using <a href="https://grafana.com/docs/loki/latest/logql/" rel="nofollow noreferrer">LogQL</a></strong></p>
<p>In this case the data is still stored in Loki and it would also make my queries complicated - would be really hard to make sure all dashboards uses them same filtering logic.</p>
<p><strong>3. Filter using loki-configuration</strong>
There seems to be some kind of <code>pre_ingesters</code>-setting in the Loki configuration but using this would probably require a restart of the Loki-service which is not a great option.</p>
<p>I'm basically looking for something where I (as the user) can create a number of filters (preferably using a web UI) that would be applied before Loki store the log lines, like some kind of proxy-layer.</p>
<p>How can this be solved?</p>

<grafana>
Configurable "Ingress filter" to prevent Grafana Loki for storing log item
Markus Knappen Johansson
# Configurable "Ingress filter" to prevent Grafana Loki for storing log item

(Asked by: username_0 on 2023-08-29)

I'm currently setting up a stack with `Grafana` and `Grafana Loki` to store, query, and analyze logs from different web applications. Most applications run on .NET using Serilog and the `Serilog.Sinks.Grafana.Loki`-Sink.

From time to time we see errors och warnings in the logs that we know are not relevant or that we want to ignore.

I know there are several options here but none of them are "straightforward":

**1. Filtering them in the reporting web app so that they are never sent to Loki**

This would require a release of the app just to filter out logs. Does not make sense to me.

**2. Filter using [LogQL](https://grafana.com/docs/loki/latest/logql/)**

In this case the data is still stored in Loki and it would also make my queries complicated - would be really hard to make sure all dashboards uses them same filtering logic.

**3. Filter using loki-configuration**
There seems to be some kind of `pre_ingesters`-setting in the Loki configuration but using this would probably require a restart of the Loki-service which is not a great option.

I'm basically looking for something where I (as the user) can create a number of filters (preferably using a web UI) that would be applied before Loki store the log lines, like some kind of proxy-layer.

How can this be solved?

**Tags:** grafana


---

## 1 answers

### Answer by username_1 on 2023-08-31. Score: 0

Suggestion (disclaimer: have not tried to do what you are trying to accomplish)...see if Caddy request matchers might help:
<https://caddyserver.com/docs/caddyfile/matchers>

Example of configuring Loki to run with Caddy (in this case, to support TLS):
<https://github.com/username_1/caddy-and-loki-deployment-example>


---

