• 【其他】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;
    }
  • 相关阅读:
    [解决方案]sql server复制需要有实际的服务器名称才能连接到服务器
    [解决方案]解决SQL Server管理器无法连接远程数据库的问题
    event.keyCode对照表
    安卓环境搭建
    什么是 MIME Type?
    Gregexpr(可用来判断一个字符串在另一个字符串中出现的位置)
    paste函数(用于字符串的连接等)
    read.csv与write.csv
    JSF使用<p:fileUpload>进行上传图片出现的javax.servlet.ServletException: The request contenttype is not a multipart/formdata错误解决
    组合函数combn
  • 原文地址:https://www.cnblogs.com/jiangxu67/p/12711556.html
Copyright © 2020-2023  润新知