<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Label-based access control (LBAC) for data sources on Grafana Labs</title><link>https://grafana.com/docs/grafana/v13.1/administration/data-source-management/teamlbac/</link><description>Recent content in Label-based access control (LBAC) for data sources on Grafana Labs</description><generator>Hugo -- gohugo.io</generator><language>en</language><atom:link href="/docs/grafana/v13.1/administration/data-source-management/teamlbac/index.xml" rel="self" type="application/rss+xml"/><item><title>Create LBAC for data sources rules</title><link>https://grafana.com/docs/grafana/v13.1/administration/data-source-management/teamlbac/create-teamlbac-rules/</link><pubDate>Wed, 07 Oct 2026 20:20:36 +0000</pubDate><guid>https://grafana.com/docs/grafana/v13.1/administration/data-source-management/teamlbac/create-teamlbac-rules/</guid><content><![CDATA[&lt;h1 id=&#34;create-lbac-for-data-sources-rules&#34;&gt;Create LBAC for data sources rules&lt;/h1&gt;
&lt;p&gt;LBAC for data sources works with supported data sources that use basic authentication. You can&amp;rsquo;t add LBAC rules to a file-provisioned data source, and provisioned data sources are read-only in the UI. Create the data source first, then add its LBAC rules on the &lt;strong&gt;Permissions&lt;/strong&gt; tab or provision them with the Grafana Terraform provider.&lt;/p&gt;
&lt;h2 id=&#34;before-you-begin&#34;&gt;Before you begin&lt;/h2&gt;
&lt;p&gt;Before you start, ensure you have:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Tenant permissions:&lt;/strong&gt; Permission to create the tenant for your data source, such as a Loki tenant, in Grafana Cloud or in Grafana Enterprise Metrics or Grafana Enterprise Logs.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Data source permissions:&lt;/strong&gt; &lt;code&gt;Admin&lt;/code&gt; permission on the data source in Grafana.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;A team:&lt;/strong&gt; At least one team set up in Grafana.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;create-an-lbac-for-data-sources-rule-for-a-team&#34;&gt;Create an LBAC for data sources rule for a team&lt;/h2&gt;
&lt;p&gt;To add an LBAC rule to a team:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Navigate to your data source.&lt;/li&gt;
&lt;li&gt;Select the &lt;strong&gt;Permissions&lt;/strong&gt; tab. The LBAC for data sources rules section appears on this tab.&lt;/li&gt;
&lt;li&gt;In the LBAC for data sources rules section, add a new rule for the team.&lt;/li&gt;
&lt;li&gt;Define a label selector for the rule. For the selector syntax, refer to &lt;a href=&#34;#lbac-rules&#34;&gt;LBAC rules&lt;/a&gt;. For data source-specific guidance, refer to the configuration guides in &lt;a href=&#34;#next-steps&#34;&gt;Next steps&lt;/a&gt;.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;lbac-rules&#34;&gt;LBAC rules&lt;/h2&gt;
&lt;p&gt;An LBAC rule is a LogQL query that filters logs or metrics based on labels. Each rule operates independently as its own filter, separate from other rules within a team.&lt;/p&gt;
&lt;p&gt;For example:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Logs:&lt;/strong&gt; &lt;code&gt;{namespace=&amp;quot;dev&amp;quot;, cluster=&amp;quot;us-west-0&amp;quot;}&lt;/code&gt; returns log lines that match both &lt;code&gt;namespace=&amp;quot;dev&amp;quot;&lt;/code&gt; and &lt;code&gt;cluster=&amp;quot;us-west-0&amp;quot;&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Metrics:&lt;/strong&gt; &lt;code&gt;{job=&amp;quot;api-server&amp;quot;, region=&amp;quot;europe&amp;quot;}&lt;/code&gt; returns metric data points that match both &lt;code&gt;job=&amp;quot;api-server&amp;quot;&lt;/code&gt; and &lt;code&gt;region=&amp;quot;europe&amp;quot;&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Within a single rule, comma-separated selectors combine with &lt;strong&gt;AND&lt;/strong&gt;. For example, the rule &lt;code&gt;{namespace=&amp;quot;dev&amp;quot;, cluster=&amp;quot;us-west-0&amp;quot;}&lt;/code&gt; matches data where &lt;code&gt;namespace=&amp;quot;dev&amp;quot;&lt;/code&gt; &lt;strong&gt;AND&lt;/strong&gt; &lt;code&gt;cluster=&amp;quot;us-west-0&amp;quot;&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Across a team, multiple rules combine with &lt;strong&gt;OR&lt;/strong&gt;. For example, the two rules &lt;code&gt;{namespace=&amp;quot;dev&amp;quot;}&lt;/code&gt; and &lt;code&gt;{cluster=&amp;quot;us-west-0&amp;quot;}&lt;/code&gt; match data where &lt;code&gt;namespace=&amp;quot;dev&amp;quot;&lt;/code&gt; &lt;strong&gt;OR&lt;/strong&gt; &lt;code&gt;cluster=&amp;quot;us-west-0&amp;quot;&lt;/code&gt;.&lt;/p&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;An &lt;code&gt;Admin&lt;/code&gt; user who&amp;rsquo;s a member of one or more teams with LBAC rules can access only the logs or metrics allowed by those teams&amp;rsquo; rules. An &lt;code&gt;Admin&lt;/code&gt; user who isn&amp;rsquo;t a member of any team with LBAC rules can access all logs or metrics.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;h3 id=&#34;traces-rules&#34;&gt;Traces rules&lt;/h3&gt;
&lt;p&gt;For Tempo and Cloud Traces, rules use attribute selectors rather than LogQL labels. This functionality is in public preview, and traces LBAC is available only at the team level. Use resource-scope attributes, for example:&lt;/p&gt;

&lt;div class=&#34;code-snippet code-snippet__mini&#34;&gt;&lt;div class=&#34;lang-toolbar__mini&#34;&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet code-snippet__border&#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-none&#34;&gt;{ resource.service.name=&amp;#34;checkout&amp;#34;, resource.env=&amp;#34;prod&amp;#34; }&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The same logic applies as for logs and metrics: comma-separated conditions in one rule combine with &lt;strong&gt;AND&lt;/strong&gt;, and multiple rules across a team combine with &lt;strong&gt;OR&lt;/strong&gt;. For more information, refer to 
    &lt;a href=&#34;/docs/grafana/v13.1/administration/data-source-management/teamlbac/configure-teamlbac-for-tempo/&#34;&gt;Configure team LBAC for Tempo or Cloud Traces&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&#34;best-practices&#34;&gt;Best practices&lt;/h3&gt;
&lt;p&gt;Follow these recommendations when you set up rules:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Grant &lt;code&gt;Query&lt;/code&gt; permission only to teams that should use the data source, and grant &lt;code&gt;Admin&lt;/code&gt; permission only to administrators.&lt;/li&gt;
&lt;li&gt;Give every team that should be restricted its own rule. A team that has &lt;code&gt;Query&lt;/code&gt; permission but no rule can query all logs or metrics.&lt;/li&gt;
&lt;li&gt;Remove label selectors from the Cloud Access Policy for the data source. Cloud Access Policy rules override LBAC for data sources rules.&lt;/li&gt;
&lt;li&gt;For a first setup, create as few rules as possible for each team and prefer rules that grant access over rules that exclude data, because access is the union of all rules.&lt;/li&gt;
&lt;li&gt;Use a dedicated data source for LBAC, and keep a separate data source without LBAC for full access, so the separation is clear.&lt;/li&gt;
&lt;li&gt;Manage rules as code with the Grafana Terraform provider for repeatable, reviewable setups.&lt;/li&gt;
&lt;li&gt;To validate rules, test them in 
    &lt;a href=&#34;/docs/grafana/v13.1/explore/&#34;&gt;Explore&lt;/a&gt;. Explore shows the logs or metrics that a rule returns.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;examples&#34;&gt;Examples&lt;/h2&gt;
