# Is there any way to dynamically manage loki users based on the tenants?

**URL:** <https://community.grafana.com/t/is-there-any-way-to-dynamically-manage-loki-users-based-on-the-tenants/116386>\
**Category:** Grafana Loki\
**Tags:** users, loki\
**Created:** [March 7, 2024, 8:33am UTC](https://community.grafana.com/t/is-there-any-way-to-dynamically-manage-loki-users-based-on-the-tenants/116386 "2024-03-07T08:33:44Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![divyngairola](https://avatars.discourse-cdn.com/v4/letter/d/85e7bf/32.png) [@divyngairola](https://community.grafana.com/u/divyngairola)\
**Post date:** [March 7, 2024, 8:33am UTC](https://community.grafana.com/t/is-there-any-way-to-dynamically-manage-loki-users-based-on-the-tenants/116386/1 "2024-03-07T08:33:44Z")

</div>

Hi,  
I need to dynamically manage loki users based on the tenants.  
If a tenant is added need to add a new user for that specific tenant and similarly on deletion of that tenant delete that user.

---

<div class="post-metadata">

**Author:** ![tonyswumac](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/tonyswumac/32/22401_2.png) [@tonyswumac](https://community.grafana.com/u/tonyswumac)\
**Post date:** [March 7, 2024, 3:15pm UTC](https://community.grafana.com/t/is-there-any-way-to-dynamically-manage-loki-users-based-on-the-tenants/116386/2 "2024-03-07T15:15:11Z")

</div>

Strictly speaking Loki doesn’t have the concept of users. It simply requires that all requests sent to Loki components have `X-Scope-OrgID` header if auth is enabled. And if you want to add some sort of authentication and user:tenant mapping it would happen at the frontend (most likely nginx).

We use Nginx with HTTP basic authentication plus a bit of configuration to map user to a tenant ID. So you can potentially build some sort of automation that generate the htpasswd file and nginx configuration and reload Nginx automatically.

---

<div class="post-metadata">

**Author:** ![divyngairola](https://avatars.discourse-cdn.com/v4/letter/d/85e7bf/32.png) [@divyngairola](https://community.grafana.com/u/divyngairola)\
**Post date:** [March 11, 2024, 5:51am UTC](https://community.grafana.com/t/is-there-any-way-to-dynamically-manage-loki-users-based-on-the-tenants/116386/3 "2024-03-11T05:51:36Z")

</div>

Thanks a lot, will try the suggested approach

---

<div class="post-metadata">

**Author:** ![divyngairola](https://avatars.discourse-cdn.com/v4/letter/d/85e7bf/32.png) [@divyngairola](https://community.grafana.com/u/divyngairola)\
**Post date:** [March 11, 2024, 6:00am UTC](https://community.grafana.com/t/is-there-any-way-to-dynamically-manage-loki-users-based-on-the-tenants/116386/4 "2024-03-11T06:00:00Z")

</div>

If loki doesn’t have a concept of the user then what does the **user** signify in config like `max_streams_per_user` or `max_global_streams_per_user`?

---

<div class="post-metadata">

**Author:** ![tonyswumac](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/tonyswumac/32/22401_2.png) [@tonyswumac](https://community.grafana.com/u/tonyswumac)\
**Post date:** [March 11, 2024, 6:22am UTC](https://community.grafana.com/t/is-there-any-way-to-dynamically-manage-loki-users-based-on-the-tenants/116386/5 "2024-03-11T06:22:39Z")

</div>

For those configurations users are synonymous to tenants.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/grafana/original/2X/e/ef5308cc58c9e5a13187b5012eb99f406928462f.png) [@system](https://community.grafana.com/u/system)\
**Post date:** [March 11, 2025, 6:22am UTC](https://community.grafana.com/t/is-there-any-way-to-dynamically-manage-loki-users-based-on-the-tenants/116386/6 "2025-03-11T06:22:52Z")

</div>

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
