Grafana HTML Panel展示post获取后数据

<!DOCTYPE html>
<html>
<head>
    <title>API 数据表格展示</title>
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
</head>
<body>
    <table id="data-table" border="1">
        <thead>
            <tr>
			    <th style="width: 1000px;">时间</th>
				<th style="width: 1500px;">应用系统名称</th>
                <th style="width: 1000px;">可用率</th>
                <!--
                <th>Count</th>
 				<th>Description</th>
 				<th>Interval</th>
 				<th>Res ID</th> 
 				-->                        
            </tr>
        </thead>
        <tbody>
            <!-- Data rows will be dynamically added here -->
        </tbody>
    </table>

    <script>
        $(document).ready(function() {
            $.ajax({
                url: 'http://aiops.test.com:8001/api/business/eventCalcProp/queryPage',
                type: 'POST',
                contentType: 'application/json',
                data: JSON.stringify({
                    "conditions": {
                        "full": "true"
                    }
                }),
                success: function(response) {
                    // 清空表格数据
                    $('#data-table tbody').empty();

                    // 解析并添加数据到表格
                    var records = response.data.records;
                    records.forEach(function(item) {
                        var row = '<tr>';
						row += '<td>' + item.occur_time.replace("T"," ") + '</td>';
						row += '<td>' + item.res_name + '</td>';
                        row += '<td>' + item.val + '</td>';
                        // row += '<td>' + item.count + '</td>';
                        // row += '<td>' + item.description + '</td>';
                        // row += '<td>' + item.interval + '</td>';
                        // row += '<td>' + item.res_id + '</td>';                       
                        row += '</tr>';
                        $('#data-table tbody').append(row);
                    });
                },
                error: function(error) {
                    $('#data-table tbody').html('<tr><td colspan="7">Error fetching data</td></tr>');
                }
            });
        });
    </script>
</body>
</html>
post返回数据格式
{"code":1,"msg":"获取成功","data":{"total":3,"size":3,"current":1,"records":[{"val":"100.00%","count":0,"description":"0.000毫秒","interval":0,"res_id":"18591","res_name":"XXX业务系统","occur_time":"2024-05-23T13:37:33"},{"val":"100.00%","count":0,"description":"0.000毫秒","interval":0,"res_id":"18594","res_name":"XXXX系统","occur_time":"2024-05-23T13:37:34"},{"val":"100.00%","count":0,"description":"0.000毫秒","interval":0,"res_id":"18631","res_name":"XXXXX系统","occur_time":"2024-05-23T13:37:35"}],"pages":1}}
效果

在这里插入图片描述

  • 5
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值