grafana-diagram
grafana-diagram copied to clipboard
Support for direct definition via query results
In my use-case I'm querying a SQL database for non-series data, specifically a prerequisites structure.
It would be nice to format the query result to produce mermaid syntax then directly use the query output in the diagram definition.
For example, I could fill in the Diagram definition with
stateDiagram-v2
$A
$A (bad example) referencing the A table query containing something like:
select GROUP_CONCAT(concat(coalesce(pt.name, '[*]'), ' --> ', coalesce(t.name, '[*]')) SEPARATOR '\n')
from tasks t
left outer join prereqs p on t.id = p.task_id
left outer join tasks pt on pt.id = p.prereq_id
where t.job_id = '...'
Resulting in:
[*] --> TASK_1
TASK_1 --> TASK_2
TASK_2 --> TASK_3.1
TASK_2 --> TASK_3.2
TASK_3.1 --> TASK_4
TASK_3.2 --> TASK_4
Thus creating diagram definition of:
stateDiagram-v2
[*] --> TASK_1
TASK_1 --> TASK_2
TASK_2 --> TASK_3.1
TASK_2 --> TASK_3.2
TASK_3.1 --> TASK_4
TASK_3.2 --> TASK_4
There's probably a better way, but having this flexibility could be a catch-all for other awkward use-cases.
Interesting use-case!