Google Sheets
Query data directly from Google Sheets spreadsheets without exporting to CSV. The Infinity data source connects to the Google Sheets API to retrieve live data.
Note
Google Sheets is a beta feature.
Before you begin
- A Google Cloud project with the Google Sheets API enabled.
- A service account with access to your spreadsheet.
- The service account JSON key file.
Create a Google Cloud service account
- Go to the Google Cloud Console.
- Create a new project or select an existing one.
- Navigate to APIs & Services > Library.
- Search for “Google Sheets API” and enable it.
- Navigate to APIs & Services > Credentials.
- Click Create Credentials > Service account.
- Enter a name and description for the service account.
- Click Create and Continue, then Done.
- Click on the newly created service account.
- Go to the Keys tab and click Add Key > Create new key.
- Select JSON and click Create.
- Save the downloaded JSON key file securely.
Share your spreadsheet
The service account needs access to your spreadsheet:
- Open your Google Sheet.
- Click Share.
- Add the service account email (found in the JSON key file as
client_email). - Grant Viewer access (or Editor if you need write access).
- Click Send.
Configure the data source
- In Grafana, navigate to Connections > Data sources.
- Click Add new data source and select Infinity.
- Expand the Authentication section.
- Click Guided auth config providers and select Google JWT.
- Paste the contents of your service account JSON key file.
- Enter the required scope:
https://www.googleapis.com/auth/spreadsheets.readonly - Click Update OAuth2 settings.
- In Allowed hosts, add
https://sheets.googleapis.com. - Click Save & test.
Alternatively, configure OAuth2 manually:
- Select OAuth2 as the authentication method.
- Select JWT as the OAuth2 type.
- Enter the following from your JSON key file:
- Email: The
client_emailvalue - Private Key ID: The
private_key_idvalue - Token URL: The
token_urivalue (usuallyhttps://oauth2.googleapis.com/token) - Private Key: The
private_keyvalue
- Email: The
- Add the scope:
https://www.googleapis.com/auth/spreadsheets.readonly
Query Google Sheets data
- In the query editor, select Google Sheets as the Type.
- Configure the query settings:
Find the Sheet ID
The Sheet ID is the long string in your Google Sheets URL:
https://docs.google.com/spreadsheets/d/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/edit
└──────────────── Sheet ID ────────────────┘Configure columns
After specifying the Sheet ID and Range, configure the columns to extract:
- Click Add Columns.
- For each column:
- Selector: The column header name from your spreadsheet
- Title: Display name in Grafana
- Type: Data type (String, Number, Time, etc.)
The first row of your range is used as column headers.
Use template variables
You can use Grafana template variables in all Google Sheets query fields:
Sheet ID: ${spreadsheet_id}
Sheet Name: ${sheet_name}
Range: A1:D${row_count}Example query
To query sales data from a spreadsheet:
- Sheet ID:
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx - Sheet Name:
Sales - Range:
A1:E100 - Columns:
Date(Type: Time)Product(Type: String)Quantity(Type: Number)Revenue(Type: Number)
Limitations
- Read-only: The integration only supports reading data, not writing.
- Rate limits: Google Sheets API has usage limits. For high-frequency queries, consider exporting to CSV.
- Large spreadsheets: Very large spreadsheets may experience performance issues. Use specific ranges instead of querying entire sheets.
- No alerting: Google Sheets queries run in the frontend and do not support Grafana Alerting.
Troubleshoot Google Sheets issues
403 Forbidden error
Cause: The service account doesn’t have access to the spreadsheet.
Solution:
- Share the spreadsheet with the service account email.
- Verify the service account has at least Viewer access.
404 Not Found error
Cause: The Sheet ID is incorrect or the spreadsheet doesn’t exist.
Solution:
- Verify the Sheet ID from the spreadsheet URL.
- Ensure the spreadsheet hasn’t been deleted or moved.
Empty results
Cause: The range doesn’t contain data or column selectors don’t match headers.
Solution:
- Verify the range includes data (for example,
A1:D100, notA2:D100if you need headers). - Ensure column selectors exactly match the header text in your spreadsheet.


