<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>GEM Admin API on Grafana Labs</title><link>https://grafana.com/docs/enterprise-metrics/v2.17.x/api/admin-api/</link><description>Recent content in GEM Admin API on Grafana Labs</description><generator>Hugo -- gohugo.io</generator><language>en</language><atom:link href="/docs/enterprise-metrics/v2.17.x/api/admin-api/index.xml" rel="self" type="application/rss+xml"/><item><title>Leadership election</title><link>https://grafana.com/docs/enterprise-metrics/v2.17.x/api/admin-api/leadership-election/</link><pubDate>Mon, 18 Aug 2025 18:19:44 +0000</pubDate><guid>https://grafana.com/docs/enterprise-metrics/v2.17.x/api/admin-api/leadership-election/</guid><content><![CDATA[&lt;h2 id=&#34;leadership-election&#34;&gt;Leadership election&lt;/h2&gt;
&lt;p&gt;The &lt;a href=&#34;/docs/enterprise-metrics/v2.17.x/api/admin-api/&#34;&gt;admin API&lt;/a&gt; allows you to create and manage resources in your Grafana Enterprise
Metrics (GEM) cluster such as tenants, access policies, and tokens. When performing operations that modify
resources such as updates or deletes, the admin API requires the use of resource version numbers to make
sure the most recent version of resources are being operated on. An additional safety feature the
admin API makes use of to ensure concurrent modifications don&amp;rsquo;t overwrite each other is
&lt;a href=&#34;https://aws.amazon.com/builders-library/leader-election-in-distributed-systems/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;leadership election&lt;/a&gt;. Admin
API components elect a single component to perform all modification requests, making sure that simultaneous
requests don&amp;rsquo;t overwrite each other. Details about how to configure or disable this feature are provided below.&lt;/p&gt;
&lt;h2 id=&#34;configuration&#34;&gt;Configuration&lt;/h2&gt;
&lt;p&gt;Leadership election is a recommended feature of the GEM admin API, and is therefore enabled by default. It can be
configured or disabled under the &lt;code&gt;admin_api&lt;/code&gt; section of the GEM

    &lt;a href=&#34;/docs/enterprise-metrics/v2.17.x/configure/config-gem/reference/#admin_api&#34;&gt;configuration file&lt;/a&gt;.
Leadership election uses the same mechanism as other GEM components to coordinate among themselves, the
&lt;a href=&#34;/docs/mimir/latest/operators-guide/architecture/hash-ring/&#34;&gt;hash ring&lt;/a&gt;. This means you need to configure
this instance of the ring the same way you configured the ring used by distributors and ingesters when
setting up your GEM cluster.&lt;/p&gt;
&lt;p&gt;An example of this configuration is provided below using the
&lt;a href=&#34;/docs/mimir/latest/operators-guide/architecture/memberlist-and-the-gossip-protocol/&#34;&gt;memberlist gossip ring&lt;/a&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;YAML&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-yaml&#34;&gt;admin_api:
  leader_election:
    ring:
      kvstore:
        store: memberlist
      tokens_observe_period: 0&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Note that any supported backend (Etcd, Consul, or memberlist) can be used for leader election with
the admin API, memberlist is only used as an example here. For simplicity, it is recommended to use whatever
ring backend you are already making use of for other GEM components.&lt;/p&gt;
&lt;h2 id=&#34;implementation&#34;&gt;Implementation&lt;/h2&gt;
&lt;p&gt;Admin API leadership election does not require a &lt;a href=&#34;https://en.wikipedia.org/wiki/Quorum_%28distributed_computing%29&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;quorum&lt;/a&gt; to operate like other uses of the ring
in GEM components. This means it is not required to run an odd number of admin API components. Instead, it
is sufficient to run two for redundancy.&lt;/p&gt;
&lt;h2 id=&#34;disabling-leadership-election&#34;&gt;Disabling Leadership Election&lt;/h2&gt;
&lt;p&gt;Leadership election can be disabled under the &lt;code&gt;admin_api&lt;/code&gt; section of the GEM

    &lt;a href=&#34;/docs/enterprise-metrics/v2.17.x/configure/config-gem/reference/#admin_api&#34;&gt;configuration file&lt;/a&gt;. This is not recommended and
