• grafana-mysql数据源


    告警总量分析

    ----------------------------------------
    ## 今天截至当前时间点
    SELECT
      UNIX_TIMESTAMP(DATE_FORMAT(row_create_time, '%Y-%m-%d')) AS "time",
      count(global_message_id) as "今天截至当前时间点总量"
    FROM global_message_info
    WHERE
      $__timeFilter(row_create_time) and date(now())<row_create_time 
    group BY DATE_FORMAT(row_create_time, '%Y-%m-%d')
    -----------------------------------------
    ## 昨天截至昨天当前时间点
    SELECT
      UNIX_TIMESTAMP(DATE_FORMAT(row_create_time, '%Y-%m-%d')) AS "time",
      count(global_message_id) as "昨天截至昨天当前时间点"
    FROM global_message_info
    WHERE
      $__timeFilter(row_create_time) and DATE_SUB(CURDATE(), INTERVAL 1 DAY)<row_create_time and row_create_time<DATE_SUB(now(),INTERVAL 1 DAY)
    group BY DATE_FORMAT(row_create_time, '%Y-%m-%d')
    -----------------------------------------
    ## 21每天告警总量
    SELECT
      UNIX_TIMESTAMP(DATE_FORMAT(row_create_time, '%Y-%m-%d')) AS "time",
      count(global_message_id) as "21每天告警总量"
    FROM global_message_info
    WHERE
      $__timeFilter(row_create_time)
    group BY DATE_FORMAT(row_create_time, '%Y-%m-%d')
    --------------------------------
    ## 7天平均告警量
    SELECT
      UNIX_TIMESTAMP(DATE_FORMAT(row_create_time, '%Y-%m-%d')) AS "time",
    (SELECT
      FLOOR(count(global_message_id)/7) 
    FROM global_message_info
    WHERE
        DATE_SUB(CURDATE(), INTERVAL 8 DAY) < date(row_create_time) and date(row_create_time) <CURDATE()) as "7天平均告警量" FROM global_message_info
    WHERE DATE_SUB(CURDATE(), INTERVAL 8 DAY) < date(row_create_time) and date(row_create_time) <CURDATE()
    group BY DATE_FORMAT(row_create_time, '%Y-%m-%d')
    -----------------------------------------------------
    

    分类报警次数

     ---------------------------------------------
    ## class1-分类报警次数
    SELECT
      UNIX_TIMESTAMP(DATE_FORMAT(row_create_time, '%Y-%m-%d')) AS "time",
      count(global_message_id) ,
      self_var_flag12 as metric
    FROM global_message_info
    WHERE
      $__timeFilter(row_create_time)
    group BY DATE_FORMAT(row_create_time, '%Y-%m-%d'),self_var_flag12
    ------------------------------------------------
    ## class1,CLASS2-分类报警次数
    SELECT
      UNIX_TIMESTAMP(DATE_FORMAT(row_create_time, '%Y-%m-%d')) AS "time",
      count(global_message_id) ,
      concat(self_var_flag12,"-",self_var_flag13) as metric
    FROM global_message_info
    WHERE
      $__timeFilter(row_create_time)
    group BY DATE_FORMAT(row_create_time, '%Y-%m-%d'),self_var_flag12,self_var_flag13
    -----------------------------------------------------
    

    close_wait

    --------------------------------------------
    # close_wait-今天截至当前
    SELECT
      UNIX_TIMESTAMP(DATE_FORMAT(row_create_time, '%Y-%m-%d')) AS "time",
      count(global_message_id),
      concat(SELF_VAR_FLAG6,"-",SELF_VAR_FLAG7,"-",SELF_VAR_FLAG8,"-",SELF_VAR_FLAG9) as metric
    FROM global_message_info
    WHERE
      $__timeFilter(row_create_time) AND message_info LIKE 'Close_wait connection%'  AND self_var_flag9 NOT IN ('运维')
    group BY DATE_FORMAT(row_create_time, '%Y-%m-%d'),SELF_VAR_FLAG6,SELF_VAR_FLAG7,SELF_VAR_FLAG8,SELF_VAR_FLAG9
    ------------------------------------------------------
    

    kafka

    -------------------------------------------
    # 告警次数
    SELECT
      UNIX_TIMESTAMP(DATE_FORMAT(row_create_time, '%Y-%m-%d')) AS "time",
      count(global_message_id),
      concat(SELF_VAR_FLAG9,'-',SUBSTRING_INDEX(MESSAGE_INFO, 'Lag:', 1)) as metric
    FROM global_message_info
    WHERE
      $__timeFilter(row_create_time) AND SELF_VAR_FLAG13 = 'KAFKA' and SELF_NUM_FLAG1>10000
    group BY DATE_FORMAT(row_create_time, '%Y-%m-%d'),SELF_VAR_FLAG9,SUBSTRING_INDEX(MESSAGE_INFO, 'Lag:', 1)
    -------------------------------------------------
    # value大小
    SELECT
      UNIX_TIMESTAMP(DATE_FORMAT(row_create_time, '%Y-%m-%d')) AS "time",
      max(SELF_NUM_FLAG1),
      concat(SELF_VAR_FLAG9,'-',SUBSTRING_INDEX(MESSAGE_INFO, 'Lag:', 1)) as metric
    FROM global_message_info
    WHERE
      $__timeFilter(row_create_time) AND SELF_VAR_FLAG13 = 'KAFKA' and SELF_NUM_FLAG1>10000
    group BY DATE_FORMAT(row_create_time, '%Y-%m-%d'),SELF_VAR_FLAG9,SUBSTRING_INDEX(MESSAGE_INFO, 'Lag:', 1)
    -------------------------------------------
    

    当日告警分析

    微信:jinmuqq222
  • 相关阅读:
    面试题32_3:之字形打印二叉树
    面试题21_2:调整数组顺序使奇数位于偶数之前(各数之间的相对位置不变)
    面试题21:调整数组顺序使奇数位于偶数前面
    面试题32_2:分行从上到下打印二叉树
    面试题32:从上到下打印二叉树
    面试题31:栈的压入、弹出序列
    面试题30:包含min函数的栈
    二分图的最大匹配
    链式前向星+次短路
    次小生成树
  • 原文地址:https://www.cnblogs.com/jinmuqq222/p/14950532.html
Copyright © 2020-2023  润新知