This is the reblocks-prometheus Reference Manual, version 0.2.0, generated automatically by Declt version 4.0 beta 2 "William Riker" on Tue Jul 15 06:32:23 2025 GMT+0.
The main system appears first, followed by any subsystem dependency.
reblocks-prometheus
reblocks-prometheus/app
reblocks-prometheus/core
reblocks-prometheus/gauges/number-of-pages
reblocks-prometheus/gauges/number-of-sessions
reblocks-prometheus
This is an addon for Reblocks Common Lisp framework which allows to gather metrics in Prometheus format.
Alexander Artemenko
(GIT https://github.com/40ants/reblocks-prometheus)
Unlicense
<a id="x-28REBLOCKS-PROMETHEUS-DOCS-2FINDEX-3A-40README-2040ANTS-DOC-2FLOCATIVES-3ASECTION-29"></a>
# reblocks-prometheus - This is an addon for Reblocks Common Lisp framework which allows to gather metrics in Prometheus format.
<a id="reblocks-prometheus-asdf-system-details"></a>
## REBLOCKS-PROMETHEUS ASDF System Details
* Description: This is an addon for Reblocks Common Lisp framework which allows to gather metrics in Prometheus format.
* Licence: Unlicense
* Author: Alexander Artemenko
* Homepage: [https://40ants.com/reblocks-prometheus][0a5b]
* Bug tracker: [https://github.com/40ants/reblocks-prometheus/issues][8225]
* Source control: [GIT][d447]
* Depends on: [40ants-routes][25b9], [prometheus][14fa], [prometheus-gc][8b12], [prometheus.collectors.process][563a], [prometheus.collectors.sbcl][a01b], [prometheus.formats.text][b66b], [reblocks][184b]
[][1638]

This is an addon for Reblocks Common Lisp framework which allows to gather
metrics in [Prometheus][df56] format.
<a id="x-28REBLOCKS-PROMETHEUS-DOCS-2FINDEX-3A-3A-40INSTALLATION-2040ANTS-DOC-2FLOCATIVES-3ASECTION-29"></a>
## Installation
You can install this library from Quicklisp, but you want to receive updates quickly, then install it from Ultralisp.org:
“‘
(ql-dist:install-dist "http://dist.ultralisp.org/"
:prompt nil)
(ql:quickload :reblocks-prometheus)
“‘
<a id="x-28REBLOCKS-PROMETHEUS-DOCS-2FINDEX-3A-3A-40USAGE-2040ANTS-DOC-2FLOCATIVES-3ASECTION-29"></a>
## Usage
Add a special metrics route into you’re app’s route list. Use [‘reblocks-prometheus:metrics‘][7ea2] macro to define this route.
“‘
(defapp app
:prefix "/"
:routes
((reblocks-prometheus:metrics (\"/metrics\" :user-metrics *user-metrics*)))
)
“‘
A new route ‘/metrics‘ will be added to serve metrics in Prometheus format.
<a id="adding-custom-metrics"></a>
### Adding custom metrics
To add business specific metrics, define them as global variables
and then the pass to the [‘reblocks-prometheus:metrics‘][7ea2] macro like this:
“‘
(defparameter *load-average*
(prometheus:make-gauge :name \"test_load_average\"
:help \"Test load average\"
:registry nil))
(defparameter *num-users*
(prometheus:make-counter :name \"test_num_users_created\"
:help \"Test num users created after the last metrics collection\"
:registry nil))
(defparameter *user-metrics*
(list *load-average*
*num-users*))
(defapp app
:prefix "/"
:routes
((reblocks-prometheus:metrics (\"/metrics\" :user-metrics *user-metrics*)))
)
“‘
After this, you can change this counter and gauge using methods from prometheus.cl library:
“‘
(prometheus:gauge.set *load-average* 2)
(prometheus:counter.inc *num-users* :value 1)
(prometheus:counter.inc *num-users* :value 3)
“‘
and their values will change during subsequent get queries for /metrics page.
<a id="x-28REBLOCKS-PROMETHEUS-DOCS-2FINDEX-3A-3A-40API-2040ANTS-DOC-2FLOCATIVES-3ASECTION-29"></a>
## API
<a id="x-28REBLOCKS-PROMETHEUS-DOCS-2FINDEX-3A-3A-40REBLOCKS-PROMETHEUS-3FPACKAGE-2040ANTS-DOC-2FLOCATIVES-3ASECTION-29"></a>
### REBLOCKS-PROMETHEUS
<a id="x-28-23A-28-2819-29-20BASE-CHAR-20-2E-20-22REBLOCKS-PROMETHEUS-22-29-20PACKAGE-29"></a>
#### [package](482f) ‘reblocks-prometheus‘
<a id="x-28REBLOCKS-PROMETHEUS-DOCS-2FINDEX-3A-3A-7C-40REBLOCKS-PROMETHEUS-3FClasses-SECTION-7C-2040ANTS-DOC-2FLOCATIVES-3ASECTION-29"></a>
#### Classes
<a id="x-28REBLOCKS-PROMETHEUS-DOCS-2FINDEX-3A-3A-40REBLOCKS-PROMETHEUS-24METRICS-ROUTE-3FCLASS-2040ANTS-DOC-2FLOCATIVES-3ASECTION-29"></a>
##### METRICS-ROUTE
<a id="x-28REBLOCKS-PROMETHEUS-3AMETRICS-ROUTE-20CLASS-29"></a>
###### [class](8f47) ‘reblocks-prometheus:metrics-route‘ (route)
**Readers**
<a id="x-28REBLOCKS-PROMETHEUS-3ASTATS-REGISTRY-20-2840ANTS-DOC-2FLOCATIVES-3AREADER-20REBLOCKS-PROMETHEUS-3AMETRICS-ROUTE-29-29"></a>
###### [reader](0156) ‘reblocks-prometheus:stats-registry‘ (metrics-route) (= (reblocks-prometheus/app::make-reblocks-metrics-registry))
<a id="x-28REBLOCKS-PROMETHEUS-DOCS-2FINDEX-3A-3A-40REBLOCKS-PROMETHEUS-24PROMETHEUS-APP-MIXIN-3FCLASS-2040ANTS-DOC-2FLOCATIVES-3ASECTION-29"></a>
##### PROMETHEUS-APP-MIXIN
<a id="x-28REBLOCKS-PROMETHEUS-3APROMETHEUS-APP-MIXIN-20CLASS-29"></a>
###### [class](6f7f) ‘reblocks-prometheus:prometheus-app-mixin‘ ()
A mixin which gathers some stats to report in Prometheus format.
Also, this mixin adds a /metrics slot to the app.
Use [‘stats-registry‘][b2a2] to access the registry slot.
<a id="x-28REBLOCKS-PROMETHEUS-DOCS-2FINDEX-3A-3A-7C-40REBLOCKS-PROMETHEUS-3FFunctions-SECTION-7C-2040ANTS-DOC-2FLOCATIVES-3ASECTION-29"></a>
#### Functions
<a id="x-28REBLOCKS-PROMETHEUS-3AMETRICS-REGISTRY-20FUNCTION-29"></a>
##### [function](3240) ‘reblocks-prometheus:metrics-registry‘
Call this function during handler’s body to update gauges before metrics will be collected.
<a id="x-28REBLOCKS-PROMETHEUS-DOCS-2FINDEX-3A-3A-7C-40REBLOCKS-PROMETHEUS-3FMacros-SECTION-7C-2040ANTS-DOC-2FLOCATIVES-3ASECTION-29"></a>
#### Macros
<a id="x-28REBLOCKS-PROMETHEUS-3AMETRICS-20-2840ANTS-DOC-2FLOCATIVES-3AMACRO-29-29"></a>
##### [macro](a770) ‘reblocks-prometheus:metrics‘ (path &key name user-metrics) &body handler-body
This macro creates a route of [‘metrics-route‘][863c] class.
The body passed as ‘HANDLER-BODY‘ will be executed each time when metrics are collected.
You can use [‘metrics-registry‘][e21f] function to access the prometheus metrics registry
from the handler body code.
[7ea2]: #x-28REBLOCKS-PROMETHEUS-3AMETRICS-20-2840ANTS-DOC-2FLOCATIVES-3AMACRO-29-29
[e21f]: #x-28REBLOCKS-PROMETHEUS-3AMETRICS-REGISTRY-20FUNCTION-29
[863c]: #x-28REBLOCKS-PROMETHEUS-3AMETRICS-ROUTE-20CLASS-29
[b2a2]: #x-28REBLOCKS-PROMETHEUS-3ASTATS-REGISTRY-20-2840ANTS-DOC-2FLOCATIVES-3AREADER-20REBLOCKS-PROMETHEUS-3AMETRICS-ROUTE-29-29
[0a5b]: https://40ants.com/reblocks-prometheus
[d447]: https://github.com/40ants/reblocks-prometheus
[1638]: https://github.com/40ants/reblocks-prometheus/actions
[6f7f]: https://github.com/40ants/reblocks-prometheus/blob/fe1b4387940bb4648f5854e61ce329334288e8a8/src/app.lisp#L38
[8f47]: https://github.com/40ants/reblocks-prometheus/blob/fe1b4387940bb4648f5854e61ce329334288e8a8/src/app.lisp#L78
[0156]: https://github.com/40ants/reblocks-prometheus/blob/fe1b4387940bb4648f5854e61ce329334288e8a8/src/app.lisp#L79
[3240]: https://github.com/40ants/reblocks-prometheus/blob/fe1b4387940bb4648f5854e61ce329334288e8a8/src/app.lisp#L87
[a770]: https://github.com/40ants/reblocks-prometheus/blob/fe1b4387940bb4648f5854e61ce329334288e8a8/src/app.lisp#L94
[482f]: https://github.com/40ants/reblocks-prometheus/blob/fe1b4387940bb4648f5854e61ce329334288e8a8/src/core.lisp#L1
[8225]: https://github.com/40ants/reblocks-prometheus/issues
[df56]: https://prometheus.io/
[25b9]: https://quickdocs.org/40ants-routes
[14fa]: https://quickdocs.org/prometheus
[8b12]: https://quickdocs.org/prometheus-gc
[563a]: https://quickdocs.org/prometheus.collectors.process
[a01b]: https://quickdocs.org/prometheus.collectors.sbcl
[b66b]: https://quickdocs.org/prometheus.formats.text
[184b]: https://quickdocs.org/reblocks
* * *
###### [generated by [40ANTS-DOC](https://40ants.com/doc/)]
0.2.0
40ants-asdf-system
(system).
cffi-grovel
(system).
reblocks-prometheus/app
(system).
reblocks-prometheus/app
Alexander Artemenko
(GIT https://github.com/40ants/reblocks-prometheus)
Unlicense
prometheus
(system).
prometheus.formats.text
(system).
prometheus.collectors.sbcl
(system).
prometheus.collectors.process
(system).
reblocks/session
(system).
reblocks/routes
(system).
reblocks/variables
(system).
reblocks-prometheus/core
(system).
reblocks-prometheus/gauges/number-of-pages
(system).
reblocks-prometheus/gauges/number-of-sessions
(system).
prometheus-gc
(system).
40ants-routes/defroutes
(system).
40ants-routes/vars
(system).
40ants-routes/handler
(system).
reblocks-prometheus/core
Alexander Artemenko
(GIT https://github.com/40ants/reblocks-prometheus)
Unlicense
reblocks-prometheus/gauges/number-of-pages
Alexander Artemenko
(GIT https://github.com/40ants/reblocks-prometheus)
Unlicense
prometheus
(system).
reblocks/session
(system).
reblocks/page
(system).
Files are sorted by type and then listed depth-first from the systems components trees.
reblocks-prometheus/reblocks-prometheus.asd
reblocks-prometheus/app/file-type.lisp
reblocks-prometheus/core/file-type.lisp
reblocks-prometheus/gauges/number-of-pages/file-type.lisp
reblocks-prometheus/gauges/number-of-sessions/file-type.lisp
reblocks-prometheus/reblocks-prometheus.asd
reblocks-prometheus
(system).
reblocks-prometheus/app/file-type.lisp
reblocks-prometheus/app
(system).
initialize-instance
(method).
metrics
(macro).
metrics-registry
(function).
metrics-route
(class).
prometheus-app-mixin
(class).
serve
(method).
serve
(method).
stats-registry
(reader method).
*current-registry*
(special variable).
make-reblocks-metrics-registry
(function).
reblocks-prometheus/core/file-type.lisp
reblocks-prometheus/core
(system).
reblocks-prometheus/gauges/number-of-pages/file-type.lisp
collect
(method).
number-of-pages-gauge
(class).
reblocks-prometheus/gauges/number-of-sessions/file-type.lisp
number-of-anonymous-sessions-gauge
(class).
number-of-sessions-gauge
(class).
Packages are listed by definition order.
reblocks-prometheus/gauges/number-of-pages
reblocks-prometheus/app
reblocks-prometheus/gauges/number-of-sessions
reblocks-prometheus
reblocks-prometheus/gauges/number-of-pages
common-lisp
.
number-of-pages-gauge
(class).
reblocks-prometheus/app
common-lisp
.
*current-registry*
(special variable).
make-reblocks-metrics-registry
(function).
registry
(slot).
reblocks-prometheus/gauges/number-of-sessions
common-lisp
.
number-of-anonymous-sessions-gauge
(class).
number-of-sessions-gauge
(class).
reblocks-prometheus
reblocks-prometheus/core
common-lisp
.
metrics
(macro).
metrics-registry
(function).
metrics-route
(class).
prometheus-app-mixin
(class).
stats-registry
(generic reader).
Definitions are sorted by export status, category, package, and then by lexicographic order.
This macro creates a route of METRICS-ROUTE class.
The body passed as HANDLER-BODY will be executed each time when metrics are collected. You can use METRICS-REGISTRY function to access the prometheus metrics registry from the handler body code.
Call this function during handler’s body to update gauges before metrics will be collected.
metrics-route
)) ¶automatically generated reader method
number-of-pages-gauge
) cb) ¶prometheus
.
number-of-sessions-gauge
) cb) ¶prometheus
.
number-of-anonymous-sessions-gauge
) cb) ¶prometheus
.
prometheus-app-mixin
) &rest args) ¶metrics-route
) env) ¶reblocks/routes
.
metrics-route
) env) ¶Returns a text document with metrics in Prometheus format.
To add your own metrics, add a :BEFORE method to this method. In this :BEFORE method you can update gauge metrics.
reblocks/routes
.
route
.
(reblocks-prometheus/app::make-reblocks-metrics-registry)
This slot is read-only.
A mixin which gathers some stats to report in Prometheus format.
Also, this mixin adds a /metrics slot to the app.
Use STATS-REGISTRY to access the registry slot.
This var will be bound to the current prometheus registry during the REBLOCKS/ROUTES:SERVE generic-function call.
gauge
.
Initarg | Value |
---|---|
:name | reblocks_anonymous_sessions_count |
:value | 0 |
:help | a number of anonymous session pages (where :user key is absent). |
gauge
.
Initarg | Value |
---|---|
:name | reblocks_pages_count |
:value | 0 |
:help | a number of nonexpired session pages. |
gauge
.
Initarg | Value |
---|---|
:name | reblocks_sessions_count |
:value | 0 |
:help | a number of non-anonymous session pages (where :user key is present). |
Jump to: | C F G I M S |
---|
Jump to: | C F G I M S |
---|
Jump to: | *
R S |
---|
Index Entry | Section | ||
---|---|---|---|
| |||
* | |||
*current-registry* : | Private special variables | ||
| |||
R | |||
registry : | Public classes | ||
| |||
S | |||
Slot, registry : | Public classes | ||
Special Variable, *current-registry* : | Private special variables | ||
|
Jump to: | *
R S |
---|
Jump to: | C F M N P R S |
---|
Jump to: | C F M N P R S |
---|