&lt;p&gt;The following examples show how different rule and team configurations affect access. Unless stated otherwise, each team has &lt;code&gt;Query&lt;/code&gt; permission on the data source and administrators have &lt;code&gt;Admin&lt;/code&gt; permission only.&lt;/p&gt;
&lt;h3 id=&#34;one-rule-for-each-team&#34;&gt;One rule for each team&lt;/h3&gt;
&lt;p&gt;A common use case is to grant a team access to data that has a specific label. In this example, Team A and Team B each have one rule:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Team A has the rule &lt;code&gt;namespace=&amp;quot;dev&amp;quot;&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Team B has the rule &lt;code&gt;namespace=&amp;quot;prod&amp;quot;&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;A user in Team A can access logs or metrics that match &lt;code&gt;namespace=&amp;quot;dev&amp;quot;&lt;/code&gt;. A user in both Team A and Team B can access data that matches &lt;code&gt;namespace=&amp;quot;dev&amp;quot;&lt;/code&gt; &lt;strong&gt;OR&lt;/strong&gt; &lt;code&gt;namespace=&amp;quot;prod&amp;quot;&lt;/code&gt;.&lt;/p&gt;
&lt;h3 id=&#34;multiple-rules-for-one-team&#34;&gt;Multiple rules for one team&lt;/h3&gt;
&lt;p&gt;A team can have more than one rule, and its members can access data that matches any of them. In this example, Team A has two rules:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Rule 1: &lt;code&gt;namespace=&amp;quot;dev&amp;quot;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Rule 2: &lt;code&gt;namespace=&amp;quot;prod&amp;quot;&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;A user in Team A can access logs or metrics that match &lt;code&gt;namespace=&amp;quot;dev&amp;quot;&lt;/code&gt; &lt;strong&gt;OR&lt;/strong&gt; &lt;code&gt;namespace=&amp;quot;prod&amp;quot;&lt;/code&gt;.&lt;/p&gt;
&lt;h3 id=&#34;exclude-a-label-for-a-team&#34;&gt;Exclude a label for a team&lt;/h3&gt;
&lt;p&gt;You can exclude data that has a specific label. For example, to exclude all log lines labeled &lt;code&gt;secret=&amp;quot;true&amp;quot;&lt;/code&gt;, add the selector &lt;code&gt;secret!=&amp;quot;true&amp;quot;&lt;/code&gt;. In this example, Team A has one rule:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Team A has the rule &lt;code&gt;secret!=&amp;quot;true&amp;quot;&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;A user in Team A can access logs or metrics that match &lt;code&gt;secret!=&amp;quot;true&amp;quot;&lt;/code&gt;, which is all data except data labeled &lt;code&gt;secret=&amp;quot;true&amp;quot;&lt;/code&gt;.&lt;/p&gt;
&lt;h3 id=&#34;rules-with-multiple-conditions&#34;&gt;Rules with multiple conditions&lt;/h3&gt;
&lt;p&gt;A single rule can combine multiple conditions with &lt;strong&gt;AND&lt;/strong&gt;. In this example, Team A and Team B each have one rule:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Team A has the rule &lt;code&gt;cluster=&amp;quot;us-west-0&amp;quot;, namespace=~&amp;quot;dev|prod&amp;quot;&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Team B has the rule &lt;code&gt;cluster=&amp;quot;us-west-0&amp;quot;, namespace=&amp;quot;staging&amp;quot;&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The &lt;code&gt;=~&lt;/code&gt; operator matches a regular expression, so &lt;code&gt;namespace=~&amp;quot;dev|prod&amp;quot;&lt;/code&gt; matches either &lt;code&gt;dev&lt;/code&gt; or &lt;code&gt;prod&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;A user in only Team A can access logs or metrics that match &lt;code&gt;cluster=&amp;quot;us-west-0&amp;quot;&lt;/code&gt; &lt;strong&gt;AND&lt;/strong&gt; (&lt;code&gt;namespace=&amp;quot;dev&amp;quot;&lt;/code&gt; &lt;strong&gt;OR&lt;/strong&gt; &lt;code&gt;namespace=&amp;quot;prod&amp;quot;&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;A user in only Team B can access logs or metrics that match &lt;code&gt;cluster=&amp;quot;us-west-0&amp;quot;&lt;/code&gt; &lt;strong&gt;AND&lt;/strong&gt; &lt;code&gt;namespace=&amp;quot;staging&amp;quot;&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;A user in both Team A and Team B can access logs or metrics that match &lt;code&gt;cluster=&amp;quot;us-west-0&amp;quot;&lt;/code&gt; &lt;strong&gt;AND&lt;/strong&gt; (&lt;code&gt;namespace=&amp;quot;dev&amp;quot;&lt;/code&gt;, &lt;code&gt;namespace=&amp;quot;prod&amp;quot;&lt;/code&gt;, or &lt;code&gt;namespace=&amp;quot;staging&amp;quot;&lt;/code&gt;), because rules across teams combine with &lt;strong&gt;OR&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;A user with an &lt;code&gt;Editor&lt;/code&gt; or &lt;code&gt;Viewer&lt;/code&gt; role who isn&amp;rsquo;t a member of any team can&amp;rsquo;t query logs or metrics, because in this setup only teams have &lt;code&gt;Query&lt;/code&gt; permission on the data source.&lt;/p&gt;
&lt;h3 id=&#34;rules-that-overlap&#34;&gt;Rules that overlap&lt;/h3&gt;
&lt;p&gt;Two teams can have rules that overlap. In this example:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Team A has the rule &lt;code&gt;namespace=&amp;quot;dev&amp;quot;&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Team B has the rule &lt;code&gt;namespace!=&amp;quot;dev&amp;quot;&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;A user in Team A can access logs or metrics that match &lt;code&gt;namespace=&amp;quot;dev&amp;quot;&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;A user in Team B can access logs or metrics that match &lt;code&gt;namespace!=&amp;quot;dev&amp;quot;&lt;/code&gt;.&lt;/p&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;A user in both Team A and Team B can access all data, because the rules combine as &lt;code&gt;namespace=&amp;quot;dev&amp;quot;&lt;/code&gt; &lt;strong&gt;OR&lt;/strong&gt; &lt;code&gt;namespace!=&amp;quot;dev&amp;quot;&lt;/code&gt;.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;h3 id=&#34;team-without-a-rule&#34;&gt;Team without a rule&lt;/h3&gt;
&lt;p&gt;When a team has no LBAC rule, its members can access all logs or metrics, subject to their data source permission. In this example, the &lt;code&gt;Editor&lt;/code&gt; and &lt;code&gt;Viewer&lt;/code&gt; roles have &lt;code&gt;Query&lt;/code&gt; permission:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Team A has the rule &lt;code&gt;namespace=&amp;quot;dev&amp;quot;&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Team B has no rule configured.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;A user in only Team A can access logs or metrics that match &lt;code&gt;namespace=&amp;quot;dev&amp;quot;&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;A user in both Team A and Team B can access logs or metrics that match &lt;code&gt;namespace=&amp;quot;dev&amp;quot;&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;A user in only Team B with an &lt;code&gt;Editor&lt;/code&gt; or &lt;code&gt;Viewer&lt;/code&gt; role can access all logs or metrics, because Team B has no rule and the user has &lt;code&gt;Query&lt;/code&gt; permission.&lt;/p&gt;
&lt;h3 id=&#34;administrator-on-a-team-with-a-rule&#34;&gt;Administrator on a team with a rule&lt;/h3&gt;
&lt;p&gt;An administrator&amp;rsquo;s basic role doesn&amp;rsquo;t bypass LBAC rules when the administrator is a member of a team that has rules. In this example, User A has an &lt;code&gt;Admin&lt;/code&gt; basic role and is a member of Team B:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Team B has no roles assigned.&lt;/li&gt;
&lt;li&gt;Team B has &lt;code&gt;Query&lt;/code&gt; permission on the data source.&lt;/li&gt;
&lt;li&gt;Team B has the rule &lt;code&gt;{ project_id=&amp;quot;project-dev&amp;quot; }&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;User A can access only logs or metrics that match &lt;code&gt;{ project_id=&amp;quot;project-dev&amp;quot; }&lt;/code&gt;.&lt;/p&gt;
&lt;h2 id=&#34;next-steps&#34;&gt;Next steps&lt;/h2&gt;
&lt;p&gt;Set up LBAC for data sources for your data source:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
    &lt;a href=&#34;/docs/grafana/v13.1/administration/data-source-management/teamlbac/configure-teamlbac-for-loki/&#34;&gt;Configure LBAC for data sources for Loki&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
    &lt;a href=&#34;/docs/grafana/v13.1/administration/data-source-management/teamlbac/configure-teamlbac-for-prometheus/&#34;&gt;Configure LBAC for data sources for Prometheus&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
    &lt;a href=&#34;/docs/grafana/v13.1/administration/data-source-management/teamlbac/configure-teamlbac-for-tempo/&#34;&gt;Configure team LBAC for Tempo or Cloud Traces&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
]]></content><description>&lt;h1 id="create-lbac-for-data-sources-rules">Create LBAC for data sources rules&lt;/h1>
&lt;p>LBAC for data sources works with supported data sources that use basic authentication. You can&amp;rsquo;t add LBAC rules to a file-provisioned data source, and provisioned data sources are read-only in the UI. Create the data source first, then add its LBAC rules on the &lt;strong>Permissions&lt;/strong> tab or provision them with the Grafana Terraform provider.&lt;/p></description></item><item><title>Configure LBAC for a Loki data source</title><link>https://grafana.com/docs/grafana/v13.1/administration/data-source-management/teamlbac/configure-teamlbac-for-loki/</link><pubDate>Tue, 29 Sep 2026 22:18:37 +0000</pubDate><guid>https://grafana.com/docs/grafana/v13.1/administration/data-source-management/teamlbac/configure-teamlbac-for-loki/</guid><content><![CDATA[&lt;h1 id=&#34;configure-lbac-for-a-loki-data-source&#34;&gt;Configure LBAC for a Loki data source&lt;/h1&gt;
&lt;p&gt;This document explains how to configure Label-Based Access Control (LBAC) for data sources for a Loki data source. LBAC for data sources filters the logs that a team can query based on labels. You can configure it on both Grafana Cloud and Grafana Enterprise.&lt;/p&gt;
&lt;h2 id=&#34;grafana-cloud&#34;&gt;Grafana Cloud&lt;/h2&gt;
&lt;p&gt;LBAC for data sources is generally available on Grafana Cloud for Loki data sources created with basic authentication. You create a new data source as described in &lt;a href=&#34;#configure-a-new-loki-data-source-on-grafana-cloud&#34;&gt;Configure a new Loki data source&lt;/a&gt;. Provisioning is currently not available.&lt;/p&gt;
&lt;p&gt;You can&amp;rsquo;t configure LBAC rules for Grafana-provisioned data sources from the UI. We recommend that you replicate the settings of the provisioned data source in a new data source, and then add the LBAC configuration to the new data source.&lt;/p&gt;
&lt;h3 id=&#34;before-you-begin&#34;&gt;Before you begin&lt;/h3&gt;
&lt;p&gt;Before you configure LBAC for data sources, ensure you have the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Permission to create a Loki tenant in Grafana Cloud.&lt;/li&gt;
&lt;li&gt;Admin data source permissions for Grafana.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Grafana recommends that you remove all permissions for roles and teams that don&amp;rsquo;t require access to the data source. This ensures that only the required teams access the data source. The recommended permissions are &lt;code&gt;Admin&lt;/code&gt; permission for administrators, and &lt;code&gt;Query&lt;/code&gt; permission only for the teams that you want to add LBAC for data sources rules for.&lt;/p&gt;
&lt;h3 id=&#34;configure-a-new-loki-data-source-on-grafana-cloud&#34;&gt;Configure a new Loki data source on Grafana Cloud&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;Access Loki data source details for your stack in Grafana Cloud.&lt;/li&gt;
&lt;li&gt;Copy Loki details and create a CAP.
&lt;ul&gt;
&lt;li&gt;Copy the details of your Loki setup.&lt;/li&gt;
&lt;li&gt;Create a Cloud Access Policy (CAP) for the Loki data source in Grafana Cloud.&lt;/li&gt;
&lt;li&gt;Ensure the CAP includes &lt;code&gt;logs:read&lt;/code&gt; permissions.&lt;/li&gt;
&lt;li&gt;Ensure the CAP doesn&amp;rsquo;t include &lt;code&gt;labels&lt;/code&gt; rules.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Create a new Loki data source.
&lt;ul&gt;
&lt;li&gt;In Grafana, add a new data source and select Loki as the type.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Navigate back to the Loki data source.
&lt;ul&gt;
&lt;li&gt;Set up the Loki data source using basic authentication. Use the &lt;code&gt;userID&lt;/code&gt; as the username. Use the generated CAP &lt;code&gt;token&lt;/code&gt; as the password.&lt;/li&gt;
&lt;li&gt;Select &lt;strong&gt;Save &amp;amp; test&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Navigate to data source permissions.
&lt;ul&gt;
&lt;li&gt;Go to the &lt;strong&gt;Permissions&lt;/strong&gt; tab of the newly created Loki data source. Here, you find the LBAC for data sources rules section.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;For more information on how to set up LBAC for data sources rules for a Loki data source, refer to 
    &lt;a href=&#34;/docs/grafana/v13.1/administration/data-source-management/teamlbac/create-teamlbac-rules/&#34;&gt;Create LBAC for data sources rules for the Loki data source&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;grafana-enterprise&#34;&gt;Grafana Enterprise&lt;/h2&gt;
