Connecting to Grafana
Using API Key Authentication
Grafana uses token authentication to control access to the API. To authenticate, set the APIKey property to your Grafana API Key or Service Account Token. To create a Service Account Token, in your Grafana account, open the side menu and click the Administration dropdown and select "Users and Access" followed by the "Service accounts" option. After creating a new service account, access its page, then click "Add service account token". On older versions of Grafana, a Grafana API Key may be used instead.
After setting the following connection properties, you are ready to connect:
- APIKey: Set this to your Grafana API Key or Service Account Token.
- Domain: Set this to the domain portion of your Grafana URL (e.g. 'acmeinc' for https://acmeinc.grafana.net/). For self-hosted instances, use the URL property instead.
Example Connection String
Profile=C:\profiles\Grafana.apip;ProfileSettings='Domain=your_domain;APIKey=my_api_key';
If using a self-hosted Grafana instance, use the URL property in ProfileSettings instead of Domain .
Profile=C:\profiles\Grafana.apip;ProfileSettings='URL=http://localhost:3000;APIKey=my_token';
Connecting to Grafana
Once the authentication is configured, you can connect to Grafana and query data from any of the available tables such as Alerts, DataSources, Dashboards, Folders, and Teams.
Available Tables
The Grafana API Profile provides access to the following tables:
- Alert: Retrieve a single alert by Id (requires Id)
- Alerts: Retrieve all alerts for the current organization
- Annotations: Retrieve all annotations
- CurrentOrganization: Retrieve details about the current organization
- CurrentOrganizationUsers: Retrieve all users within the current organization (requires org admin role)
- DashboardByUid: Retrieve a dashboard by its unique identifier (requires Uid)
- DashboardPermissions: Retrieve all permissions for a specified dashboard (requires DashboardId)
- DashboardsTags: Retrieve all tags used across dashboards
- DashboardVersion: Retrieve details for a specific dashboard version (requires DashboardId)
- DashboardVersions: Retrieve all versions for a specified dashboard (requires DashboardId)
- DataSource: Retrieve a specific data source by Id or Name (requires Id or Name)
- DataSources: Retrieve all data sources
- Folder: Retrieve a folder by its unique identifier (requires Uid)
- FolderPermissions: Retrieve all permissions for a specified folder (requires FolderUid)
- Folders: Retrieve all folders that the authenticated user has permission to view
- HomeDashboard: Retrieve the home dashboard for the current organization
- NotificationChannels: Retrieve all notification channels the authenticated user has permission to view
- Playlist: Retrieve a playlist by Id (requires Id)
- PlaylistDashboards: Retrieve dashboards assigned to a specified playlist (requires PlaylistId)
- PlaylistItems: Retrieve items within a specified playlist (requires PlaylistId)
- Playlists: Retrieve all playlists for the current organization
- Snapshot: Retrieve a snapshot by its key (requires Key)
- Snapshots: Retrieve all snapshots
- TeamMembers: Retrieve members of a specified team (requires TeamId)
- TeamPreferences: Retrieve preferences of a specified team (requires TeamId)
- Teams: Retrieve all teams for the current organization (requires org admin role)
Important Notes
- Several tables require a parent identifier (e.g. DashboardId, PlaylistId, TeamId, Uid, Key) to be specified as a filter in the WHERE clause.
- Tables that access organization-wide data (e.g. CurrentOrganizationUsers, Teams) require the authenticated user to have the org admin role.
- Grafana API Keys are deprecated in newer versions of Grafana; prefer using Service Account Tokens where possible.
API Documentation
For more information about the Grafana API, see the official Grafana API documentation.
Usage Examples
Alerts:
SELECT * FROM Alerts
Alert:
SELECT * FROM Alert WHERE Id = '1'
Annotations:
SELECT * FROM Annotations
CurrentOrganization:
SELECT * FROM CurrentOrganization
CurrentOrganizationUsers:
SELECT * FROM CurrentOrganizationUsers
DashboardByUid:
SELECT * FROM DashboardByUid WHERE Uid = 'your-dashboard-uid'
DashboardPermissions:
SELECT * FROM DashboardPermissions WHERE DashboardId = '1'
DashboardsTags:
SELECT * FROM DashboardsTags
DashboardVersions:
SELECT * FROM DashboardVersions WHERE DashboardId = '1'
DashboardVersion:
SELECT * FROM DashboardVersion WHERE DashboardId = '1'
DataSources:
SELECT * FROM DataSources
DataSource:
SELECT * FROM DataSource WHERE Id = '1'
Folders:
SELECT * FROM Folders
Folder:
SELECT * FROM Folder WHERE Uid = 'your-folder-uid'
FolderPermissions:
SELECT * FROM FolderPermissions WHERE FolderUid = 'your-folder-uid'
HomeDashboard:
SELECT * FROM HomeDashboard
NotificationChannels:
SELECT * FROM NotificationChannels
Playlists:
SELECT * FROM Playlists
Playlist:
SELECT * FROM Playlist WHERE Id = '1'
PlaylistDashboards:
SELECT * FROM PlaylistDashboards WHERE PlaylistId = '1'
PlaylistItems:
SELECT * FROM PlaylistItems WHERE PlaylistId = '1'
Snapshots:
SELECT * FROM Snapshots
Snapshot:
SELECT * FROM Snapshot WHERE Key = 'your-snapshot-key'
Teams:
SELECT * FROM Teams
TeamMembers:
SELECT * FROM TeamMembers WHERE TeamId = '1'
TeamPreferences:
SELECT * FROM TeamPreferences WHERE TeamId = '1'
Connection Properties
The connection string properties are the various options that can be used to establish a connection. This section provides a complete list of the options you can configure in the connection string for this provider.
| Property | Description |
| APIKey | Your Grafana API Key or Service Account Token. Both are sent as Bearer tokens. |
| AuthScheme | The scheme used for authentication. Accepted entries are APIKey or None. Allowed values are: BASIC, NONE, NTLM, OAUTH, APIKEY, OAUTH_CLIENT, OAUTH_PASSWORD |
| Domain | The domain for the Grafana account. |
| URL | URL of the Grafana instance. |