diagram - 如何在 Grafana 中绘制网络图?

标签 diagram grafana

我想在 Grafana 中绘制网络图。

我的数据在一个两列的表中:一列是源节点的 id;另一列是指目标节点。例如。:

 +--------+--------+
 | source | target |
 +--------+--------+
 | 00     | 21     |
 | 00     | 23     |
 | 00     | 28     |
 | 01     | 21     |
 | 02     | 21     |
 | 02     | 22     |
 | 02     | 23     |
 +--------+--------+

我想要一个图表,其中的节点对应于表中同一行上的节点之间的列和行中的数字。

你对如何做到这一点有什么建议吗?

更新:

我使用了文本面板并使用 visjs 添加了以下 HTML 代码网络图书馆。
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/vis/4.21.0/vis.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/vis/4.21.0/vis.min.css" rel="stylesheet" type="text/css" />


<style type="text/css">
    #mynetwork {
        height: 400px;
        border: 1px solid lightgray;
    }
</style>
<div id="mynetwork"></div>

<script type="text/javascript">
    // create an array with nodes
    var nodes = new vis.DataSet([
        {id: '00', label: '00', group: 'producers'},
        {id: '01', label: '01', group: 'producers'},
        {id: '02', label: '02', group: 'producers'},
        {id: '21', label: '21', group: 'consumers'},
        {id: '22', label: '22', group: 'consumers'},
        {id: '23', label: '23', group: 'consumers'},
        {id: '28', label: '28', group: 'consumers'}
    ]);

    // create an array with edges
    var edges = new vis.DataSet([
        {from: '00', to: '21'},
        {from: '00', to: '23'},
        {from: '00', to: '28'},
        {from: '01', to: '21'},
        {from: '02', to: '21'},
        {from: '02', to: '22'},
        {from: '02', to: '23'}
    ]);

    // create a network
    var container = document.getElementById('mynetwork');

    // provide the data in the vis format
    var data = {
        nodes: nodes,
        edges: edges
    };    

    var options = {
        nodes: {
            shape: 'dot',
            size: 20,
            font: {
                size: 20,
                  color: '#ffffff'
            },
            borderWidth: 2
        },
        edges: {
            width: 2
        },
        groups: {
            producers: {
                color: {background:'red',border:'orange'},
                shape: 'diamond'
            },
            consumers: {
                shape: 'dot',
                color: {background: 'cyan',border:'blue'}
            }
        }
    };


    // initialize your network!
    var network = new vis.Network(container, data, options);

输出如下所示:

Network Diagram

后续问题:

我得到的数据被硬编码到 HTML 中,而不是从我的 MariaDB (mysql) 数据库加载。

直接从数据库加载网络数据应该做哪些修改?

最佳答案

现在有一个 grafana 图表插件:https://grafana.com/grafana/plugins/jdbranham-diagram-panel

您可以使用 Mermaid JS绘制图表并将度量与图表的每个节点相关联的语法。

在您的情况下,配置将是这样的:

00 --> 21
00 --> 23
00 --> 28
01 --> 21
02 --> 21
02 --> 22
02 --> 23

每个节点( 002101 ...)都是特定的 grafana 指标

关于diagram - 如何在 Grafana 中绘制网络图?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50033085/

相关文章:

.Net Winform 图表库

html - 我可以使用什么图表来显示 Html 事件和操作

database - 如何使用 localdb 在 Code First 中查看数据库图表

docker - Kamon、Statsd、Grafana 磁盘空间

普罗米修斯:0 偏移计数器

Grafana 7.4.3/var/lib/grafana 在 AWS ECS 中不可写入 - EFS

java - flink可以使用固定数量的key到keyBy一个数据流均匀地避免数据倾斜吗?

api - UML 图到模型 API

erlang - 如何可视化Erlang gen_fsm

elasticsearch - 如何在Grafana中实现完全匹配查询