| 1 | --- |
| 2 | title: Twisted |
| 3 | weight: 1 |
| 4 | --- |
| 5 | |
| 6 | To use prometheus with [twisted](https://twistedmatrix.com/), there is `MetricsResource` which exposes metrics as a twisted resource. |
| 7 | |
| 8 | ```python |
| 9 | from prometheus_client.twisted import MetricsResource |
| 10 | from twisted.web.server import Site |
| 11 | from twisted.web.resource import Resource |
| 12 | from twisted.internet import reactor |
| 13 | |
| 14 | root = Resource() |
| 15 | root.putChild(b'metrics', MetricsResource()) |
| 16 | |
| 17 | factory = Site(root) |
| 18 | reactor.listenTCP(8000, factory) |
| 19 | reactor.run() |
| 20 | ``` |