首页 > 解决方案 > 如何将 HTML 数据填充到 Grafana Ajax 插件

问题描述

我有一个动态生成的 html 内容,我想在 Grafana 中显示相同的内容。手动填充 Ajax 插件是不可行的。我知道 Ajax 插件也可以用于相同的用途。我如何将 html 内容发送到这个插件,以及必须更新哪些不同的参数(下图)才能正确获取数据?

在此处输入图像描述

我正在使用 Python 将数据推送到 Influxdb。下面的例子 -

变量 htmloutput 包含必须显示的 html 数据。

client = InfluxDBClient(host='10.10.10.10', port=8086)
client.switch_database('TesDB')
json_body = [
              {
                      "measurement": "MS1",
                      "tags": {
                              "Server": QA1,
                      },
                      "time": timestamp,
                      "fields": {
                              "HTMLCONTENT": htmloutput
                        }
                }
                ]
client.write_points(json_body)

我得到的需要显示的示例 HTML 输出 -

在此处输入图像描述

HTML 代码 -

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-type" content="text/html;charset=UTF-8"><title>Errors</title><link rel="stylesheet" type="text/css" href="styles.css"><script src="code.js" type="text/javascript"></script></head><body onload="preparepage();"><input type="hidden" id="imageBase" value="img/"><a name="17">Problem 1</a></h3><div id="exp17"><div class="important"><div><p>104 errors of <b>General Exceptions</b>, at <b>Overview page</b> occupy <b>26.92%</b> in total. <br><br><b>Keywords</b><br>General<br>Unavailable, Temporary<br></div></div></div></div><br>
</body></html>

提前致谢。

标签: grafanainfluxdbinfluxdb-python

解决方案


推荐阅读