Loki: Serving from external URL + subpath

I want to reach my Loki instance from a subpath like so:

<mydomain>/monitoring/loki/<loki specific path>

I can’t find any information on how to configure that? Is it even possible? I know that it is with Prometheus using flags like --web.external-url but I don’t know how similar Loki is to Prometheus.

Okay I have checked the options with docker run grafana/loki -help and the flag I mentioned is not included there. So I guess it is not possible? Grepped for url and the only remotely related option I found is -frontend.downstream-url with the description: “URL of downstream Prometheus”.

Sorry to resurrect this old question, but I have exactly the same.

I have a few services (including Loki) behind a caddy V2 web server and I would like to use a subpath to only have one public FQDN.

Could not find any hints on this.

Is it possible ?

Or are there other best practices to run Loki behind a reverse proxy on a subpath ?
Any hint would be greatly apreciated.

Many thanks.

I had some help from the community and could solve this.

TL;DR you can define the prefix on a loki 2.3+ server with:

server:
  http_listen_port: 3100
  http_path_prefix: /myprefix

And with more details, in case it helps someone else:

This assume all the services are defined in a single docker-compose setup with vanilla names, the Caddy server is the single entry point for the outside world.

Caddy v2 reverse proxy conf:

:8080 {
    route /myprefix* {
        reverse_proxy loki:3100
    }
  
    reverse_proxy myapp:8081 
}

Yaml conf for Loki:

...
server:
  http_listen_port: 3100
  http_path_prefix: /myprefix
...

Yaml Conf for promtail:

...
clients:
  - url: http://loki:3100/myprefix/loki/api/v1/push
...

You can then define the datasource in Grafana with: https://my.example.com/myprefix.

And it works!