fix: wire live mode and Grafana to the generated data stream
Use the real hive column name (`drone`) in the prototype's live query and pin the Grafana datasource uid to `swarm-prom` so provisioned dashboards resolve their Prometheus source in k3d.
This commit is contained in:
@@ -298,8 +298,12 @@ resource "kubernetes_config_map" "grafana_provisioning" {
|
|||||||
data = {
|
data = {
|
||||||
"datasource.yml" = <<-EOT
|
"datasource.yml" = <<-EOT
|
||||||
apiVersion: 1
|
apiVersion: 1
|
||||||
|
deleteDatasources:
|
||||||
|
- name: Prometheus
|
||||||
|
orgId: 1
|
||||||
datasources:
|
datasources:
|
||||||
- name: Prometheus
|
- name: Prometheus
|
||||||
|
uid: swarm-prom
|
||||||
type: prometheus
|
type: prometheus
|
||||||
access: proxy
|
access: proxy
|
||||||
url: http://prometheus:9090
|
url: http://prometheus:9090
|
||||||
|
|||||||
@@ -20,24 +20,24 @@ export interface LivePose {
|
|||||||
// latest battery reading from telemetry. arg_max keeps it a single scan.
|
// latest battery reading from telemetry. arg_max keeps it a single scan.
|
||||||
const LIVE_SQL = `
|
const LIVE_SQL = `
|
||||||
WITH pose AS (
|
WITH pose AS (
|
||||||
SELECT drone_id,
|
SELECT drone,
|
||||||
arg_max(pos_x, ts_ns) AS x,
|
arg_max(pos_x, ts_ns) AS x,
|
||||||
arg_max(pos_y, ts_ns) AS y,
|
arg_max(pos_y, ts_ns) AS y,
|
||||||
arg_max(yaw, ts_ns) AS yaw,
|
arg_max(yaw, ts_ns) AS yaw,
|
||||||
max(ts_ns) AS ts_ns
|
max(ts_ns) AS ts_ns
|
||||||
FROM state
|
FROM state
|
||||||
WHERE direction = 'sent'
|
WHERE direction = 'sent'
|
||||||
GROUP BY drone_id
|
GROUP BY drone
|
||||||
),
|
),
|
||||||
batt AS (
|
batt AS (
|
||||||
SELECT drone_id, arg_max(level_pct, ts_ns) AS battery
|
SELECT drone, arg_max(level_pct, ts_ns) AS battery
|
||||||
FROM telemetry
|
FROM telemetry
|
||||||
WHERE sensor = 'battery'
|
WHERE sensor = 'battery'
|
||||||
GROUP BY drone_id
|
GROUP BY drone
|
||||||
)
|
)
|
||||||
SELECT p.drone_id, p.x, p.y, p.yaw, p.ts_ns, b.battery
|
SELECT p.drone, p.x, p.y, p.yaw, p.ts_ns, b.battery
|
||||||
FROM pose p LEFT JOIN batt b USING (drone_id)
|
FROM pose p LEFT JOIN batt b USING (drone)
|
||||||
ORDER BY p.drone_id`;
|
ORDER BY p.drone`;
|
||||||
|
|
||||||
interface QueryResponse {
|
interface QueryResponse {
|
||||||
columns?: string[];
|
columns?: string[];
|
||||||
|
|||||||
Reference in New Issue
Block a user