grafana / grafana/google-bigquery-datasource
Feature Request: Add BigQuery reservation support per datasource
- Dominant language
- TypeScript
- Stars
- 40
- Forks
- 24
- Avg merge
- 3d 21h
- Merged PRs (30d)
- 8
Description
## Use Case
We're building a multi-tenant monitoring platform where we need cost isolation between different query workloads:
- **Human dashboard queries** - ad-hoc exploration via Grafana UI
- **Automated alerting queries** - scheduled Grafana alerts
Both workloads use service accounts in the same GCP project, so project-level reservation assignments don't provide the isolation we need.
## Problem
BigQuery supports specifying a reservation at query time via the [`reservation` field in QueryJobConfig](https://cloud.google.com/python/docs/reference/bigquery/latest/google.cloud.bigquery.job.QueryJobConfig#google_cloud_bigquery_job_QueryJobConfig.reservation). However, the Grafana BigQuery plugin doesn't expose this configuration option.
**Current workaround**: Users can manually prepend `SET @@reservation = 'projects/.../reservations/NAME';` to every query, but this:
- Is error-prone and easily forgotten
- Doesn't work with query builder mode
- Requires educating all dashboard authors
- Doesn't scale for alerting rules
## Proposed Solution
Add an optional `reservation` field to the datasource configuration that specifies the BigQuery reservation resource name:
```
projects/{project}/locations/{location}/reservations/{reservation_name}
```
When configured, all queries from that datasource would automatically use the specified reservation for billing/capacity purposes.
### Implementation Approach
Based on reviewing the plugin source:
**Frontend (`src/types.ts`):**
```typescript
export interface BigQueryOptions extends DataSourceOptions {
// ... existing fields
reservation?: string;
}
```
**Frontend (`src/components/ConfigEditor.tsx`):**
Add an input field for the reservation resource name.
**Backend (`pkg/bigquery/driver/conn.go`):**
When executing queries, set the reservation on the QueryJobConfig before running.
## Questions for Maintainers
1. Is reservation support planned or on the roadmap?
2. Would a PR implementing this feature be accepted?
3. Are there alternative approaches you'd recommend (e.g., labels, different architecture)?
We're happy to contribute a PR if the approach is acceptable. The implementation appears straightforward and follows existing patterns in the codebase (similar to `MaxBytesBilled` and `processingLocation`).
## References
- [BigQuery Reservations Overview](https://cloud.google.com/bigquery/docs/reservations-intro)
- [BigQuery SET statement for reservations](https://cloud.google.com/bigquery/docs/reference/standard-sql/lexical#set_statement)
- [QueryJobConfig.reservation](https://cloud.google.com/python/docs/reference/bigquery/latest/google.cloud.bigquery.job.QueryJobConfig#google_cloud_bigquery_job_QueryJobConfig.reservation)
Contributor guide
Research direction
Start with src/types.ts and src/components/ConfigEditor.tsx to trace datasource options, then read pkg/bigquery/driver/conn.go and the existing MaxBytesBilled or processingLocation handling. Done means an optional reservation resource name can be configured per datasource and is applied when queries execute, including query builder use.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- google-cloud, typescript
- Domain
- cloud, full-stack
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100