🌐
Medium
medium.com › @dast04 › writing-custom-prometheus-exporters-in-python-kubernetes-73626b66d78c
Writing Custom Prometheus Exporters (in Python) — Kubernetes | by Daniello | Medium
August 22, 2024 - FROM python:3.11-alpine # This prevents Python from writing out pyc files ENV PYTHONDONTWRITEBYTECODE 1 # This keeps Python from buffering stdin/stdout ENV PYTHONUNBUFFERED 1 WORKDIR /app COPY requirements.txt /app/requirements.txt RUN pip install -r requirements.txt COPY main.py /app/main.py EXPOSE 8000 ENTRYPOINT ["python3", "main.py"] This step will depend on your personal preference. I have used AWS ECR for that purpose. We have written the exporter itself using prometheus-client, dockerized the application, and pushed it to the remote repository.
🌐
Prometheus
prometheus.io › docs › instrumenting › writing_exporters
Writing exporters | Prometheus
In this case, Prometheus should still do service discovery, and pass on the target to be scraped. See the blackbox and SNMP exporters for examples. Note that it is only currently possible to write this type of exporter with the Go, Python and Java client libraries.
Discussions

write an exporter in python: basic questions, organizing metrics
try not to hardcode IPs in the exporter itself, have a seperate .env file or config.yaml to list ips to make the exporter more modular and also maybe look at netbox to add the devices there and use the netbox api to fetch the device names and its IPs so that you can add / remove devices as your environment changes and automatically the exporter would fetch the current devices without changing any exporter code. also another tip is to dockerize the exporter once you are happy with it and restrict the compute it can use in docker compose so that in case there is any memory leak etc in your exporter it wouldnt crash your host. More on reddit.com
🌐 r/PrometheusMonitoring
12
5
July 23, 2025
Help with my prometheus exporter and python
Why do you think the output is "useless"? More on reddit.com
🌐 r/PrometheusMonitoring
8
1
August 2, 2024
FastAPI and Prometheus endpoint
You won't be able to start 2 servers/processes listening on the same port. First one to start, wins. The other will fail to bind as the port is already in use. What you could do though is start both on different ports, say 8080 and 8081 or something, then put nginx in front of it all and proxy through to which ever backend based on the requested path. As a bonus you can terminate TLS at the nginx level using a single cert etc etc too. More on reddit.com
🌐 r/FastAPI
5
1
December 16, 2022
Prometheus Middleware is out!
This is great work! Thanks for sharing Will try it out soon More on reddit.com
🌐 r/FastAPI
10
14
October 12, 2020
🌐
ITNEXT
itnext.io › prometheus-building-a-custom-prometheus-exporter-in-python-988908327600
Prometheus: Building a Custom Prometheus Exporter in Python | by Arseny Zinchenko (setevoy) | ITNEXT
May 21, 2023 - Currently, we use Blackbox Exporter to monitor it, but later we want to expand the capabilities a bit, so we will try to create an exporter that for now will simply check the response code of this endpoint.
🌐
Last9
last9.io › blog › best-practices-using-and-writing-prometheus-exporters
Best Practices Using and Writing Prometheus Exporters | Last9
January 25, 2026 - Access the Sample Page Once the ... simply a directory where you’ll write your exporter. For this example, the directory will be named httpd-exporter....
🌐
RTFM
rtfm.co.ua › home › monitoring › prometheus › prometheus: building a custom prometheus exporter in python
Prometheus: Building a Custom Prometheus Exporter in Python
February 25, 2023 - Currently, we use Blackbox Exporter to monitor it, but later we want to expand the capabilities a bit, so we will try to create an exporter that for now will simply check the response code of this endpoint.
🌐
Medium
medium.com › @shaharewq0 › creating-a-custom-prometheus-exporter-with-python-257b6492a0a0
Creating a Custom Prometheus Exporter with Python | by Shahar Cohen hadad | Medium
September 7, 2024 - They enable the collection of metrics that Prometheus doesn’t natively support, empowering you to gain deeper visibility into the behavior of your applications and infrastructure. To demonstrate the creation of a custom exporter, we’ll use Python along with two key libraries: the Prometheus_client library for defining and exposing metrics, and the Openshift.Dynamic library for interacting with the Openshift Container Platform API.
🌐
MetricFire
metricfire.com › blog › first-contact-with-prometheus
First Contact with Prometheus Exporters | MetricFire
May 27, 2024 - It covers two metric types: Counters ... and CPU usage). Examples include a standalone exporter for system resource usage and a Flask web application exporter for request response time and uptime....
🌐
Thomas Stringer
trstringer.com › quick-and-easy-prometheus-exporter
Create a Quick and Easy Prometheus Exporter | Thomas Stringer
January 3, 2021 - Let’s see a small but complete exporter implemented in Python (notes and explanation in comments and below the snippet): ... In the above code, I defined a helper class AppMetrics to contain the Prometheus metrics and app metric loop logic. Creating the class wasn’t necessary, but I think it is a bit cleaner and more future-proof to start this way and keep the logic and data contained in an object.
Find elsewhere
🌐
Readthedocs
opentelemetry-python-kinvolk.readthedocs.io › en › latest › exporter › prometheus › prometheus.html
OpenTelemetry Prometheus Exporter — OpenTelemetry Python documentation
from opentelemetry import metrics from opentelemetry.exporter.prometheus import PrometheusMetricsExporter from opentelemetry.sdk.metrics import Counter, Meter from prometheus_client import start_http_server # Start Prometheus client start_http_server(port=8000, addr="localhost") # Meter is responsible for creating and recording metrics metrics.set_meter_provider(MeterProvider()) meter = metrics.get_meter(__name__) # exporter to export metrics to Prometheus prefix = "MyAppPrefix" exporter = PrometheusMetricsExporter(prefix) # Starts the collect/export pipeline for metrics metrics.get_meter_provider().start_pipeline(meter, exporter, 5) counter = meter.create_counter( "requests", "number of requests", "requests", int, ("environment",), ) # Labels are used to identify key-values that are associated with a specific # metric that you want to record.
🌐
PyPI
pypi.org › project › prometheus-aioexporter
prometheus-aioexporter · PyPI
Creating a new exporter is just a matter of subclassing PrometheusExporterScript and implementing a few methods as needed. ... import click from prometheus_aioexporter import Arguments, PrometheusExporterScript class MyExporter(PrometheusExporterScript): """My Prometheus exporter.""" name = "my-exporter" default_port = 9091 envvar_prefix = "MYEXP" def command_line_parameters(self) -> list[click.Parameter]: # Additional options for the script return [ click.Option(["--custom-option"], help="a custom option"), ...
      » pip install prometheus-aioexporter
    