&lt;p&gt;LBAC for data sources is available in Grafana Enterprise for Loki connected to Grafana Enterprise Logs (GEL), created with basic authentication.&lt;/p&gt;
&lt;p&gt;You can&amp;rsquo;t configure LBAC rules for Grafana-provisioned data sources from the UI. Alternatively, you can replicate the settings of the provisioned data source in a new data source, and then add the LBAC configuration to the new data source.&lt;/p&gt;
&lt;h3 id=&#34;before-you-begin-1&#34;&gt;Before you begin&lt;/h3&gt;
&lt;p&gt;Before you configure LBAC for data sources, ensure you have the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Permission to create a cluster in your Grafana.&lt;/li&gt;
&lt;li&gt;Admin plugins permissions for Grafana.&lt;/li&gt;
&lt;li&gt;Admin data source permissions for Grafana.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Grafana recommends that you remove all permissions for roles and teams that don&amp;rsquo;t require access to the data source. This ensures that only the required teams access the data source. The recommended permissions are &lt;code&gt;Admin&lt;/code&gt; permission for administrators, and &lt;code&gt;Query&lt;/code&gt; permission only for the teams that you want to add LBAC for data sources rules for.&lt;/p&gt;
&lt;h3 id=&#34;set-up-a-grafana-enterprise-logs-tenant-and-access-policies&#34;&gt;Set up a Grafana Enterprise Logs tenant and access policies&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;Access the plugins page and install the Grafana Enterprise Logs plugin.&lt;/li&gt;
&lt;li&gt;Connect your plugin and use the app as the cluster.&lt;/li&gt;
&lt;li&gt;Access the Grafana Enterprise Logs app and configure a tenant.&lt;/li&gt;
&lt;li&gt;Store the &lt;code&gt;uid&lt;/code&gt; of the tenant to use as the username for basic authentication.&lt;/li&gt;
&lt;li&gt;Access the policies page inside the app and create an access policy.
&lt;ul&gt;
&lt;li&gt;Create an access policy for the Loki data source.&lt;/li&gt;
&lt;li&gt;Ensure the access policy includes &lt;code&gt;logs:read&lt;/code&gt; permissions.&lt;/li&gt;
&lt;li&gt;Ensure the access policy doesn&amp;rsquo;t include &lt;code&gt;labels&lt;/code&gt; rules.&lt;/li&gt;
&lt;li&gt;Store the &lt;code&gt;token&lt;/code&gt; to use as the password for authentication.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&#34;configure-a-new-loki-data-source-on-grafana-enterprise&#34;&gt;Configure a new Loki data source on Grafana Enterprise&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;Create a new Loki data source.
&lt;ul&gt;
&lt;li&gt;In Grafana, add a new data source and select Loki as the type.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Navigate back to the Loki data source.
&lt;ul&gt;
&lt;li&gt;Set up the Loki data source using basic authentication. Use the &lt;code&gt;uid&lt;/code&gt; as the username. Use the generated &lt;code&gt;token&lt;/code&gt; as the password.&lt;/li&gt;
&lt;li&gt;Select &lt;strong&gt;Save &amp;amp; test&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Navigate to data source permissions.
&lt;ul&gt;
&lt;li&gt;Go to the &lt;strong&gt;Permissions&lt;/strong&gt; tab of the newly created Loki data source. Here, you find the LBAC for data sources rules section.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;For more information on how to set up LBAC for data sources rules for a Loki data source, refer to 
    &lt;a href=&#34;/docs/grafana/v13.1/administration/data-source-management/teamlbac/create-teamlbac-rules/&#34;&gt;Create LBAC for data sources rules for the Loki data source&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;examples-of-lbac-rules&#34;&gt;Examples of LBAC rules&lt;/h2&gt;
