CnOps 智能运维与可观测社区
首页开源项目实践文章视频课程常见问答开发者工具STAROps 专题
导航菜单
首页开源项目实践文章视频课程常见问答开发者工具STAROps 专题

CnOps 智能运维与可观测社区

愿景

CnOps 智能运维与可观测社区是一个以"智能运维与可观测"为核心的开放、包容、分享的技术社区,旨在聚集运维专家、开发者和爱好者,共同探讨、学习和分享可观测最佳实践与最新技术,与众多技术社区合作互动,共同探讨交叉领域的技术挑战,推动可观测领域的创新与进步。

内容社区

  • 实践文章
  • 视频课程
  • 开源项目
  • 常见问答
  • 开发者工具

友情链接

  • Prometheus
  • Grafana Lab
  • OpenTelemetry
  • LoongCollector

关注我们

阿里云云原生公众号阿里云云原生
阿里云可观测公众号阿里云可观测

Copyright © 2026 CnOps 社区. All rights reserved.

首页问答如何使用 SLS SQL 实现游戏业务的 PV/UV 同环比监控?

如何使用 SLS SQL 实现游戏业务的 PV/UV 同环比监控?

#SLS#监控

CNOps | 2026-04-15

SLS 内置了 compare 函数(内部转化为 join 统计分析),可以轻松实现 PV/UV 的同环比分析。实现环比监控的 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(distinct remote_addr) as pv from log)
)

其中 86400 表示与前一天(86400 秒)进行对比。实现同比监控的 SQL 则需要按时间粒度分组:

* | select t, diff[1] as today, diff[2] as yestoday, diff[3] as percentage
from (
  select t, compare(pv, 86400) as diff
  from (
    select count(1) as pv, date_format(from_unixtime(__time__), '%H:%i') as t
    from log group by t
  ) group by t order by t
)

这些查询结果可以直接配合 SLS 仪表盘功能制作业务监控大盘和运营报表。

推荐文章

超过 2000+ 位开发者正在阅读

给 OpenClaw 加上企业级 Memory

给 OpenClaw 加上企业级 Memory

4646 阅读

阿里云 STAROps 全域智能运维平台发布!

阿里云 STAROps 全域智能运维平台发布!

3453 阅读

阿里云正式发布 RCA Benchmark

阿里云正式发布 RCA Benchmark

2716 阅读

推荐视频

UModel 最佳实践 Vol.1 UModel 数据建模全景解读

UModel 最佳实践 Vol.1 UModel 数据建模全景解读

3854 观看50:35
云监控2.0全景:可观测范式升级与智能运维蓝图

云监控2.0全景:可观测范式升级与智能运维蓝图

2532 观看41:06

推荐工具

精选可观测领域开发者工具

云监

云监控 2.0 沙箱体验

7483 使用

免费

免费网络拨测工具

2746 使用