Closed KE6MTO closed 1 month ago
Hey @KE6MTO,
You can use the LEFT JOIN
on the node graph to identify which nodes have edges. This query should do the trick:
SELECT DISTINCT
cd.node_id AS "id",
cd.long_name AS "title",
cd.hardware_model AS "detail__Hardware Detail",
cd.role AS "detail__Client Role",
cd.mqtt_status AS "detail__MQTT Status",
cd.short_name AS "subtitle",
CASE
WHEN cd.mqtt_status = 'online' THEN '#2ECC71' -- Green for online
WHEN cd.mqtt_status = 'offline' THEN '#E74C3C' -- Red for offline
ELSE '#808080' -- Gray for none or any other status
END AS "color"
FROM
client_details cd
LEFT JOIN (
SELECT node_id FROM node_neighbors
UNION
SELECT neighbor_id FROM node_neighbors
) nn ON cd.node_id = nn.node_id
WHERE nn.node_id IS NOT NULL
To be honest, I'm hopeful that Grafana will enhance this panel with more features in the future, as its current functionality is quite limited. While this query solves your immediate problem, I'm hesitant to incorporate it directly into the project. Doing so would hide nodes without connections, which could be problematic for smaller meshes where it might result in an empty or near-empty graph.
Ideally, Grafana would introduce a toggle feature for this kind of filtering, giving users the flexibility to show or hide disconnected nodes as needed. This would cater to both large networks like yours and smaller setups. For now, you can use this query in your personal setup, and we'll keep an eye out for future improvements from the Grafana team.
Cool, thank you. Yeah I agree, it's a very limited and could use some enhancements. Thank you for the code, that did the trick.
Been trying to figure out a way to filter the nodes in the Node Graph panel to not show nodes that don't have a link. We have 200+ nodes but most don't have links so it makes it really hard to view the Node Graph.