Groups
Groups
Sign in
Groups
Groups
Prometheus Users
Conversations
About
Send feedback
Help
how to get precise scape timestamp
36 views
Skip to first unread message
林浩
unread,
Jun 9, 2020, 11:15:38 AM
6/9/20
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Prometheus Users
when I use range query api to get data point, for example I using step 30s
API return me data like these
"values"
: [
[
1591607520
,
"2270"
],
[
1591607550
,
"2270"
],
[
1591607580
,
"2270"
],
for the UNIX timestamp, is that really reflex to scrap time?
since I see some scrape setting
global: scrape_interval: 2m scrape_timeout: 2m evaluation_interval: 1m
because Prometheus using pull to get metric, so is there any way I can get precise scape UNIX timestamp from API ?
Brian Brazil
unread,
Jun 9, 2020, 11:16:49 AM
6/9/20
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to 林浩, Prometheus Users
You can use the timestamp() function, or use a query with a range vector to get the raw samples.
--
Brian Brazil
www.robustperception.io
林浩
unread,
Jun 9, 2020, 10:38:13 PM
6/9/20
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Prometheus Users
Brian,
How can I get raw samples with exactly scraping time from Prometheus by the range query?
I use this call to query data , and use parameter step=30,
curl --location --request GET '
http://xxx:9090/api/v1/query_range?query=node_processes_state{state%3D%27D%27}%20%3E%20500&start=2020-06-08T00:00:00Z&end=2020-06-09T18:00:00Z&step=30
'
api result below show that timestamp
159160
7520,
159160
7550,
159160
7580
are not the scape time I guess..
"values"
: [
[
1591607520
,
"2270"
],
[
1591607550
,
"2270"
],
[
1591607580
,
"2270"
],
在 2020年6月9日星期二 UTC+8下午11:16:49,Brian Brazil写道:
Brian Candler
unread,
Jun 10, 2020, 3:04:15 AM
6/10/20
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Prometheus Users
As Brian said, use a range vector query rather than an instant query.
# curl -Ssg 'localhost:9090/api/v1/query?query=up{instance="sw1"}[5m]' | python3 -mjson.tool
{
"status": "success",
...
[
1591772319.53,
"1"
],
[
1591772334.53,
"1"
],
[
1591772349.531,
"1"
],
[
1591772364.53,
"1"
],
...
林浩
unread,
Jun 10, 2020, 6:38:29 AM
6/10/20
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Prometheus Users
Thank
Brian Candler &
Brian Braizil !!
The last question, is there the way I can transform UNIX timestamp to human readable time string in the below API you give?
curl -Ssg 'localhost:9090/api/v1/query?
query=up{instance="sw1"}[5m]'
在 2020年6月10日星期三 UTC+8下午3:04:15,Brian Candler写道:
Brian Candler
unread,
Jun 10, 2020, 8:34:36 AM
6/10/20
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Prometheus Users
Not in prometheus - because it's an API. The consumer of the API is responsible for rendering the time in human-readable form.
However, you can always write a little Python script or whatever that replaces each time value with a string.
林浩
unread,
Jun 11, 2020, 3:43:30 AM
6/11/20
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Prometheus Users
I see. many thanks Brain!
在 2020年6月10日星期三 UTC+8下午8:34:36,Brian Candler写道:
Reply all
Reply to author
Forward
0 new messages