Monitoring short lived python Batch Job Processes using Prometheus

前端 未结 2 838
旧时难觅i
旧时难觅i 2021-01-21 06:39

How can I monitor my python processes (say some script that gets triggered periodically by Cron daemon) using Prometheus?

Note that this is not a web application but a s

2条回答
  •  生来不讨喜
    2021-01-21 07:29

    you can use pushgateway and prometheus_client

    from prometheus_client import CollectorRegistry, Gauge, push_to_gateway
    
    registry = CollectorRegistry()
    g = Gauge('job_last_success_unixtime', 'Last time a job successfully finished', registry=registry)
    g.set_to_current_time()
    push_to_gateway('localhost:9091', job='job_a', registry=registry)
    

提交回复
热议问题