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;
    }
  • 相关阅读:
    有趣的linux指令
    Linux——文件打包与压缩
    linux点滴记录
    不归零法编码、曼彻斯特编码和差分曼彻斯特编码
    MySQL点滴记录
    hdu 1200 To and Fro(简单模拟或DP)
    hdu 1081 To The Max(dp+化二维为一维)
    抓起根本(二)(hdu 4554 叛逆的小明 hdu 1002 A + B Problem II,数字的转化(反转),大数的加法......)
    抓其根本(一)(hdu2710 Max Factor 素数 最大公约数 最小公倍数.....)
    hdu 1159 Common Subsequence(最长公共子序列 DP)
  • 原文地址:https://www.cnblogs.com/jiangxu67/p/12711556.html
Copyright © 2011-2022 走看看