&lt;p&gt;An LBAC rule is a &lt;code&gt;logql&lt;/code&gt; query that filters logs based on labels. Each rule operates independently as its own filter, separate from other rules within a team. The following examples show common patterns. For more detail, refer to 
    &lt;a href=&#34;/docs/grafana/v13.1/administration/data-source-management/teamlbac/create-teamlbac-rules/&#34;&gt;Create LBAC for data sources rules for the Loki data source&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&#34;single-rule&#34;&gt;Single rule&lt;/h3&gt;
&lt;p&gt;Multiple label selectors in a single rule are combined with &lt;code&gt;AND&lt;/code&gt;. The following rule grants access to log lines that match both &lt;code&gt;namespace=&amp;quot;dev&amp;quot;&lt;/code&gt; and &lt;code&gt;cluster=&amp;quot;us-west-0&amp;quot;&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;logql&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-logql&#34;&gt;{namespace=&amp;#34;dev&amp;#34;, cluster=&amp;#34;us-west-0&amp;#34;}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;multiple-rules&#34;&gt;Multiple rules&lt;/h3&gt;
&lt;p&gt;Multiple rules assigned to the same team are combined with &lt;code&gt;OR&lt;/code&gt;. The following two rules grant access to log lines that match &lt;code&gt;namespace=&amp;quot;dev&amp;quot;&lt;/code&gt; or &lt;code&gt;cluster=&amp;quot;us-west-0&amp;quot;&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;logql&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-logql&#34;&gt;{namespace=&amp;#34;dev&amp;#34;}
{cluster=&amp;#34;us-west-0&amp;#34;}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;match-multiple-values-with-a-regular-expression&#34;&gt;Match multiple values with a regular expression&lt;/h3&gt;
&lt;p&gt;Use the &lt;code&gt;=~&lt;/code&gt; operator to match a label against a regular expression. The following rule grants access to log lines in the &lt;code&gt;dev&lt;/code&gt; or &lt;code&gt;prod&lt;/code&gt; namespace:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;logql&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-logql&#34;&gt;{namespace=~&amp;#34;dev|prod&amp;#34;}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;exclude-a-label-value&#34;&gt;Exclude a label value&lt;/h3&gt;
&lt;p&gt;Use the &lt;code&gt;!=&lt;/code&gt; operator to exclude log lines that carry a specific label value. The following rule grants access to all log lines except those labeled &lt;code&gt;secret=&amp;quot;true&amp;quot;&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;logql&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-logql&#34;&gt;{secret!=&amp;#34;true&amp;#34;}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;user-on-multiple-teams&#34;&gt;User on multiple teams&lt;/h3&gt;
&lt;p&gt;Users on multiple teams receive access based on all the combined rules assigned to each team, combined with &lt;code&gt;OR&lt;/code&gt;. For example, if Team A has &lt;code&gt;{namespace=&amp;quot;dev&amp;quot;}&lt;/code&gt; and Team B has &lt;code&gt;{namespace=&amp;quot;prod&amp;quot;}&lt;/code&gt;, a user on both teams can access log lines that match &lt;code&gt;namespace=&amp;quot;dev&amp;quot;&lt;/code&gt; or &lt;code&gt;namespace=&amp;quot;prod&amp;quot;&lt;/code&gt;.&lt;/p&gt;
&lt;h2 id=&#34;related-resources&#34;&gt;Related resources&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
    &lt;a href=&#34;/docs/grafana/v13.1/administration/data-source-management/teamlbac/&#34;&gt;LBAC for data sources overview&lt;/a&gt; explains how LBAC works, which data sources are supported, and current limitations.&lt;/li&gt;
&lt;li&gt;
    &lt;a href=&#34;/docs/grafana/v13.1/administration/data-source-management/teamlbac/create-teamlbac-rules/&#34;&gt;Create LBAC for data sources rules for a supported data source&lt;/a&gt; explains how to define and manage rules.&lt;/li&gt;
&lt;/ul&gt;
]]></content><description>&lt;h1 id="configure-lbac-for-a-loki-data-source">Configure LBAC for a Loki data source&lt;/h1>
&lt;p>This document explains how to configure Label-Based Access Control (LBAC) for data sources for a Loki data source. LBAC for data sources filters the logs that a team can query based on labels. You can configure it on both Grafana Cloud and Grafana Enterprise.&lt;/p></description></item><item><title>Configure LBAC for a Prometheus data source</title><link>https://grafana.com/docs/grafana/v13.1/administration/data-source-management/teamlbac/configure-teamlbac-for-prometheus/</link><pubDate>Wed, 07 Oct 2026 21:17:40 +0000</pubDate><guid>https://grafana.com/docs/grafana/v13.1/administration/data-source-management/teamlbac/configure-teamlbac-for-prometheus/</guid><content><![CDATA[&lt;h1 id=&#34;configure-lbac-for-a-prometheus-data-source&#34;&gt;Configure LBAC for a Prometheus data source&lt;/h1&gt;
&lt;p&gt;This document explains how to configure Label-Based Access Control (LBAC) for data sources for a Prometheus data source. LBAC for data sources filters the metrics that a team can query based on labels. You can configure it on both Grafana Cloud and Grafana Enterprise.&lt;/p&gt;
&lt;h2 id=&#34;grafana-cloud&#34;&gt;Grafana Cloud&lt;/h2&gt;
&lt;p&gt;LBAC for data sources is generally available on Grafana Cloud for Prometheus data sources created with basic authentication. You create a new data source as described in &lt;a href=&#34;#configure-a-new-prometheus-data-source-on-grafana-cloud&#34;&gt;Configure a new Prometheus data source&lt;/a&gt;. Provisioning is currently not available.&lt;/p&gt;
&lt;p&gt;You can&amp;rsquo;t configure LBAC rules for Grafana-provisioned data sources from the UI. We recommend that you replicate the settings of the provisioned data source in a new data source, and then add the LBAC configuration to the new data source.&lt;/p&gt;
&lt;h3 id=&#34;before-you-begin&#34;&gt;Before you begin&lt;/h3&gt;
&lt;p&gt;Before you configure LBAC for data sources, ensure you have the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Permission to create a Prometheus tenant in Grafana Cloud.&lt;/li&gt;
&lt;li&gt;Admin data source permissions for Grafana.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Grafana recommends that you remove all permissions for roles and teams that don&amp;rsquo;t require access to the data source. This ensures that only the required teams access the data source. The recommended permissions are &lt;code&gt;Admin&lt;/code&gt; permission for administrators, and &lt;code&gt;Query&lt;/code&gt; permission only for the teams that you want to add LBAC for data sources rules for.&lt;/p&gt;
&lt;h3 id=&#34;configure-a-new-prometheus-data-source-on-grafana-cloud&#34;&gt;Configure a new Prometheus data source on Grafana Cloud&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;Access Prometheus data source details for your stack in Grafana Cloud.&lt;/li&gt;
&lt;li&gt;Copy Prometheus details and create a CAP.
&lt;ul&gt;
&lt;li&gt;Copy the details of your Prometheus setup.&lt;/li&gt;
&lt;li&gt;Create a Cloud Access Policy (CAP) for the Prometheus data source in Grafana Cloud.&lt;/li&gt;
&lt;li&gt;Ensure the CAP includes &lt;code&gt;metrics:read&lt;/code&gt; permissions.&lt;/li&gt;
&lt;li&gt;Ensure the CAP doesn&amp;rsquo;t include &lt;code&gt;labels&lt;/code&gt; rules.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Create a new Prometheus data source.
&lt;ul&gt;
&lt;li&gt;In Grafana, add a new data source and select Prometheus as the type.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Navigate back to the Prometheus data source.
&lt;ul&gt;
&lt;li&gt;Set up the Prometheus data source using basic authentication. Use the &lt;code&gt;userID&lt;/code&gt; as the username. Use the generated CAP &lt;code&gt;token&lt;/code&gt; as the password.&lt;/li&gt;
&lt;li&gt;Select &lt;strong&gt;Save &amp;amp; test&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Navigate to data source permissions.
&lt;ul&gt;
&lt;li&gt;Go to the &lt;strong&gt;Permissions&lt;/strong&gt; tab of the newly created Prometheus data source. Here, you find the LBAC for data sources rules section.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;For more information on how to set up LBAC for data sources rules for a Prometheus data source, refer to 
    &lt;a href=&#34;/docs/grafana/v13.1/administration/data-source-management/teamlbac/create-teamlbac-rules/&#34;&gt;Create LBAC for data sources rules for the Prometheus data source&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;grafana-enterprise&#34;&gt;Grafana Enterprise&lt;/h2&gt;
