Skip to content

just1not2/prometheus-exporter-yourls

Repository files navigation

YOURLS Prometheus Exporter Listed in Awesome YOURLS!

A Prometheus exporter to fetch some metrics from a YOURLS URL-shortener instance.

Exported metrics

Gauges

Name Description
yourls_clicks_total Total number of clicks
yourls_links_total Total number of deployed links

Go metrics

A variety of Go metrics that describe the exporter are exported as well.

Installation

Docker image

The preferred way to use the exporter is by running the provided Docker image. It is currently available on Docker Hub:

docker pull just1not2/prometheus-exporter-yourls:latest

In addition to the latest tag which points to the version currently in the main branch, tagged versions are also available.

From source

You can clone the repository and build the exporter locally.

git clone https://github.com/just1not2/prometheus-exporter-yourls.git
cd prometheus-exporter-yourls
make local

Configuration

Exporter configuration

There are two ways to configure the exporter:

  • Environment variables
  • Configuration file

The first method takes precedence over the second one.

To use the first one, you just have to declare environment variables while launching the Docker image, a Docker-compose or directly the executable:

docker run -p 9923:9923 \
           -e YOURLS_URL=http://yourls.example.com \
           -e YOURLS_SIGNATURE=SECRET_API_KEY \
           just1not2/prometheus-exporter-yourls:latest

If you prefer to configure your provider with the second method, you should copy the config.json.template file and replace the sample values. You can then launch the exporter:

docker run -p 9923:9923 -v $(pwd)/config.json:/config.json just1not2/prometheus-exporter-yourls:latest config.json

The configuration parameters that can be declared are summarized in this table:

Parameter Environment variable Description Note
url YOURLS_URL URL of the YOURLS instance Required
signature YOURLS_SIGNATURE Signature of the YOURLS instance Required
exporter_port YOURLS_EXPORTER_PORT Port on which the exporter listens Default is 9923
exporter_timeout YOURLS_EXPORTER_TIMEOUT Timeout of requests to the YOURLS instance Default is 10

The signature parameter can be found at http://<your YOURLS instance URL>/admin/tools.php.

Scrape configuration

The exporter will query the YOURLS server every time it is scraped by Prometheus. You can modify the configuration of the exporter to change the scrape interval:

scrape_configs:
  - job_name: yourls
    scrape_interval: 1m
    static_configs:
      - targets: ['<your YOURLS exporter host>:9923']

See also

Contributing to this exporter

This exporter started as personal project, but I welcome community contributions to this exporter. If you find problems, please open an issue or create a PR against the YOURLS exporter repository.

You can also reach me by email at [email protected].

Licensing

GNU General Public License v3.0 or later.

See LICENSE to see the full text.

Author information

This exporter was created in 2022 by Justin Béra.