Junior — Middle
Have you had experience setting up monitoring systems and collecting metrics using Prometheus and visualizing data through Grafana?
sobes.tech AI
Answer from AI
Yes, I have configured monitoring systems using Prometheus to collect metrics from various services and applications. Prometheus allows collecting metrics via HTTP using exporters and storing them in time series. For data visualization, I used Grafana, where I created dashboards with graphs, alerts, and panels for convenient system status analysis.
An example of setting up metric export in Python using the prometheus_client library:
from prometheus_client import start_http_server, Summary
import random
import time
REQUEST_TIME = Summary('request_processing_seconds', 'Time spent processing request')
@REQUEST_TIME.time()
def process_request():
time.sleep(random.random())
if __name__ == '__main__':
start_http_server(8000) # starts an HTTP server for Prometheus
while True:
process_request()
After launching such a service, Prometheus can collect metrics from http://localhost:8000/metrics, and Grafana can visualize them.