Introduction
Grafana stores its users, dashboards, organizations, and settings in a database. If you are using PostgreSQL as the Grafana database, you can create a dashboard to monitor important information such as:
• Total users
• Admin users
• Active users
• Organizations
• Datasources
• Dashboard changes
This guide explains how to create a PostgreSQL monitoring dashboard in Grafana step by step.
Prerequisites
Before starting, make sure you have:
Grafana installed
PostgreSQL configured as Grafana’s database
Access to the PostgreSQL database
Grafana Admin privileges
Step 1: Verify PostgreSQL Connection
Open the Grafana configuration file:
and then restart the grafana
Step 2: Add PostgreSQL as a Data Source
- Login to Grafana.
- Click Connections → Data Sources.
- Click Add Data Source.
- Select PostgreSQL.
Step 3: Create a New Dashboard
- Click Dashboards.
- Click New Dashboard.
- Click Add Visualization.
- Select your PostgreSQL datasource.
No of users with Admin Previleges
SELECT
COUNT(*) AS admin_user_count
FROM public.org_user
WHERE role = 'Admin';
Active users information in last 24 hours
SELECT
o.name AS org_name,
u.id AS user_id,
u.login AS user_login,
u.last_seen_at
FROM
public.user u
JOIN
public.org o ON u.org_id = o.id
WHERE
u.last_seen_at >= NOW() - INTERVAL '1 day'
ORDER BY
u.last_seen_at DESC;
Datasources by Org
select count(a.*), b."name" from public.data_source as a join public.org as b on a.org_id = b.id
group by b."name"
Note: Create more panels and KPIs based on Grafana database tables to monitor platform activity, such as active users, dashboards modified in the last week, total dashboards, total datasources, total users, organizations, admin users, login activity, and dashboard usage statistics. This will help administrators gain better visibility into Grafana usage and system health.




