> For the complete documentation index, see [llms.txt](https://docs.defguard.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.defguard.net/1.6/features/openid-connect/grafana-setup.md).

# Grafana setup

#### Add grafana app on defguard

First, go to the Defguard OpenID tab and click add new app button.

1. Add the name Grafana
2. Redirect Url add `https://<grafana domain>/login/generic_oauth` where is the address of your grafana instance.
3. Select the below scopes

* OpenID
* Profile
* Email Then add your app. After successfully adding your app you can see it in the OpenID apps list. When you click on it you will be redirected to the client details page. From this page copy Client ID and Client secret values for later.

#### Grafana setup

1. Open your [grafana config](https://grafana.com/docs/grafana/latest/setup-grafana/configure-grafana/#config-file-locations) which is located in `/etc/grafana/grafana.ini` if you're using linux if you're using other operating system see link above.
2. In auth section of your configuration file append the template from below and fill it with corresponding values.

```
#################################### Auth Defguard ##########################
[auth.generic_oauth]
name = Defguard
icon = signin
enabled = true
client_id = <YOUR_APP_CLIENT_ID>  # from Defguard page
client_secret = <YOUR_APP_CLIENT_SECRET> # from Defguard page
scopes = openid profile email
empty_scopes = false
auth_url = https://<your_defguards_instance>/api/v1/oauth/authorize
token_url = https://<your_defguard_instance>/api/v1/oauth/token
api_url = https://<your_defguard_instance>/api/v1/oauth/userinfo
allow_sign_up = true
```

1. Restart your grafana server using `systemctl restart grafana-server`
2. Then on login, you'll see the `Sign-in Defguard button`


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.defguard.net/1.6/features/openid-connect/grafana-setup.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