leadership election will be enabled permanently in a future release.&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;YAML&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-yaml&#34;&gt;admin_api:
  leader_election:
    enabled: false&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
]]></content><description>&lt;h2 id="leadership-election">Leadership election&lt;/h2>
&lt;p>The &lt;a href="/docs/enterprise-metrics/v2.17.x/api/admin-api/">admin API&lt;/a> allows you to create and manage resources in your Grafana Enterprise
Metrics (GEM) cluster such as tenants, access policies, and tokens. When performing operations that modify
resources such as updates or deletes, the admin API requires the use of resource version numbers to make
sure the most recent version of resources are being operated on. An additional safety feature the
admin API makes use of to ensure concurrent modifications don&amp;rsquo;t overwrite each other is
&lt;a href="https://aws.amazon.com/builders-library/leader-election-in-distributed-systems/" target="_blank" rel="noopener noreferrer">leadership election&lt;/a>. Admin
API components elect a single component to perform all modification requests, making sure that simultaneous
requests don&amp;rsquo;t overwrite each other. Details about how to configure or disable this feature are provided below.&lt;/p></description></item><item><title>Audit logging</title><link>https://grafana.com/docs/enterprise-metrics/v2.17.x/api/admin-api/audit-logging/</link><pubDate>Mon, 18 Aug 2025 18:19:44 +0000</pubDate><guid>https://grafana.com/docs/enterprise-metrics/v2.17.x/api/admin-api/audit-logging/</guid><content><![CDATA[&lt;h2 id=&#34;admin-api-audit-logging&#34;&gt;Admin API Audit logging&lt;/h2&gt;
&lt;p&gt;An audit log is available for actions on the Admin API path. This captures any HTTP requests against
&lt;code&gt;/admin/api/*&lt;/code&gt; and outputs them to the standard logger, tagged with &lt;code&gt;level=audit&lt;/code&gt; for filtering.&lt;/p&gt;
&lt;p&gt;The following fields may be present on each log line depending on the API endpoint called:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;traceID&lt;/code&gt;: The jaeger-trace-id if &lt;a href=&#34;/docs/mimir/latest/configure/configure-tracing/&#34;&gt;configured&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;requestURI&lt;/code&gt;: The URI of the incoming request.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;httpMethod&lt;/code&gt;: The HTTP method of the incoming request.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;remoteIPAddress&lt;/code&gt;: The IP address of the requesting client, either the address of the proxy in front of this admin API instance (if there is one), or the original source of the request if it connects directly to this admin API instance.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;forwardedIPAddress&lt;/code&gt;: The forwarded IP address if &lt;code&gt;X-Forwarded-For&lt;/code&gt; is set by a proxy.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;requestBody&lt;/code&gt;: The HTTP body sent with the request.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;httpStatus&lt;/code&gt;: The HTTP response code sent back to the client.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;reason&lt;/code&gt;: If available, the reason for the specific &lt;code&gt;httpStatus&lt;/code&gt;. For example, failed authentication.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;authorization&lt;/code&gt;: The method used for authorization.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;authFromCache&lt;/code&gt;: &lt;code&gt;true&lt;/code&gt; if successful authentication came from a 
    &lt;a href=&#34;/docs/enterprise-metrics/v2.17.x/configure/config-gem/reference/#auth&#34;&gt;cache check&lt;/a&gt;, otherwise &lt;code&gt;false&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;tokenID&lt;/code&gt;: The token ID of the authenticated user, or the subject if using 
    &lt;a href=&#34;/docs/enterprise-metrics/v2.17.x/manage/oauth/&#34;&gt;OAuth integration&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;accessPolicyID&lt;/code&gt;: The access policy ID of the requesting token.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;webauth-user&lt;/code&gt;: The username as set by the header configured by 
    &lt;a href=&#34;/docs/enterprise-metrics/v2.17.x/configure/config-gem/reference/#admin_api&#34;&gt;user_header_name&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;X-Grafana-Org-Id&lt;/code&gt; and &lt;code&gt;X-Grafana-User&lt;/code&gt;: The respective headers as sent by the requesting client. &lt;a href=&#34;/docs/grafana/latest/setup-grafana/configure-grafana/#send_user_header&#34;&gt;You can configure Grafana&lt;/a&gt; to send this information about the user interacting with the API.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;configuration&#34;&gt;Configuration&lt;/h2&gt;
&lt;p&gt;Audit logs are disabled by default. They can be configured under the &lt;code&gt;admin_api&lt;/code&gt; section of the GEM

    &lt;a href=&#34;/docs/enterprise-metrics/v2.17.x/configure/config-gem/reference/#admin_api&#34;&gt;configuration file&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;For example:&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;YAML&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-yaml&#34;&gt;admin_api:
  auditlogging:
    enabled: true&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;request-body-logging&#34;&gt;Request body logging&lt;/h2&gt;
&lt;p&gt;By default, when Admin API audit logging is enabled, the body of the HTTP request is also logged.&lt;/p&gt;
&lt;p&gt;As the body could potentially be large, the size of the request body is limited by the value of the &lt;code&gt;-admin-api.max-request-body-size-bytes&lt;/code&gt; flag (default 10MiB).
If this limit is exceeded, the request will be rejected with an HTTP 413 response.&lt;/p&gt;
&lt;p&gt;Alternatively, you can disable logging the request body with the &lt;code&gt;-admin-api.log-request-body&lt;/code&gt; flag.&lt;/p&gt;
&lt;h2 id=&#34;example-log-output&#34;&gt;Example log output&lt;/h2&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;level=audit ts=2023-05-26T12:07:03.859986132Z traceID=45a25b15f51938d0 requestURI=/admin/api/v3/tenants httpMethod=POST remoteIPAddress=172.20.0.1 requestBody=&amp;#34;{\n  \&amp;#34;name\&amp;#34;: \&amp;#34;acme\&amp;#34;,\n  \&amp;#34;display_name\&amp;#34;: \&amp;#34;Acme Co.\&amp;#34;,\n  \&amp;#34;created_at\&amp;#34;: \&amp;#34;2023-04-13T17:37:59.341728283Z\&amp;#34;,\n  \&amp;#34;status\&amp;#34;: \&amp;#34;active\&amp;#34;,\n  \&amp;#34;cluster\&amp;#34;: \&amp;#34;enterprise-metrics\&amp;#34;,\n  \&amp;#34;limits\&amp;#34;: {\n    \&amp;#34;ruler_max_rule_groups_per_tenant\&amp;#34;: 1\n  }\n}&amp;#34; httpStatus=200 authorization=bearer authFromCache=false tokenID=myuser accessPolicyID=admin-ap&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
]]></content><description>&lt;h2 id="admin-api-audit-logging">Admin API Audit logging&lt;/h2>
&lt;p>An audit log is available for actions on the Admin API path. This captures any HTTP requests against
&lt;code>/admin/api/*&lt;/code> and outputs them to the standard logger, tagged with &lt;code>level=audit&lt;/code> for filtering.&lt;/p></description></item></channel></rss>