NGINX
NGINX Trac
3rd Party Modules
Security Advisories
CHANGES
OpenResty
ngx_lua
Tengine
在线学习资源
NGINX 开发从入门到精通
NGINX Modules
ngx_echo
YaD2x
0.1D
V2EX  ›  NGINX

请大佬指点一下 loki 查询 nginx 日志,对 ip 去重处理的语法。

  •  
  •   YaD2x · May 23, 2024 · 1672 views
    This topic created in 718 days ago, the information mentioned may be changed or developed.

    需求:通过 loki 查询 nginx 日志里用户下载 dpcb.apk 的次数。需要对一天内同一个 ip 地址去重,只统计一次。

    如图,只能实现所有 ip 的总下载次数,未对 ip 去重处理。

    image.png

    image.png

    sum by(remote_addr) (count_over_time({instance="172.24.135.93", filename="/var/log/nginx/access.log"} | json | request = GET /uniapp/DPCB.apk HTTP/1.1 [$__auto]))

    请教如何实现 ip 去重

    3 replies    2024-05-23 15:27:10 +08:00
    tiandishi
        1
    tiandishi  
       May 23, 2024
    sort 后 重定向到 uniq

    sort|uniq
    tiandishi
        2
    tiandishi  
       May 23, 2024
    awk 数组打表也可以
    tiandishi
        3
    tiandishi  
       May 23, 2024
    搞错了,没用过 loki
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1185 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 18:07 · PVG 02:07 · LAX 11:07 · JFK 14:07
    ♥ Do have faith in what you're doing.