firebase / firebase/firebase-js-sdk

[Feature Request] Expose Firestore Query Insights via REST API / Admin SDK

Open
#10,061 2 comments 0 reactions 1 assignee Claimed by @cherylEnkidu View on GitHub
api: firestore feature request
Dominant language
TypeScript
Stars
5.1k
Forks
1k
Avg merge
2d 21h
Merged PRs (30d)
37

Description

## Feature Request

**Problem**

The Firestore Console's **Query Insights** tab provides valuable per-query performance data (executions, read operations, average docs scanned, latency). This data is currently only accessible through the Firebase Console UI — there is no public API endpoint to retrieve it programmatically.

**Desired Solution**

Expose Firestore Query Insights via a public REST API endpoint and/or the Firebase Admin SDK, e.g.:

```
GET https://firestore.googleapis.com/v1/projects/{project}/databases/{database}/queryInsights
```

Expected response per query:
- Query pattern / collection path
- Execution count
- Total + average read operations
- Average docs scanned
- Average latency
- Configurable time range

**Alternatives Considered**

The `firestore.googleapis.com/document/read_ops_count` Cloud Monitoring metric provides aggregate counts by operation type (`QUERY` / `LOOKUP` / `NOT_FOUND`) but no per-query breakdown. The following endpoints were tested and all return 404 or invalid argument:

- `GET .../databases/(default)/queryInsights` (v1)
- `GET .../databases/(default):queryInsights` (v1beta1)
- `GET .../databases/(default)/observability/queryInsights` (v1)

**Use Case**

Integrating Firestore query performance into CI/CD pipelines to automatically detect read regressions after deployments. Without a programmatic API, this requires manual inspection of the Firebase Console — not feasible for automated monitoring or alerting.

A concrete example: after deploying a backend change, a pipeline step could compare the top-5 queries by read ops against a baseline and fail the deploy if a query's avg docs scanned increases by more than 2×.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.