Apologies if this is tagged incorrectly, but i have a perl script and would like to send metrics directly to prometheus/grafana from within the script so they are as close to real time as possible. Anyone have any recommendations?
You have some curl/python/go examples here:
So rewrite them into your Perl. You can use Opentelemetry protocol
Have you also looked at alloy to ship logs to Loki or Prometheus
Is your script more of a job, more of a service, or more of a worker?
If it’s a service (HTTP server that handles requests), you can expose metrics in openmetrics format and have prometheus scrape them in a given interval.
If it’s a script that has one job to do and then dies, you can use prometheus pushgateway - notice the override of the metrics each time you push them. Pushgateway will store your metrics so that prometheus can scrape them.
If it’s more of a worker (continuous working but doesn’t expose HTTP service), you can also use pushgateway and push metrics in a given interval there but there’s a couple of things to keep in mind.