The prometheus exporter sever is limited for some time

24 views
Skip to first unread message

Dhanush Eswar

unread,
Jan 22, 2021, 4:37:14 AM1/22/21
to Prometheus Users
Hi,
I am new to prometheus, I am using prometheus_client python package for exporting metrics and I hosted the python program on some Amazon EC2 instance, I have been receiving the data from the metrics for only 2 hours and the Graph of the Grafana shows only that data(for 2 hours), Can anyone tell why its happening in such a way and provide me some tips.

Best,
Dhanush Eswar G

Julius Volz

unread,
Jan 22, 2021, 1:10:19 PM1/22/21
to Dhanush Eswar, Prometheus Users
Hi Dhanush,

The way Prometheus works (usually) is that it scrapes the current value of all metrics from a target / exporter. So a /metrics endpoint does not provide historical data, the history only gets built up by Prometheus itself as a process of scraping and storing current values periodically in the time series database. So if you only have been scraping for 2h, it's expected that you would only get 2h of data in your TSDB.

Regards,
Julius

--
You received this message because you are subscribed to the Google Groups "Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/8f19c390-ad71-4c21-85ea-f0159c52a2b7n%40googlegroups.com.


--
Julius Volz
PromLabs - promlabs.com

Dhanush Eswar

unread,
Jan 24, 2021, 10:53:42 PM1/24/21
to Prometheus Users
Hi  Julius Volz, 
Thanks for the explanation got the clear picture of the working of Prometheus, It works fine in my local computer, when I host the Exporter to the AWS instance, I am getting only the 2 hours of data, unlikely in local it works for any number of hours(Getting the data uninterrupted when the Exporter server is up), I think I am missing something while handling the server on AWS Instance, Herby I am including the code for the server, Kindly help me out to resolve that.

Code:
import prometheus_client
class ABCD:
    def function:
        yield metric

if __name__ == '__main__':

    start_http_server(int(sys.argv[1]))
    REGISTRY.register(ABCD())
    while True: time.sleep(1)

Best,
Dhanush Eswar G

Julius Volz

unread,
Jan 25, 2021, 9:47:45 AM1/25/21
to Dhanush Eswar, Prometheus Users
Hi Dhanush,

I'm not sure why running it on AWS would limit the duration of scraped data for 2h. When you say you are only seeing 2h, are those the 2h of data after you started the instance (so past data), or the latest 2h from now (so current data)? What does the "up" metric say during the time period where you have no data from your target? And do you see any scrape errors? Also, what is your Prometheus version, configuration, and command-line?

Regards,
Julius

Reply all
Reply to author
Forward
0 new messages