Sign inSign up

phsmith/rundeck-exporter

By phsmith

•Updated 5 days ago

Rundeck Metrics Exporter for Prometheus

Image
Monitoring & observability
0

100K+

phsmith/rundeck-exporter repository overview

⁠Rundeck metrics exporter for Prometheus

Docker Pulls GitHub release (latest SemVer)

Rundeck-Grafana-Dashboard

Dashboard example can be found in: examples/grafana⁠

This exporter uses the prometheus_client and requests Python module to expose Rundeck metrics found in:

Where version represents the Rundeck API version, like: 31,32,33,34,etc.

This code was tested on Rundeck API version 31+.

Warning

Since version 4.x.x, the /api/<version>/metrics endpoint is disabled, so you need to enable it in rundeck-config.properties or by setting the environment variable RUNDECK_METRICS_ENABLED=true for the exporter to work. See config-file-reference.html#metrics-capturing⁠

If audit logs are enabled, consider changing the default INFO log level to prevent excessive log growth.

⁠Metrics

All metrics are exported with rundeck_ prefix.

More detailed information about the metrics can be found in Documentations⁠

⁠Dependencies

Although the requirements.txt file is still available, the project uses UV⁠ for Python package and management, which is highly recommended.

  • Python 3.10+

  • A Rundeck token with permissions to make API requests

  • The following steps for installing the dependencies:

    uv sync
    

    Or:

    python -m venv .venv
    source .venv/bin/activate
    pip install -r requirements.txt
    

⁠API Authentication

Rundeck token or username and password are required.

The token (RUNDECK_TOKEN) or password (RUNDECK_USERPASSWORD) must be passed as environment variables to work.

The ACL associated with the token/user must have the following policy rules as a minimum:

  • system:read (system context)
  • project:read (system context)
  • events:read (project context)

Example ACL Policy allowing a user named exporter to get system metrics as well as execution metrics for any project:

  by:
    username: exporter
  description: system:read
  for:
    resource:
    - allow:
      - read
      equals:
        kind: system
  context:
    application: rundeck
---
by:
  username: exporter
description: project:read
for:
  project:
  - allow:
    - read
    match:
      name: .*
context:
  application: rundeck
---
by:
  username: exporter
description: events:read
for:
  resource:
  - allow:
    - read
    equals:
      kind: event
  job:
  - allow:
    - read
    - view
context:
  project: .*
---
by:
  username: exporter
description: Allow [read] for node
for:
  node:
  - allow:
    - read
    match:
      nodename: .*
context:
  project: .*

---
by:
  username: exporter
description: Allow [read] for (All) node
for:
  resource:
  - allow:
    - read
    equals:
      kind: node
context:
  project: .*

⁠Usage

The rundeck_exporter supports the following paramenters:

$ rundeck_exporter --help

usage: rundeck_exporter [-h] [--debug] [-v] [--host RUNDECK_EXPORTER_HOST] [--port RUNDECK_EXPORTER_PORT] [--no_checks_in_passive_mode] [--threadpool_max_workers RUNDECK_EXPORTER_THREADPOOL_MAX_WORKERS] [--rundeck.requests.timeout RUNDECK_EXPORTER_REQUESTS_TIMEOUT] [--rundeck.url RUNDECK_URL] [--rundeck.skip_ssl] [--rundeck.api.version RUNDECK_API_VERSION]
                           [--rundeck.username RUNDECK_USERNAME] [--rundeck.projects.executions] [--rundeck.projects.executions.filter RUNDECK_PROJECT_EXECUTIONS_FILTER] [--rundeck.projects.executions.limit RUNDECK_PROJECTS_EXECUTIONS_LIMIT] [--rundeck.projects.executions.cache] [--rundeck.projects.filter RUNDECK_PROJECTS_FILTER [RUNDECK_PROJECTS_FILTER ...]]
                           [--rundeck.projects.nodes.info] [--rundeck.cached.requests.ttl RUNDECK_CACHED_REQUESTS_TTL] [--rundeck.cpu.stats] [--rundeck.memory.stats]

Rundeck Metrics Exporter

required environment vars:
    RUNDECK_TOKEN        Rundeck API Token
    RUNDECK_USERPASSWORD Rundeck User Password (RUNDECK_USERNAME or --rundeck.username are required too)

