Skip to content

Quick Start

Install

$ git clone https://git.doom.fm/citruspi/calibre-metrics.git && \
  cd calibre-metrics && cargo build --release

Expose Some Metrics

You'll need to know the path to your Calibre library database for this next part. In most cases it should be

{path-to-calibre-library}/metadata.db

For example if your library exists in the default location

~/Calibre Library

then the path will be

~/Calibre Library/metadata.db

Create a XML config file - you can name this whatever you'd like but I'll use config.xml

<?xml version="1.0" encoding="UTF-8"?>
<calibre-metrics>
    <library db-path="/Users/citruspi/Calibre Library/metadata.db"/>
</calibre-metrics>

Set the the db-path attribute on the library element to the path to your database as I have above.

Warning

Library database paths must be relative or full-paths - tildes, environment variables, etc. will not be expanded.

You should see something similar to

$ ./calibre-metrics -c config.xml
version: 0.1.0
 Jul 27 06:00:04.063 INFO loading config, path: config.xml
 Jul 27 06:00:04.064 WARN no read config specified
 Jul 27 06:00:04.064 WARN using default read config, interval: 30
 Jul 27 06:00:04.064 WARN no sink config specified
 Jul 27 06:00:04.064 WARN using default sink config, bind: 127.0.0.1:7323, type: prometheus
 Jul 27 06:00:04.064 WARN no metrics config specified
 Jul 27 06:00:04.064 WARN using default metrics config, metrics: ["books"]
 Jul 27 06:00:04.065 INFO reading calibre db, path: /Users/citruspi/Calibre Library/metadata.db
 Jul 27 06:00:04.068 INFO finished loading all metrics, elapsed_ms: 3
 Jul 27 06:00:04.068 INFO sleeping, time_ms: 29997

In another shell run curl:

$ curl -s  http://127.0.0.1:7323/metrics
# HELP calibre_books Title count
# TYPE calibre_books gauge
calibre_books{library="/Users/citruspi/Calibre Library/metadata.db"} 33

Congrats! You're now exposing a Calibre library metric via Prometheus.

Head on to the next section to learn more about configuration options.