-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
大盘panel使用排行榜但显示数量不对 #234
Comments
如群里说的 topk 不是取 k 条数据,这是 promql 语法和查询的设定,你拿这个 ql 去查 prometheus 接口也是一样的结果的
你需要的可能是 MetricsQL 的 topk_[aggfunc]
kobe ***@***.***> 于2023年1月12日周四 17:10写道:
… sort_desc(topk(20,avg by (uri, method)
((sum(increase(http_server_requests_seconds_sum{application="$application",instance="$instance",uri!="root",method!="HEAD"}[1h]))
by (uri,
method))/(sum(increase(http_server_requests_seconds_count{application="$application",instance="$instance",uri!="root",method!="HEAD"}[1h]))
by (uri, method) > 0)) * 1000)>0)
以上是我的图表的promql,想看top20的请求耗时,但是显示的排行榜里不止20条数据
—
Reply to this email directly, view it on GitHub
<#234>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABYUU6RGKY6BATZUE22WDTLWR7C7PANCNFSM6AAAAAATY776UI>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
|
补充一下,我如果选择的是时间序列图,topk数量也是对的上的 |
很多问题搜索引擎都是查询到的
https://stackoverflow.com/questions/71552862/prometheus-topk-function-returning-all-results
[image: image.png]
kobe ***@***.***> 于2023年1月12日周四 17:36写道:
… 补充一下,我如果选择的是时间序列图,topk数量也是对的上的
—
Reply to this email directly, view it on GitHub
<#234 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABYUU6UMS2TIR7LG67XE5RTWR7GBNANCNFSM6AAAAAATY776UI>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
什么意思? |
Note that topk(N, ...)
<https://docs.victoriametrics.com/MetricsQL.html#topk> function may return
more than N time series when this function is used for building a graph
over time (aka range query
<https://prometheus.io/docs/prometheus/latest/querying/api/#range-queries>).
This is because it returns top N time series independently per each
timestamp on the graph.
topk 是基于每个 series 的每个 timestamp 去计算 top n
kobe ***@***.***> 于2023年1月12日周四 18:46写道:
… 什么意思?
—
Reply to this email directly, view it on GitHub
<#234 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABYUU6XI2VVGDOYGWPYT5QDWR7OHPANCNFSM6AAAAAATY776UI>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
那我怎么才能统计的准呢 |
准备后面新增一个 Instant 开关,开启后会通过 query 接口查询数据,这样可以避免因为 query_range 返回的时间点不对齐导致无法获取期望的 topN 数据 |
sort_desc(topk(20,avg by (uri, method) ((sum(increase(http_server_requests_seconds_sum{application="$application",instance="$instance",uri!="root",method!="HEAD"}[1h])) by (uri, method))/(sum(increase(http_server_requests_seconds_count{application="$application",instance="$instance",uri!="root",method!="HEAD"}[1h])) by (uri, method) > 0)) * 1000)>0)
以上是我的图表的promql,想看top20的请求耗时,但是显示的排行榜里不止20条数据
The text was updated successfully, but these errors were encountered: