egress data

10 views
Skip to first unread message

chris....@gmail.com

unread,
Oct 2, 2020, 10:02:47 AM10/2/20
to Prometheus Users
I've been asked to get a value from the prometheus instance we are running.

I want the metric "temp_in_c" for the past year for a number of the machines we are running.  The people that would like the data don't have access to the any of the data in any other way.

Working in python and this is what I'm trying and was wondering if it is correct?
start_date=str(time.mktime(datetime.date(2019,10,1).timetuple()))
end_date  =str(time.mktime(datetime.date(2019,10,2).timetuple()))
step_resolution='5m'  -- This is hardcoded below

response = requests.get('{}/api/v1/query'.format(hostname),params={'query': 'temp_in_c','step':'5m','start':start_date,'end_input':end_date})

print(response)    ## This comes back as 200 which look ok
results = response.json()['data']['result']  ## This gives me [] nothing

There is data for this metric during that time so I figure I'm doing something wrong in my query?

Any ideas?

Thanks


Brian Candler

unread,
Oct 2, 2020, 11:17:13 AM10/2/20
to Prometheus Users
You need /api/v1/query_range not /api/v1/query. See:

If that doesn't help, you may get more clues from print(response.text)
Reply all
Reply to author
Forward
0 new messages