Skip to content

nginx 日志查看今日 PV 和昨日对比

先通过 count 函数计算总的 pv,再用 compare 函数得出今日的 pv 与昨日的同比

通过单值图进行展示,显示值为 20.381Mil,对比值为-2%

试用 Demo

SQL
* |
select
  diff [1] as today,
  round((diff [3] -1.0) * 100, 2) as growth
FROM
  (
    SELECT
      compare(pv, 86400) as diff
    FROM
      (
        SELECT
          COUNT(1) as pv
        FROM
          log
      )
  )

查询结果:

样例图片

可视化展示

样例图片

可视化配置

样例图片