[Python] How to send Prometheus-formatted metrics from Python to an existing server on port...

Discussão em 'Python' iniciado por Stack, Julho 23, 2025.

  1. Stack

    Stack Membro Participativo

    I'm working on a metrics pipeline and need help integrating my Python application with an existing setup. Here's what I'm trying to do:

    1. I have a Python app that generates metrics.
    2. I want to send Prometheus-formatted metrics to port 2020, but I do not want to start a new HTTP server in my Python app.
    3. Port 2020 is already open and used by another application (assume it's ready to accept Prometheus-style metrics).
    4. Fluent Bit will then scrape data from port 2020 using the Prometheus input plugin, and forward it to New Relic Metrics.

    My main question is:

    How can I send Prometheus-compatible metrics from my Python app to an already-running server on port 2020 without starting a new server?

    Things I’ve considered: I know the prometheus_client library in Python starts a metrics server (e.g., on port 8000), but that’s not what I want.

    I just want to push or write metrics in a way that another server on port 2020 can consume it.

    Any guidance on:

    1. How to send metrics to an already open port used by another app?
    2. How to do this in Prometheus format?
    3. Whether there’s a way to write or forward metrics manually to that server?

    Thanks in advance!

    Continue reading...

Compartilhe esta Página