View Table Selector Queries
View table selectors reuse cached data from other views instead of hitting the original data sources again. They are ideal for composing dashboards, drilldowns, or summaries on top of existing views.
Overview
- Query the materialized Postgres tables generated for other views
- Avoid re-running expensive source queries
- Compose multiple views together or build drill-downs
- Keep formatting and column types consistent with the source view
Query Properties
| Property | Type | Description |
|---|---|---|
name | string | Name of the view to query |
namespace | string | Namespace of the view (default: default) |
labelSelector | string | Optional label selector to match multiple views (for composition by label) |
The selector returns all rows from the matched view tables. Shape or filter the data in your merge SQL or panel queries.
Example: Summarize an Existing View
Aggregate the cached deployments view to show healthy vs unhealthy releases per namespace:
deployments-summary.yamlapiVersion: mission-control.flanksource.com/v1
kind: View
metadata:
name: deployments-summary
namespace: mc
spec:
description: Summarize cached deployment health by namespace using a view table selector.
display:
title: Deployment Health Summary
icon: view-details
sidebar: true
queries:
deployments:
viewTableSelector:
name: deployments
namespace: mc
merge: |
SELECT
namespace,
SUM(CASE WHEN health = 'healthy' THEN 1 ELSE 0 END) AS healthy,
SUM(CASE WHEN health IN ('unhealthy', 'warning') THEN 1 ELSE 0 END) AS unhealthy,
COUNT(*) AS total
FROM deployments
GROUP BY namespace
columns:
- name: namespace
type: string
primaryKey: true
filter:
type: multiselect
- name: healthy
type: number
- name: unhealthy
type: number
- name: total
type: number
panels:
- name: Health Mix
description: Health distribution across all deployments
type: piechart
query: SELECT COUNT(*) AS count, health FROM deployments GROUP BY health
Tips
- Ensure the source view has cached data; the selector reads the Postgres table created for that view.
- Column types are inherited from the source view, so filters and formatting stay consistent.
- Use
labelSelectorwhen you want to stitch together multiple related views without hard-coding names. - Apply filtering and limits in
mergeSQL or panel queries to keep selectors simple.