zoukankan      html  css  js  c++  java
  • 【其他】Falcon的数据查询

    查询监控项

    select
        *
    from
        endpoint e inner join endpoint_counter c on e.id = c.endpoint_id where 
        c.counter = "mysql_alive_local/port=3306,type=mysql" 
        and endpoint = "host_name"

    模拟登录获取Cookie,Postman选form-data

    login()在/static/js/uic.js

    # POST FORM, curl可以通过-b 将cookie输出到文件
    curl -d "name=user&password=passwd" http://falconhost:port/auth/login

    从接口获取监控数据

    curl -H "Cookie:session=eyJvcGVuLWZhbGNvbi1jayI6ImppYW5neHU6NGUwOGM0YjM3ZjAwMTFlYTlmM2NlY2Y0YmJmMWFhAAQifQ.XpfQVQ._-QAoxYM--Xf7BKHfi64CU2hgwE" -X GET "http://falconhost:port/chart/h?cf=AVERAGE&end=1586943404&graph_type=h&id=8095&start=1586939864&sum=off&sumonly=off" | jq
    {
      "units": "",
      "series": [
        {
          "counter": "mysql_alive_local/port=3306,type=mysql",
          "endpoint": "monitored_host",
          "data": [
            [
              1586940000000,
              1
            ],...
          ],
          "name": "monitored_host",
          "cf": "AVERAGE"
        }
      ],
      "title": "mysql_alive_local/port=3306,type=mysql"
    }

    从chart接口获取数据需要一个id,id是在dashboard.tmp_graph表中的主键

    不是所有主机(endpoint)的metric(counter)在tmp_graph都有数据

    <a href="javascript:void(0);" onclick="fn_show_chart('mysql_alive_local/port=3306,type=mysql')">mysql_alive_local/port=3306,type=mysql</a>

    /static/js/dashboard.js

    function fn_show_chart(counter)
    {
        var checked_hosts = new Array();
        $("#tbody-endpoints input:checked").each(function(i, o){
            if($(o).is(":visible")){
                var hostfullname = $(o).attr("data-fullname");
                checked_hosts.push(hostfullname);
            }
        });
        if(checked_hosts.length === 0){
            err_message_quietly("鍏堥€塭ndpoint锛氾級");
            return false;
        }
    
        checked_items = new Array();
        checked_items.push(counter);
        var w = window.open();
        $.ajax({
            url: "/chart",
            dataType: "json",
            method: "POST",
            data: {"endpoints": checked_hosts, "counters": checked_items, "graph_type": "h", "_r": Math.random()},
            success: function(ret) {
                if (ret.ok) {
                    setTimeout(function(){w.location='/chart/big?id='+ret.id;}, 0);
                } else {
                    err_message_quietly("璇锋眰鍑洪敊浜�");
                }
            },
            error: function(){
                err_message_quietly("璇锋眰鍑洪敊浜�");
            }
        });
        return false;
    }
  • 相关阅读:
    Angle Beats Gym
    MUV LUV UNLIMITED Gym
    Balanced Diet Gym
    数位dp HDU
    数位dp CodeForces
    数位dp HDU
    有依赖的背包 洛谷P1064 金明的预算方案 (不是分组背包)
    多重背包+二进制拆分 POJ1014
    单调队列优化dp 入门 洛谷P2627 修剪草坪
    01背包 + 排序 (记忆化搜索) 骄傲的商人(HDU
  • 原文地址:https://www.cnblogs.com/jiangxu67/p/12711556.html
Copyright © 2011-2022 走看看