-
Notifications
You must be signed in to change notification settings - Fork 21
feat(dashboards): add Streamlit agent analytics dashboard #480
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
whuang602
wants to merge
5
commits into
GoogleCloudPlatform:main
Choose a base branch
from
whuang602:streamlit
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
33527b5
feat(dashboards): add Streamlit agent analytics dashboard
whuang602 ee4d25e
fix(dashboards/streamlit): address core Streamlit issues and Grafana …
whuang602 0fba125
fix(dashboards/streamlit): address widget retention, prefix flag, #48…
whuang602 9c71f08
CI(dashboards/streamlit): add query sync workflow, tests, and legacy …
whuang602 295542a
fix(dashboards/streamlit): resolve widget identity, job reload, and r…
whuang602 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| # Copyright 2026 Google LLC | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| name: Streamlit query sync check | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| paths: | ||
| - "dashboards/grafana/queries/**" | ||
| - "dashboards/streamlit/**" | ||
| - "scripts/check_streamlit_queries_sync.py" | ||
| - "tests/test_dashboards_streamlit_app.py" | ||
| - "tests/test_check_streamlit_queries_sync.py" | ||
| - "tests/test_dashboards_streamlit_charts.py" | ||
| - "tests/test_dashboards_streamlit_apptest.py" | ||
| - "pyproject.toml" | ||
| - ".github/workflows/streamlit-sync-check.yml" | ||
| pull_request: | ||
| branches: [main] | ||
| paths: | ||
| - "dashboards/grafana/queries/**" | ||
| - "dashboards/streamlit/**" | ||
| - "scripts/check_streamlit_queries_sync.py" | ||
| - "tests/test_dashboards_streamlit_app.py" | ||
| - "tests/test_check_streamlit_queries_sync.py" | ||
| - "tests/test_dashboards_streamlit_charts.py" | ||
| - "tests/test_dashboards_streamlit_apptest.py" | ||
| - "pyproject.toml" | ||
| - ".github/workflows/streamlit-sync-check.yml" | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| streamlit-query-sync: | ||
| name: Dashboard queries and contracts match SQL sources | ||
| runs-on: ubuntu-22.04 | ||
| steps: | ||
| - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 | ||
| with: | ||
| persist-credentials: false | ||
|
|
||
| - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5 | ||
| with: | ||
| python-version: "3.12" | ||
|
|
||
| - name: Install package with dev and streamlit dependencies | ||
| run: pip install -e ".[dev,streamlit]" | ||
|
|
||
| - name: Validate Streamlit queries match canonical Grafana SQL | ||
| run: python3 scripts/check_streamlit_queries_sync.py | ||
|
|
||
| - name: Run Streamlit dashboard contract tests | ||
| run: | | ||
| pytest --tb=short -q \ | ||
| tests/test_dashboards_streamlit_app.py \ | ||
| tests/test_check_streamlit_queries_sync.py \ | ||
| tests/test_dashboards_streamlit_charts.py \ | ||
| tests/test_dashboards_streamlit_apptest.py | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| # Self-Hosted Dashboards | ||
|
|
||
| Self-hosted observability and analytics dashboards for BigQuery Agent Analytics (BQAA). | ||
|
|
||
| ## Available Dashboards | ||
|
|
||
| | Dashboard | Primary Use Case | Documentation | | ||
| | :-------------------------- | :------------------------------------------------------------------------------------------ | :---------------------------------------------------------- | | ||
| | **Streamlit** | Interactive Python-native telemetry inspection, latency distributions, token analytics | [Streamlit Guide](streamlit/README.md) | | ||
| | **Grafana** | Time-series metrics, customizable SQL panels, public demo sharing, one-command local runner | [Grafana Guide](grafana/README.md) | | ||
| | **Looker Studio** | Published 37-chart template over BQAA views, zero-install, team-wide reporting | [Looker Studio Guide](../dashboard/looker_studio/README.md) | | ||
| | **Demo Streamlit (Legacy)** | Original standalone demo app and Colab tutorial for raw ADK table logs | [Legacy Demo App](../dashboard/README.md) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| # Path to Google Cloud service account JSON key file | ||
| GOOGLE_APPLICATION_CREDENTIALS=dashboards/streamlit/sa-key.json # Remove or comment out to use user credentials (ADC) | ||
|
|
||
| # Google Cloud project ID | ||
| BQ_PROJECT_ID=my-gcp-project | ||
|
|
||
| # BigQuery dataset ID | ||
| BQ_DATASET_ID=agent_analytics | ||
|
|
||
| # BigQuery table ID storing raw agent telemetry events | ||
| BQ_TABLE_ID=agent_events #default | ||
|
|
||
| # Prefix applied to typed analytical views | ||
| BQ_VIEW_PREFIX=adk_ #default |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| # Streamlit Dashboard for BigQuery Agent Analytics | ||
|
|
||
| Interactive dashboard for monitoring, diagnosing, and evaluating AI agent traces in Google BigQuery. | ||
|
|
||
| --- | ||
|
|
||
| ## 1. Install | ||
|
|
||
| Install dependencies with the `dashboards` extra: | ||
|
|
||
| ```bash | ||
| pip install '.[streamlit]' | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## 2. Configure | ||
|
|
||
| Copy the sample environment file and configure your parameters: | ||
|
|
||
| ```bash | ||
| cp dashboards/streamlit/.env.sample dashboards/streamlit/.env | ||
| ``` | ||
|
|
||
| Parameters configured in `dashboards/streamlit/.env`: | ||
|
|
||
| | Variable | Description | Default | | ||
| | :------------------------------- | :--------------------------------------- | :--------------------------------- | | ||
| | `GOOGLE_APPLICATION_CREDENTIALS` | Path to service account JSON key file | `dashboards/streamlit/sa-key.json` | | ||
| | `BQ_PROJECT_ID` | Google Cloud project ID | `my-gcp-project` | | ||
| | `BQ_DATASET_ID` | BigQuery dataset containing agent events | `agent_analytics` | | ||
| | `BQ_TABLE_ID` | Raw agent events table | `agent_events` | | ||
| | `BQ_VIEW_PREFIX` | Prefix for typed analytical views | `adk_` | | ||
|
|
||
| --- | ||
|
|
||
| ## 3. Prerequisites & Typed Views | ||
|
|
||
| The dashboard queries typed analytical views (`adk_llm_responses`, `adk_tool_starts`, etc.) created over the raw events table. | ||
|
|
||
| ### IAM Roles | ||
|
|
||
| Ensure the query identity (service account or `gcloud auth application-default login`) has: | ||
| * **`roles/bigquery.jobUser`** on the Google Cloud project to run query jobs. | ||
| * **`roles/bigquery.dataViewer`** on the dataset to read tables and views. | ||
|
|
||
| ### Create Views | ||
|
|
||
| Generate the typed analytical views matching your project, dataset, and events table: | ||
|
|
||
| ```bash | ||
| bq-agent-sdk views create-all \ | ||
| --project-id YOUR_PROJECT \ | ||
| --dataset-id YOUR_DATASET \ | ||
| --table-id YOUR_TABLE | ||
| ``` | ||
|
|
||
| > **Note:** Views default to the `adk_` prefix. If you specify a custom prefix with `--prefix`, set `BQ_VIEW_PREFIX` in `.env` (or in the dashboard sidebar) to match. | ||
|
|
||
| --- | ||
|
|
||
| ## 4. Run | ||
|
|
||
| Launch the Streamlit dashboard: | ||
|
|
||
| ```bash | ||
| streamlit run dashboards/streamlit/app.py | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## 5. Sidebar Controls | ||
|
|
||
| The sidebar provides runtime controls and guardrails for query execution: | ||
|
|
||
| * **Time range selector**: Snaps query execution to discrete sliding windows (e.g., Last 15 minutes, Last 24 hours, Last 7 days, Last 30 days) with bucketed intervals. | ||
| * **Per-query scan cap guardrail (`maximum_bytes_billed`)**: Sets a strict byte limit on every BigQuery job. A free dry-run preflight validates query scan size before execution, preventing queries from running if they exceed the selected cap rather than billing for unexpected costs. | ||
| * **Token pricing defaults**: Configures input and output token rates for estimated cost calculations (defaults to \$1.25 / 1M input tokens and \$5.00 / 1M output tokens). Note that costs are derived from token counts rather than recorded billing telemetry. |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P3 (non-blocking): dashboard Python bypasses the formatting gate
This workflow runs the SQL checker and tests, but no formatter. The repository's
autoformat.shand the main CI dirty-diff assertion cover onlysrc/,tests/,examples/, andscripts/, so the new production Python underdashboards/streamlit/is outside both paths. The gap is observable on this head:pyink --check dashboards/streamlit/charts.pywants to add the missing final newline.Please add
dashboards/streamlitto the shared format command and CI diff list, or runpyink --checkandisort --check-onlyfor it here.