---
title: "How do I troubleshoot setting up Grafana for ITRS Analytics?"
description: "Grafana integration with ITRS Analytics requires correct grafana.ini hostname and OAuth settings, Keycloak redirect URLs, realm role mappers, and a user with admin rights."
url: "https://docs.itrsgroup.com/docs/faq/itrs-analytics/27942772467997-itrs-analytics-troubleshooting-setting-up-grafana-for-itrs-analytics/index.html"
---
The sections below cover additional configuration points that commonly cause login or data access issues. If you have not yet configured Grafana authentication with ITRS Analytics, refer to [Configure Grafana authentication with ITRS Analytics](https://docs.itrsgroup.com/docs/itrs-analytics/latest/faqs/how-to-configure-grafana-authentication/index.html). 

## Configure grafana.ini

The `domain` setting is often left as `localhost`. Change it to the hostname or FQDN where Grafana is accessed.

Update the relevant fields in `grafana.ini`. Replace the example hostname and OAuth URLs with your ITRS Analytics server address. Obtain `client_secret` from your Keycloak `obcerv-apps` client configuration.

Below is an example of a `grafana.ini` file:

```
## The http port to use
http_port = 3000

## The public facing domain name used to access grafana from a browser
domain = ec2-18-171-143-13.eu-west-2.compute.amazonaws.com

#################################### Generic OAuth #######################
[auth.generic_oauth]
name = ITRS Analytics
enabled = true
allow_sign_up = true
client_id = obcerv-apps
client_secret = LZplLkJSag4lPRJhUXGA4OGxqpqV0ZEP
scopes = openid profile email offline_access roles
email_attribute_path = email
login_attribute_path = username
name_attribute_path = full_name
role_attribute_path = contains(roles[*], 'admin') && 'GrafanaAdmin' || 'Editor'
auth_url = https://ec2-18-171-143-13.eu-west-2.compute.amazonaws.com/auth/realms/obcerv/protocol/openid-connect/auth
token_url = https://ec2-18-171-143-13.eu-west-2.compute.amazonaws.com/auth/realms/obcerv/protocol/openid-connect/token
api_url = https://ec2-18-171-143-13.eu-west-2.compute.amazonaws.com/auth/realms/obcerv/protocol/openid-connect/userinfo
tls_skip_verify_insecure = true
```

Restart Grafana after saving changes.

## Configure Keycloak

### Valid redirect URLs

Configure valid redirect URLs for the Grafana OAuth client as shown below:

![ITRS Analytics - Keycloak valid redirect URLs](https://docscdn.itrsgroup.com/faq/images/itrs-analytics/27942772467997-27942772455965-mceclip1.png)

### Realm roles mapper

Configure the realm roles mapper as shown below:

![ITRS Analytics - Keycloak realm roles mapper](https://docscdn.itrsgroup.com/faq/images/itrs-analytics/27942772467997-27942786190365-mceclip3.png)

Set **Token Claim Name** to `roles`:

![ITRS Analytics - Keycloak token claim name](https://docscdn.itrsgroup.com/faq/images/itrs-analytics/27942772467997-27942786190749-mceclip4.png)

### Grafana user

Create a user in Keycloak with admin role rights:

1. Create a user under **Users**. Enter an email address. The address does not need to be a valid mailbox.

   ![ITRS Analytics - Create Keycloak user](https://docscdn.itrsgroup.com/faq/images/itrs-analytics/27942772467997-27942786191133-mceclip5.png)

2. Set a password for the user.

   ![ITRS Analytics - Set Keycloak user password](https://docscdn.itrsgroup.com/faq/images/itrs-analytics/27942772467997-27942772456733-mceclip6.png)

3. Clear the **Temporary** option so the password does not expire on first login.

   ![ITRS Analytics - Disable temporary password](https://docscdn.itrsgroup.com/faq/images/itrs-analytics/27942772467997-27942772456989-mceclip7.png)

4. Under **Realm roles**, create an `admin` role if it does not already exist.

   ![ITRS Analytics - Create realm role](https://docscdn.itrsgroup.com/faq/images/itrs-analytics/27942772467997-27942772457373-mceclip8.png)

5. For the Grafana user, assign **client roles**:

   ![ITRS Analytics - Assign client roles](https://docscdn.itrsgroup.com/faq/images/itrs-analytics/27942772467997-27942786197405-mceclip10.png)

6. Assign **realm roles** to the user:

   ![ITRS Analytics - Assign realm roles](https://docscdn.itrsgroup.com/faq/images/itrs-analytics/27942772467997-27942786198685-mceclip11.png)

The user should have both client and realm roles assigned:

![ITRS Analytics - User role assignment result](https://docscdn.itrsgroup.com/faq/images/itrs-analytics/27942772467997-27945737697821-mceclip13.png)

## Verify Grafana access

1. Log in to Grafana with the Keycloak user you created.

   ![ITRS Analytics - Grafana login](https://docscdn.itrsgroup.com/faq/images/itrs-analytics/27942772467997-27945752933789-mceclip14.png)

2. Complete the ITRS Analytics OAuth login when redirected:

   ![ITRS Analytics - ITRS Analytics OAuth login](https://docscdn.itrsgroup.com/faq/images/itrs-analytics/27942772467997-27945737705117-mceclip15.png)

3. In Grafana, go to **Connections** > **Data sources** and open **Explore**:

   ![ITRS Analytics - Grafana Explore](https://docscdn.itrsgroup.com/faq/images/itrs-analytics/27942772467997-27945737706269-mceclip16.png)

4. Open the **Metrics** drop-down and start typing a metric name, for example, `cpuutilisation`. Matching entries should appear as you type.

   ![ITRS Analytics - Select metric](https://docscdn.itrsgroup.com/faq/images/itrs-analytics/27942772467997-27945752938909-mceclip17.png)

   ![ITRS Analytics - Metric suggestions](https://docscdn.itrsgroup.com/faq/images/itrs-analytics/27942772467997-27945752940701-mceclip18.png)

5. Click **Run query**. Data should appear in the results panel:

   ![ITRS Analytics - Query results](https://docscdn.itrsgroup.com/faq/images/itrs-analytics/27942772467997-27945737714845-mceclip19.png)