&lt;p&gt;LBAC for data sources is available in Grafana Enterprise for Prometheus connected to Grafana Enterprise Metrics (GEM), created with basic authentication.&lt;/p&gt;
&lt;p&gt;You can&amp;rsquo;t configure LBAC rules for Grafana-provisioned data sources from the UI. Alternatively, you can replicate the settings of the provisioned data source in a new data source, and then add the LBAC configuration to the new data source.&lt;/p&gt;
&lt;h3 id=&#34;before-you-begin-1&#34;&gt;Before you begin&lt;/h3&gt;
&lt;p&gt;Before you configure LBAC for data sources, ensure you have the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Permission to create a cluster in your Grafana.&lt;/li&gt;
&lt;li&gt;Admin plugins permissions for Grafana.&lt;/li&gt;
&lt;li&gt;Admin data source permissions for Grafana.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Grafana recommends that you remove all permissions for roles and teams that don&amp;rsquo;t require access to the data source. This ensures that only the required teams access the data source. The recommended permissions are &lt;code&gt;Admin&lt;/code&gt; permission for administrators, and &lt;code&gt;Query&lt;/code&gt; permission only for the teams that you want to add LBAC for data sources rules for.&lt;/p&gt;
&lt;h3 id=&#34;set-up-a-grafana-enterprise-metrics-tenant-and-access-policies&#34;&gt;Set up a Grafana Enterprise Metrics tenant and access policies&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;Access the plugins page and install the Grafana Enterprise Metrics plugin.&lt;/li&gt;
&lt;li&gt;Connect your plugin and use the app as the cluster.&lt;/li&gt;
&lt;li&gt;Access the Grafana Enterprise Metrics app and configure a tenant.&lt;/li&gt;
&lt;li&gt;Store the &lt;code&gt;uid&lt;/code&gt; of the tenant to use as the username for basic authentication.&lt;/li&gt;
&lt;li&gt;Access the policies page inside the app and create an access policy.
&lt;ul&gt;
&lt;li&gt;Create an access policy for the Prometheus data source.&lt;/li&gt;
&lt;li&gt;Ensure the access policy includes &lt;code&gt;metrics:read&lt;/code&gt; permissions.&lt;/li&gt;
&lt;li&gt;Ensure the access policy doesn&amp;rsquo;t include &lt;code&gt;labels&lt;/code&gt; rules.&lt;/li&gt;
&lt;li&gt;Store the &lt;code&gt;token&lt;/code&gt; to use as the password for authentication.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&#34;configure-a-new-prometheus-data-source-on-grafana-enterprise&#34;&gt;Configure a new Prometheus data source on Grafana Enterprise&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;Create a new Prometheus data source.
&lt;ul&gt;
&lt;li&gt;In Grafana, add a new data source and select Prometheus as the type.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Navigate back to the Prometheus data source.
&lt;ul&gt;
&lt;li&gt;Set up the Prometheus data source using basic authentication. Use the &lt;code&gt;uid&lt;/code&gt; as the username. Use the generated &lt;code&gt;token&lt;/code&gt; as the password.&lt;/li&gt;
&lt;li&gt;Select &lt;strong&gt;Save &amp;amp; test&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Navigate to data source permissions.
&lt;ul&gt;
&lt;li&gt;Go to the &lt;strong&gt;Permissions&lt;/strong&gt; tab of the newly created Prometheus data source. Here, you find the LBAC for data sources rules section.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;For more information on how to set up LBAC for data sources rules for a Prometheus data source, refer to 
    &lt;a href=&#34;/docs/grafana/v13.1/administration/data-source-management/teamlbac/create-teamlbac-rules/&#34;&gt;Create LBAC for data sources rules for the Prometheus data source&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;examples-of-lbac-rules&#34;&gt;Examples of LBAC rules&lt;/h2&gt;
&lt;p&gt;An LBAC rule is a &lt;code&gt;logql&lt;/code&gt; query that filters metrics based on labels. Each rule operates independently as its own filter, separate from other rules within a team. The following examples show common patterns. For more detail, refer to 
    &lt;a href=&#34;/docs/grafana/v13.1/administration/data-source-management/teamlbac/create-teamlbac-rules/&#34;&gt;Create LBAC for data sources rules for the Prometheus data source&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&#34;single-rule&#34;&gt;Single rule&lt;/h3&gt;
