How to set promtail send logs to different loki servers according to namespaces?

Hi all,

Can I set promtail sending logs to different loki servers according to namespaces?
For example, namespace A to Loki A, namespace B to Loki B.

I also find the related post, Single Promtail with multiple clients, each getting a different set of logs. But I don’t get any help from it.

How to specify one client for one namespace?
Does anyone can help?

Thanks

I’ve not personally tried to send to multiple Loki servers from Promtail, but I don’t believe this is possible with promtail, because I believe the client configurations are set by the time you enter the pipeline stage. Also, according to the documentation:

# Describes how Promtail connects to multiple instances
# of Grafana Loki, sending logs to each.
# WARNING: If one of the remote Loki servers fails to respond or responds
# with any error which is retryable, this will impact sending logs to any
# other configured remote Loki servers.  Sending is done on a single thread!
# It is generally recommended to run multiple Promtail clients in parallel
# if you want to send to multiple remote Loki instances.

sounds like it just sends to all configured loki servers.

With that said, couple of options I can think of:

  1. You can have multiple promtail agents running (as suggested by the doc), and configure them accordingly to look for certain namespaces for the loki server that they are configured to send to.

  2. You can consider using other logging agent that can forward log dynamically, such as fluentd.

Thanks. It sounds like I have to give up promtail in my case.