options:
  -h, --help            show this help message and exit
  --debug               Enable debug mode
  -v, --version         Shows rundeck_exporter current release version
  --host RUNDECK_EXPORTER_HOST
                        Host binding address. Default: 127.0.0.1
  --port RUNDECK_EXPORTER_PORT
                        Host binding port. Default: 9620
  --no_checks_in_passive_mode
                        The rundeck_exporter will not perform any checks while the Rundeck host is in passive execution mode
  --threadpool_max_workers RUNDECK_EXPORTER_THREADPOOL_MAX_WORKERS
                        The maximum number of workers in the threadpool to run rundeck_exporter asynchronous checks. Defaults to (number of CPUs) + 4
  --rundeck.requests.timeout RUNDECK_EXPORTER_REQUESTS_TIMEOUT
                        The maximum number of seconds that requests to the Rundeck API should timeout
  --rundeck.url RUNDECK_URL
                        Rundeck Base URL [ REQUIRED ]
  --rundeck.skip_ssl    Rundeck Skip SSL Cert Validate
  --rundeck.api.version RUNDECK_API_VERSION
                        Defaults to 34
  --rundeck.username RUNDECK_USERNAME
                        Rundeck User with access to the system information
  --rundeck.projects.executions
                        Get projects executions metrics
  --rundeck.projects.executions.filter RUNDECK_PROJECT_EXECUTIONS_FILTER
                        Get the latest project executions filtered by time period Can be in: [s]: seconds, [n]: minutes, [h]: hour, [d]: day, [w]: week, [m]: month, [y]: year Defaults to 5n
  --rundeck.projects.executions.limit RUNDECK_PROJECTS_EXECUTIONS_LIMIT
                        Project executions max results per query. Defaults to 20
  --rundeck.projects.executions.cache
                        Cache requests for project executions metrics query
  --rundeck.projects.filter RUNDECK_PROJECTS_FILTER [RUNDECK_PROJECTS_FILTER ...]
                        Get executions only from listed projects (delimiter = space)
  --rundeck.projects.nodes.info
                        Display Rundeck projects nodes info metrics, currently only the `rundeck_project_nodes_total` metric is available. May cause high CPU load depending on the number of projects
  --rundeck.cached.requests.ttl RUNDECK_CACHED_REQUESTS_TTL
                        Rundeck cached requests expiration time. Defaults to 120
  --rundeck.cpu.stats   Show Rundeck CPU usage stats
  --rundeck.memory.stats
                        Show Rundeck memory usage stats

Optionally, it's possible to pass the following environment variables to the rundeck_exporter:

VariableOptionsDescription
RUNDECK_EXPORTER_DEBUG
  • True
  • False (default)
Enable debug mode
RUNDECK_EXPORTER_HOSTDefault: 127.0.0.1Binding address
RUNDECK_EXPORTER_PORTDefault: 9620Binding port
RUNDECK_URL (required)Rundeck base URL
RUNDECK_TOKEN (required)Rundeck access token
RUNDECK_USERNAMERundeck User with access to the system information
RUNDECK_USERPASSWORDRundeck User Password (RUNDECK_USERNAME or --rundeck.username are required too)
RUNDECK_API_VERSIONDefault: 41Rundeck API version
RUNDECK_SKIP_SSL
  • True
  • False (default)
Skip SSL certificate check
RUNDECK_PROJECTS_EXECUTIONS
  • True
  • False (default)
Get projects executions metrics
RUNDECK_PROJECTS_FILTERGet executions only from listed projects e.g. "project-1 project-2 ..."
RUNDECK_PROJECT_EXECUTIONS_FILTERDefault: 5nProject executions filter by a period of time. Can be in: [s]: seconds, [n]: minutes, [h]: hour, [d]: day, [w]: week, [m]: month, [y]: year
RUNDECK_PROJECTS_EXECUTIONS_LIMITDefault: 20Projects executions max results per query
RUNDECK_PROJECTS_EXECUTIONS_CACHE
  • True
  • False (default)
Cache requests for project executions metrics query
RUNDECK_PROJECTS_NODES_INFO
  • True
  • False (default)
Display Rundeck projects nodes info metrics, currently only the rundeck_project_nodes_total metric is available. May cause high CPU load depending on the number of projects
RUNDECK_CACHED_REQUESTS_TTLDefault: 120Rundeck cached requests expiration time
RUNDECK_CPU_STATS
  • True
  • False (default)
Show Rundeck CPU usage stats
RUNDECK_MEMORY_STATS
  • True
  • False (default)
Show Rundeck memory usage stats
RUNDECK_EXPORTER_NO_CHECKS_IN_PASSIVE_MODE
  • True
  • False (default)
The rundeck_exporter will not perform any checks while the Rundeck host is in passive execution mode
RUNDECK_EXPORTER_THREADPOOL_MAX_WORKERSDefault: (number of CPUs) + 4The maximum number of workers in the threadpool to run rundeck_exporter asynchronous checks
RUNDECK_EXPORTER_REQUESTS_TIMEOUTDefault: 30The maximum number of seconds that requests to the Rundeck API should timeout
⁠Example
$ RUNDECK_TOKEN=xxxxxxxx uv run rundeck_exporter \
    --host=0.0.0.0 \
    --rundeck.url=http://localhost:4440 \
    --rundeck.skip_ssl \
    --rundeck.cpu.stats \
    --rundeck.memory.stats \
    --rundeck.projects.filter="project-1 project-2 project-n" \
    --rundeck.projects.executions \
    --rundeck.projects.executions.filter=5n \
    --rundeck.requests.timeout=10
⁠Running from pypi
pip install rundeck-exporter
rundeck_exporter -v
⁠Running with Docker
docker build -t rundeck-exporter .

docker run --rm -d -p 9620:9620 -e RUNDECK_TOKEN=$RUNDECK_TOKEN rundeck-exporter \
--host 0.0.0.0 \
--rundeck.url https://rundeck.test.com \
--rundeck.skip_ssl
⁠Running with Docker-Compose
cd examples/docker-compose
docker compose up -d

Docker Compose services:

After provisioning of the docker-compose services, access Rundeck from http://localhost:4440/user/profile⁠ and gerate a new API token. Place the token at RUNDECK_TOKEN environment variable in the docker-compose.yml and run docker compose up -d again.

Tag summary

Content type

Image

Digest

sha256:519c8b979…

Size

17.5 MB

Last updated

5 days ago

docker pull phsmith/rundeck-exporter