Monitoring short lived python Batch Job Processes using Prometheus

前端 未结 2 840
旧时难觅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:25

    You may want to look at Prometheus' Pushgateway: whenever your script completes, it can push the metrics it collected (e.g. a histogram of how long your function calls took, total CPU utilization, peak memory utilization etc.).

    You seem to be saying your script will run approximately once a second. I am hoping that means something along the lines of "once every 5 minutes for each of 300 tenants". In a case like this, you would push your metrics with something like a tenant_id label and be able to see either per-tenant or aggregated metrics.

    If your script runs once a second with the same parameters/configuration, then you'll probably lose some of the metrics because multiple scripts may terminate within the same second, all push their metrics and only the last one's metrics will get collected by Prometheus (as I believe you can't set a collection interval lower than 1 second in Prometheus).

提交回复
热议问题