Published: Mar 26, 2026
Version: 3.2.0
🌐
Enix
enix.io › en › blog › create-prometheus-exporter
How to Create a Prometheus Exporter?
It’s important to note that Prometheus provides several libraries to define and expose your metrics based on the language your exporter uses: ... And other unofficial libraries can be found here. Now, let’s move on to the practical side, let’s begin by setting up a basic HTTP server. For this tutorial, I’ll use the python language and the official client library.
🌐
SysOpsPro
sysopspro.com › home › building a custom prometheus exporter in python
Building a Custom Prometheus Exporter in Python - SysOpsPro
July 13, 2024 - In this tutorial, you will learn the process of developing a custom Prometheus Exporter in Python. We will create an exporter to monitor an API endpoint and expose selected data as Prometheus metrics.
🌐
GitHub
github.com › albertodonato › prometheus-aioexporter
GitHub - albertodonato/prometheus-aioexporter: Asyncio library for creating Prometheus exporters · GitHub
Creating a new exporter is just a matter of subclassing PrometheusExporterScript and implementing a few methods as needed. An example usage is the following: import click from prometheus_aioexporter import Arg
Starred by 17 users
Forked by 9 users
Languages: Python
🌐
PyPI
pypi.org › project › prometheus-flask-exporter
prometheus-flask-exporter · PyPI
If this doesn't suit your needs, set the path argument to None and/or the export_defaults argument to False plus change the registry argument if needed. The group_by constructor argument controls what the default request duration metric is tracked by: endpoint (function) instead of URI path (the default). This parameter also accepts a function to extract the value from the request, or a name of a property of the request object. Examples: PrometheusMetrics(app, group_by='path') # the default PrometheusMetrics(app, group_by='endpoint') # by endpoint PrometheusMetrics(app, group_by='url_rule') # by URL rule def custom_rule(req): # the Flask request object """ The name of the function becomes the label name.
🌐
Ashish
ashish.one › blogs › [part 3] how to write custom prometheus exporter?
[Part 3] How to write custom prometheus exporter? | ashish.one
May 11, 2022 - Like below: It exposes the data on a specific port e.g http://myurl:8000. Let’s take a very basic example, Suppose there is one script (Daemon service) is running with the name myprocess.go.
🌐
DEV Community
dev.to › ladiesindevops › building-a-prometheus-exporter-1cb9
Building a Prometheus Exporter - DEV Community
May 5, 2021 - We will build a Prometheus exporter for monitoring HTTP servers from logs. It extracts data from HTTP logs and exports it to Prometheus. We will be using a python client library, prometheus_client, to define and expose metrics via an HTTP endpoint.
🌐
Qone
qone.io › prometheus › exporter › python › 2016 › 08 › 28 › docker-prometheus-exporter-python.html
simple prometheus exporter in python - qone.io
If metrics is exported in a format like response{latency="p99"} response{latency="p95"} . You can new do a promQL like this response{latency="p99"} to access this metrics. import falcon from wsgiref import simple_server from prometheus_client.exposition import CONTENT_TYPE_LATEST from ...
🌐
GitHub
gist.github.com › rchakode › 8c362c23876b82c85e997c029b076540
Sample Python program providing a Prometheus exporter that exposes system CPU and memory usage every 5 minutes. · GitHub
Sample Python program providing a Prometheus exporter that exposes system CPU and memory usage every 5 minutes. - prometheus_exporter_system_resource_usage.py
🌐
rokpoto
rokpoto.com › home › blog › how to create and debug custom python prometheus exporter
How to create and debug custom Python Prometheus exporter | rokpoto
February 11, 2023 - Create custom Python Prometheus exporter and debug it fast in docker container. Prometheus and Grafana are configured in code.