get the wrong mistake number when query time is short

35 views
Skip to first unread message

何吉林

unread,
Jul 31, 2020, 12:22:06 AM7/31/20
to Prometheus Users
suppose I monitor a job with 100 instance.when I query with 1 minute : 

count(sum(metrics_name{xxx}[1m]) by (instance)),
 
what i get is less than 100.

when I use 10 minutes, 

count(sum(metrics_name{xxx}[10m]) by (instance)),

what i get is 100.


Brian Candler

unread,
Jul 31, 2020, 3:10:47 AM7/31/20
to Prometheus Users
That query cannot even be run - metrics_name{xxx}[1m] is a range vector, but sum() only works over an instant vector.

What's the real query you're doing?

何吉林

unread,
Jul 31, 2020, 3:19:36 AM7/31/20
to Prometheus Users
sorry, the increase function was lost, the whole query should be 
count(sum(increase(metric_name{xxx}[1m])) by (instance) )

在 2020年7月31日星期五 UTC+8下午3:10:47,Brian Candler写道:

Brian Candler

unread,
Jul 31, 2020, 6:34:43 AM7/31/20
to Prometheus Users
What's your scrape interval?

increase(metric_name{xxx}[1m])

requires at least two data points in the 1m window.  So if you are scraping at 1m intervals, you need at least [2m] to guarantee two data points in the window at any time.

Reply all
Reply to author
Forward
0 new messages