&lt;p&gt;Multiple label selectors in a single rule are combined with &lt;code&gt;AND&lt;/code&gt;. The following rule grants access to metrics that match both &lt;code&gt;job=&amp;quot;api-server&amp;quot;&lt;/code&gt; and &lt;code&gt;region=&amp;quot;europe&amp;quot;&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;logql&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-logql&#34;&gt;{job=&amp;#34;api-server&amp;#34;, region=&amp;#34;europe&amp;#34;}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;multiple-rules&#34;&gt;Multiple rules&lt;/h3&gt;
&lt;p&gt;Multiple rules assigned to the same team are combined with &lt;code&gt;OR&lt;/code&gt;. The following two rules grant access to metrics that match &lt;code&gt;job=&amp;quot;api-server&amp;quot;&lt;/code&gt; or &lt;code&gt;region=&amp;quot;europe&amp;quot;&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;logql&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-logql&#34;&gt;{job=&amp;#34;api-server&amp;#34;}
{region=&amp;#34;europe&amp;#34;}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;match-multiple-values-with-a-regular-expression&#34;&gt;Match multiple values with a regular expression&lt;/h3&gt;
&lt;p&gt;Use the &lt;code&gt;=~&lt;/code&gt; operator to match a label against a regular expression. The following rule grants access to metrics in the &lt;code&gt;europe&lt;/code&gt; or &lt;code&gt;us-east&lt;/code&gt; region:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;logql&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-logql&#34;&gt;{region=~&amp;#34;europe|us-east&amp;#34;}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;exclude-a-label-value&#34;&gt;Exclude a label value&lt;/h3&gt;
&lt;p&gt;Use the &lt;code&gt;!=&lt;/code&gt; operator to exclude metrics that carry a specific label value. The following rule grants access to all metrics except those labeled &lt;code&gt;cluster=&amp;quot;restricted&amp;quot;&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;logql&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-logql&#34;&gt;{cluster!=&amp;#34;restricted&amp;#34;}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;user-on-multiple-teams&#34;&gt;User on multiple teams&lt;/h3&gt;
&lt;p&gt;Users on multiple teams receive access based on all the combined rules assigned to each team, combined with &lt;code&gt;OR&lt;/code&gt;. For example, if Team A has &lt;code&gt;{region=&amp;quot;europe&amp;quot;}&lt;/code&gt; and Team B has &lt;code&gt;{region=&amp;quot;us-east&amp;quot;}&lt;/code&gt;, a user on both teams can access metrics that match &lt;code&gt;region=&amp;quot;europe&amp;quot;&lt;/code&gt; or &lt;code&gt;region=&amp;quot;us-east&amp;quot;&lt;/code&gt;.&lt;/p&gt;
&lt;h2 id=&#34;related-resources&#34;&gt;Related resources&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
    &lt;a href=&#34;/docs/grafana/v13.1/administration/data-source-management/teamlbac/&#34;&gt;LBAC for data sources overview&lt;/a&gt; explains how LBAC works, which data sources are supported, and current limitations.&lt;/li&gt;
&lt;li&gt;
    &lt;a href=&#34;/docs/grafana/v13.1/administration/data-source-management/teamlbac/create-teamlbac-rules/&#34;&gt;Create LBAC for data sources rules for a supported data source&lt;/a&gt; explains how to define and manage rules.&lt;/li&gt;
&lt;/ul&gt;
]]></content><description>&lt;h1 id="configure-lbac-for-a-prometheus-data-source">Configure LBAC for a Prometheus data source&lt;/h1>
&lt;p>This document explains how to configure Label-Based Access Control (LBAC) for data sources for a Prometheus data source. LBAC for data sources filters the metrics that a team can query based on labels. You can configure it on both Grafana Cloud and Grafana Enterprise.&lt;/p></description></item><item><title>Configure LBAC for Tempo or Cloud Traces</title><link>https://grafana.com/docs/grafana/v13.1/administration/data-source-management/teamlbac/configure-teamlbac-for-tempo/</link><pubDate>Tue, 13 Oct 2026 14:23:35 +0000</pubDate><guid>https://grafana.com/docs/grafana/v13.1/administration/data-source-management/teamlbac/configure-teamlbac-for-tempo/</guid><content><![CDATA[&lt;h1 id=&#34;configure-lbac-for-tempo-or-cloud-traces&#34;&gt;Configure LBAC for Tempo or Cloud Traces&lt;/h1&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;Label-based access control for traces is currently in &lt;a href=&#34;/docs/release-life-cycle/&#34;&gt;public preview&lt;/a&gt;. Grafana Labs offers limited support, and breaking changes might occur prior to the feature being made generally available.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;


&lt;p&gt;This document explains how to configure Label-Based Access Control (LBAC) for data sources for a Tempo or Cloud Traces data source. LBAC for data sources lets you restrict which spans a team can access by defining rules based on trace attributes, providing fine-grained, team-based access control within a single tenant. It mirrors the experience used for logs and metrics LBAC in Grafana Cloud.&lt;/p&gt;
&lt;p&gt;Grafana uses LBAC as an umbrella term for label-based access control across all data sources. Traces use &lt;strong&gt;attributes&lt;/strong&gt;, not labels, for access control, but the Grafana UI surfaces this functionality as LBAC for consistency.&lt;/p&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;LBAC for traces is available only on Grafana Cloud. It isn&amp;rsquo;t available in Grafana Enterprise. It applies only to the Cloud-provisioned Tempo or Cloud Traces data source that Grafana hosts, not to self-managed data sources.&lt;/p&gt;
&lt;p&gt;Unlike logs and metrics, which also support data source-level LBAC through cloud access policies, traces LBAC is available only at the team level.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;h2 id=&#34;how-lbac-works&#34;&gt;How LBAC works&lt;/h2&gt;
&lt;p&gt;When a user queries a tracing data source, Grafana evaluates the user&amp;rsquo;s team memberships and the LBAC rules assigned to those teams. Grafana adds these rules to the request, so the Cloud Traces data source returns only permitted spans or attributes.&lt;/p&gt;
&lt;p&gt;LBAC rules use attribute selectors, such as:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;traceql&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-traceql&#34;&gt;{ resource.service.name=&amp;#34;checkout&amp;#34;, resource.env=&amp;#34;prod&amp;#34; }&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Multiple conditions in the same rule are combined with &lt;code&gt;AND&lt;/code&gt; (&lt;code&gt;,&lt;/code&gt;), while multiple rules across teams are combined with &lt;code&gt;OR&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;If none of a user&amp;rsquo;s teams have LBAC rules for the data source, that user can query all traces, subject to their data source permissions.&lt;/p&gt;
&lt;h2 id=&#34;before-you-begin&#34;&gt;Before you begin&lt;/h2&gt;
&lt;p&gt;Before you configure LBAC for data sources, ensure you have the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Permission to create a Tempo or Cloud Traces tenant in Grafana Cloud.&lt;/li&gt;
&lt;li&gt;Administrator permissions for Grafana.&lt;/li&gt;
&lt;li&gt;A team set up in Grafana.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;known-limitations&#34;&gt;Known limitations&lt;/h2&gt;
&lt;p&gt;Be aware of the following limitations for traces LBAC:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;LBAC for traces is available only at the team level. Data source-level LBAC rules, configured through cloud access policies, aren&amp;rsquo;t currently supported for traces. This differs from logs and metrics LBAC, which supports both team-level and data source-level rules.&lt;/li&gt;
&lt;li&gt;Autocomplete in search is still under development.&lt;/li&gt;
&lt;li&gt;Rules are restricted to resource scope attributes.&lt;/li&gt;
&lt;li&gt;Users with multiple rules may experience a slight performance degradation.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;configure-a-new-tempo-or-cloud-traces-data-source&#34;&gt;Configure a new Tempo or Cloud Traces data source&lt;/h2&gt;
&lt;p&gt;Follow this workflow when adding a new data source. The data source must be hosted by Grafana and not self-managed.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Start your Grafana Cloud instance.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Access Tempo or Cloud Traces data source details for your stack.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Copy the &lt;a href=&#34;/docs/grafana-cloud/send-data/traces/set-up/locate-url-user-password/&#34;&gt;details of your Tempo or Cloud Traces setup&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;In Grafana Cloud, navigate to &lt;strong&gt;Administration&lt;/strong&gt; &amp;gt; &lt;strong&gt;Users and access&lt;/strong&gt; &amp;gt; &lt;strong&gt;Cloud Access Policies&lt;/strong&gt;.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Create an access policy for the Tempo or Cloud Traces data source.&lt;/li&gt;
&lt;li&gt;Ensure the access policy includes &lt;code&gt;traces:read&lt;/code&gt; permissions.&lt;/li&gt;
&lt;li&gt;Ensure the access policy doesn&amp;rsquo;t include &lt;code&gt;labels&lt;/code&gt; rules. Data source-level LBAC isn&amp;rsquo;t supported for traces, so any &lt;code&gt;labels&lt;/code&gt; rules in the access policy are ignored.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;In Grafana, select the Tempo or Cloud Traces data source, or create a new one.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Navigate back to the Tempo or Cloud Traces data source.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Set up the data source using basic authentication. Use the &lt;a href=&#34;/docs/grafana-cloud/send-data/traces/set-up/locate-url-user-password/&#34;&gt;userID or tenantID&lt;/a&gt; as the username. Use the token from your access policy as the password.&lt;/li&gt;
&lt;li&gt;Select &lt;strong&gt;Save &amp;amp; test&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Go to the &lt;strong&gt;Permissions&lt;/strong&gt; tab of the newly created data source. Here, you find the LBAC for data sources rules section.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Choose a team from the &lt;strong&gt;Team&lt;/strong&gt; drop-down.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Enter attribute selectors, such as:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;traceql&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-traceql&#34;&gt;{ resource.service.name=&amp;#34;checkout&amp;#34;, resource.env=&amp;#34;prod&amp;#34; }&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Select &lt;strong&gt;Save&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;examples-of-lbac-rules&#34;&gt;Examples of LBAC rules&lt;/h2&gt;
&lt;p&gt;An LBAC rule for traces is an attribute selector that filters spans based on trace attributes. Each rule operates independently as its own filter, separate from other rules within a team.&lt;/p&gt;
&lt;p&gt;Follow these guidelines when you write rules:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Use only resource scope attributes, for example &lt;code&gt;{ resource.env=&amp;quot;prod&amp;quot; }&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Use double quotes for string values. Only string values are supported.&lt;/li&gt;
&lt;li&gt;Use the &lt;code&gt;=~&lt;/code&gt; operator for regular expression matching, for example &lt;code&gt;{ resource.team =~ &amp;quot;team-a|team-b&amp;quot; }&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;If you use negation (&lt;code&gt;!=&lt;/code&gt; or &lt;code&gt;!~&lt;/code&gt;), refer to &lt;a href=&#34;#troubleshoot-missing-service-traces&#34;&gt;Troubleshoot missing service traces&lt;/a&gt;. TraceQL negation behaves differently from PromQL when an attribute is missing.&lt;/li&gt;
&lt;li&gt;Use up to two conditions in a single rule, separated by a comma (&lt;code&gt;,&lt;/code&gt;), which acts as an &lt;code&gt;AND&lt;/code&gt; operator.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For more detail, refer to 
    &lt;a href=&#34;/docs/grafana/v13.1/administration/data-source-management/teamlbac/create-teamlbac-rules/&#34;&gt;Create LBAC for data sources rules for a supported data source&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&#34;single-rule&#34;&gt;Single rule&lt;/h3&gt;
