GitHub GraphQL API
Query GitHub repositories, issues, pull requests, and organization data using the GitHub GraphQL API.
Before you begin
- A GitHub account
- A Personal Access Token (PAT) with appropriate scopes (for example,
repo,read:org)
Configure the data source
- In Grafana, navigate to Connections > Data sources.
- Click Add new data source and select Infinity.
- Expand the Authentication section and select Bearer Token.
- Enter your GitHub Personal Access Token.
- In Allowed hosts, enter
https://api.github.com. - Click Save & test.
Tip
You can also use Basic Authentication with your GitHub username and PAT as the password, but Bearer Token is the recommended approach.
Query GitHub data
Use GraphQL queries to retrieve GitHub data. The GitHub GraphQL endpoint is https://api.github.com/graphql.
Basic query setup
- In the query editor, set Type to GraphQL.
- Set URL to
https://api.github.com/graphql. - Set Parser to Backend or UQL.
- Enter your GraphQL query.
- Set the Root selector to extract your data (for example,
data.repository.issues.edges).
Query examples
List repository issues
GraphQL query:
{
repository(owner: "grafana", name: "grafana") {
issues(last: 20) {
edges {
node {
author {
login
}
state
title
url
}
}
}
}
}Root selector: data.repository.issues.edges
Columns:
Organization repository summary
Query multiple repositories in an organization:
{
repositoryOwner(login: "grafana") {
repositories(first: 100) {
nodes {
name
stargazerCount
issues(states: OPEN) {
totalCount
}
pullRequests(states: OPEN) {
totalCount
}
}
}
}
}Root selector: data.repositoryOwner.repositories.nodes
Columns:
Pull request metrics
{
repository(owner: "grafana", name: "grafana") {
pullRequests(last: 50, states: MERGED) {
nodes {
title
mergedAt
author {
login
}
additions
deletions
}
}
}
}Root selector: data.repository.pullRequests.nodes
Use template variables
Replace hardcoded values with Grafana template variables:
{
repository(owner: "${GithubOrg}", name: "${GithubRepo}") {
issues(last: 20, states: OPEN) {
edges {
node {
title
state
createdAt
}
}
}
}
}Create dashboard variables for GithubOrg and GithubRepo to make the dashboard dynamic.
Provision the data source
Configure GitHub authentication through provisioning:
apiVersion: 1
datasources:
- name: GitHub Infinity
type: yesoreyeram-infinity-datasource
jsonData:
auth_method: bearerToken
allowedHosts:
- https://api.github.com
secureJsonData:
bearerToken: YOUR_GITHUB_PATTroubleshoot
Limitations
- Queries are not automatically paginated. For large result sets, use cursor-based pagination in your GraphQL query.
- GitHub API rate limits apply (5,000 requests per hour for authenticated requests).
- For comprehensive GitHub analytics with built-in pagination, consider the GitHub data source.