&lt;p&gt;Multiple conditions in a single rule are combined with &lt;code&gt;AND&lt;/code&gt;. The following rule grants access to spans that match both &lt;code&gt;resource.service.name=&amp;quot;payments-api&amp;quot;&lt;/code&gt; and &lt;code&gt;resource.env=&amp;quot;prod&amp;quot;&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;traceql&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-traceql&#34;&gt;{ resource.service.name=&amp;#34;payments-api&amp;#34;, resource.env=&amp;#34;prod&amp;#34; }&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;match-multiple-values-with-a-regular-expression&#34;&gt;Match multiple values with a regular expression&lt;/h3&gt;
&lt;p&gt;Use the &lt;code&gt;=~&lt;/code&gt; operator to match an attribute against a regular expression. The following rule grants access to spans from &lt;code&gt;team-a&lt;/code&gt; or &lt;code&gt;team-b&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;traceql&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-traceql&#34;&gt;{ resource.team =~ &amp;#34;team-a|team-b&amp;#34; }&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;multiple-rules&#34;&gt;Multiple rules&lt;/h3&gt;
&lt;p&gt;Multiple rules assigned to the same team are combined with &lt;code&gt;OR&lt;/code&gt;. The following two rules grant access to spans in the &lt;code&gt;prod&lt;/code&gt; environment or spans from the &lt;code&gt;billing&lt;/code&gt; team:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;traceql&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-traceql&#34;&gt;{ resource.env=&amp;#34;prod&amp;#34; }
{ resource.team=&amp;#34;billing&amp;#34; }&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;user-on-multiple-teams&#34;&gt;User on multiple teams&lt;/h3&gt;
&lt;p&gt;Users on multiple teams receive access based on all the combined rules assigned to each team, combined with &lt;code&gt;OR&lt;/code&gt;. For example, if the teams have the following rules:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Team A: &lt;code&gt;{ resource.cluster=&amp;quot;us-east-1&amp;quot; }&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Team B: &lt;code&gt;{ resource.service.name=&amp;quot;frontend&amp;quot; }&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;A user on both teams can access spans that match &lt;code&gt;resource.cluster=&amp;quot;us-east-1&amp;quot;&lt;/code&gt; or &lt;code&gt;resource.service.name=&amp;quot;frontend&amp;quot;&lt;/code&gt;.&lt;/p&gt;
&lt;h2 id=&#34;how-lbac-affects-returned-data&#34;&gt;How LBAC affects returned data&lt;/h2&gt;
&lt;p&gt;How LBAC filters data depends on the endpoint:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Trace-by-ID lookups&lt;/strong&gt; use one of three redaction modes, described in the following sections, that control how non-matching spans are handled.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Search, metrics, and autocomplete endpoints&lt;/strong&gt; always return only the spans that match the LBAC rules, regardless of the configured redaction mode.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Cloud Traces supports three redaction modes for trace-by-ID lookups. The active mode is configured per tenant. To change the mode for your organization, contact Grafana Support.&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Mode&lt;/th&gt;
              &lt;th&gt;Non-matching spans&lt;/th&gt;
              &lt;th&gt;Best for&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;Attributes (default)&lt;/td&gt;
              &lt;td&gt;Kept, but attributes and intrinsics redacted&lt;/td&gt;
              &lt;td&gt;Preserving trace structure&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Spans&lt;/td&gt;
              &lt;td&gt;Removed entirely&lt;/td&gt;
              &lt;td&gt;Hiding the existence of spans (may break traces)&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Error&lt;/td&gt;
              &lt;td&gt;Entire request returns a &lt;code&gt;404&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Strict, all-or-nothing visibility&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;attributes-mode-default&#34;&gt;Attributes mode (default)&lt;/h3&gt;
&lt;p&gt;Non-matching spans are included in the response, but their attributes and intrinsics are redacted. Only the following minimal fields remain visible on redacted spans:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;traceId&lt;/code&gt;, &lt;code&gt;spanId&lt;/code&gt;, &lt;code&gt;parentId&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;name&lt;/code&gt;, &lt;code&gt;kind&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;timestamps&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;status&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You can extend the set of always-visible fields by configuring &lt;code&gt;allowed_attributes&lt;/code&gt;, which sets a list of scoped attributes and intrinsics that are never redacted. For example, you can set &lt;code&gt;span:name&lt;/code&gt;, &lt;code&gt;resource.service.name&lt;/code&gt;, &lt;code&gt;event:name&lt;/code&gt;, or &lt;code&gt;scope.version&lt;/code&gt; so they&amp;rsquo;re never redacted, even on non-matching spans. Contact Grafana Support to configure &lt;code&gt;allowed_attributes&lt;/code&gt; for your organization.&lt;/p&gt;
&lt;h3 id=&#34;spans-mode&#34;&gt;Spans mode&lt;/h3&gt;
&lt;p&gt;Non-matching spans are removed from the response entirely. This can result in broken traces where a returned span has no matching parent, creating gaps in the span tree.&lt;/p&gt;
&lt;h3 id=&#34;error-mode&#34;&gt;Error mode&lt;/h3&gt;
&lt;p&gt;If any span in a requested trace doesn&amp;rsquo;t match the LBAC policy, the entire request returns a &lt;code&gt;404&lt;/code&gt; error. This is the strictest mode and suits environments where partial trace visibility isn&amp;rsquo;t acceptable.&lt;/p&gt;
&lt;h2 id=&#34;troubleshoot-missing-service-traces&#34;&gt;Troubleshoot missing service traces&lt;/h2&gt;
&lt;p&gt;If a team can&amp;rsquo;t see traces from a service you expect, a negation rule combined with a missing attribute may be excluding those spans.&lt;/p&gt;
&lt;p&gt;If you&amp;rsquo;re familiar with PromQL label matching, TraceQL attribute selectors behave differently for negation.&lt;/p&gt;
&lt;p&gt;In PromQL, &lt;code&gt;labelFoo != &amp;quot;abc&amp;quot;&lt;/code&gt; matches series that don&amp;rsquo;t have &lt;code&gt;labelFoo&lt;/code&gt; or have a value other than &lt;code&gt;&amp;quot;abc&amp;quot;&lt;/code&gt;.
In TraceQL, &lt;code&gt;resource.attr != &amp;quot;abc&amp;quot;&lt;/code&gt; and &lt;code&gt;resource.attr !~ &amp;quot;abc&amp;quot;&lt;/code&gt; match only spans that &lt;strong&gt;have&lt;/strong&gt; &lt;code&gt;resource.attr&lt;/code&gt; and whose value matches the condition.
Spans that don&amp;rsquo;t include that attribute aren&amp;rsquo;t returned.&lt;/p&gt;
&lt;p&gt;This difference matters when you combine attributes in one rule with &lt;code&gt;,&lt;/code&gt; (AND).
For example, this rule matches only spans from &lt;code&gt;checkout-api&lt;/code&gt; that also have the &lt;code&gt;resource.k8s.namespace.name&lt;/code&gt; attribute.
Services such as &lt;code&gt;checkout-api&lt;/code&gt; that don&amp;rsquo;t set &lt;code&gt;resource.k8s.namespace.name&lt;/code&gt; won&amp;rsquo;t match, even if you want to include them.&lt;/p&gt;

&lt;div class=&#34;code-snippet code-snippet__mini&#34;&gt;&lt;div class=&#34;lang-toolbar__mini&#34;&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet code-snippet__border&#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-none&#34;&gt;{ resource.service.name=&amp;#34;checkout-api&amp;#34;, resource.k8s.namespace.name !~ &amp;#34;prod-main&amp;#34; }&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;To include services that don&amp;rsquo;t set the attribute, add a separate rule for each service.
Multiple rules for a team combine with &lt;strong&gt;OR&lt;/strong&gt;:&lt;/p&gt;

&lt;div class=&#34;code-snippet code-snippet__mini&#34;&gt;&lt;div class=&#34;lang-toolbar__mini&#34;&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet code-snippet__border&#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-none&#34;&gt;{ resource.service.name=&amp;#34;checkout-api&amp;#34;, resource.k8s.namespace.name !~ &amp;#34;prod-main&amp;#34; }
{ resource.service.name=&amp;#34;checkout-api&amp;#34; }&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Add similar OR rules for other services that don&amp;rsquo;t set the namespace attribute.&lt;/p&gt;
&lt;p&gt;To find services that don&amp;rsquo;t set an attribute, run this query in Grafana Explore:&lt;/p&gt;

&lt;div class=&#34;code-snippet code-snippet__mini&#34;&gt;&lt;div class=&#34;lang-toolbar__mini&#34;&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet code-snippet__border&#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-none&#34;&gt;{ resource.k8s.namespace.name = nil } | rate() by (resource.service.name)&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;This query returns services that don&amp;rsquo;t have &lt;code&gt;resource.k8s.namespace.name&lt;/code&gt; set.&lt;/p&gt;
&lt;h2 id=&#34;manage-lbac-rules&#34;&gt;Manage LBAC rules&lt;/h2&gt;
&lt;p&gt;You can edit or delete existing LBAC rules from the data source&amp;rsquo;s &lt;strong&gt;Permissions&lt;/strong&gt; tab.&lt;/p&gt;
&lt;h3 id=&#34;edit-an-lbac-rule&#34;&gt;Edit an LBAC rule&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;Open your stack and select your &lt;strong&gt;Tempo&lt;/strong&gt; or &lt;strong&gt;Cloud Traces&lt;/strong&gt; data source.&lt;/li&gt;
&lt;li&gt;Select &lt;strong&gt;Permissions&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Scroll to &lt;strong&gt;Data access&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Select the rule you want to edit and select the pencil (edit) icon.&lt;/li&gt;
&lt;li&gt;Modify the &lt;strong&gt;Attribute filters&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Select &lt;strong&gt;Save&lt;/strong&gt;.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&#34;delete-an-lbac-rule&#34;&gt;Delete an LBAC rule&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;Open your stack and select your &lt;strong&gt;Tempo&lt;/strong&gt; or &lt;strong&gt;Cloud Traces&lt;/strong&gt; data source.&lt;/li&gt;
&lt;li&gt;Select &lt;strong&gt;Permissions&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Scroll to &lt;strong&gt;Data access&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Select the rule you want to delete.&lt;/li&gt;
&lt;li&gt;Select the &lt;strong&gt;X&lt;/strong&gt; (delete) icon.&lt;/li&gt;
&lt;li&gt;Confirm the deletion.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;related-resources&#34;&gt;Related resources&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
    &lt;a href=&#34;/docs/grafana/v13.1/administration/data-source-management/teamlbac/&#34;&gt;LBAC for data sources overview&lt;/a&gt; explains how LBAC works, which data sources are supported, and current limitations.&lt;/li&gt;
&lt;li&gt;
    &lt;a href=&#34;/docs/grafana/v13.1/administration/data-source-management/teamlbac/create-teamlbac-rules/&#34;&gt;Create LBAC for data sources rules for a supported data source&lt;/a&gt; explains how to define and manage rules.&lt;/li&gt;
&lt;li&gt;
    &lt;a href=&#34;/docs/tempo/latest/traceql/construct-traceql-queries/&#34;&gt;Construct a TraceQL query&lt;/a&gt; explains attribute selector syntax, including &lt;code&gt;!=&lt;/code&gt;, &lt;code&gt;!~&lt;/code&gt;, and &lt;code&gt;= nil&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
    &lt;a href=&#34;/docs/grafana/v13.1/datasources/tempo/query-editor/traceql-search/&#34;&gt;Search traces using the query builder&lt;/a&gt; explains how to run the diagnostic query in Explore.&lt;/li&gt;
&lt;/ul&gt;
]]></content><description>&lt;h1 id="configure-lbac-for-tempo-or-cloud-traces">Configure LBAC for Tempo or Cloud Traces&lt;/h1>
&lt;div class="admonition admonition-note">&lt;blockquote>&lt;p class="title text-uppercase">Note&lt;/p>&lt;p>Label-based access control for traces is currently in &lt;a href="/docs/release-life-cycle/">public preview&lt;/a>. Grafana Labs offers limited support, and breaking changes might occur prior to the feature being made generally available.&lt;/p></description></item></channel></rss>