HUB
Sign inSign up
paperclip-exporter logo

visibilityspots/paperclip-exporter

By visibilityspots

•Updated 2 days ago

Paperclip Prometheus Exporter

Buildkit cache
Image
0

392

visibilityspots/paperclip-exporter repository overview

⁠Paperclip exporter

trivy docker-hub-description build status gitHub release docker image size docker pulls license

a Prometheus exporter for a self-hosted Paperclip⁠ instance.

Paperclip has no metrics endpoint of its own. This exporter polls its REST API every minute and serves what it finds on /metrics: whether the AI connection your agents use is still connected, the state of every agent, failed heartbeat runs, the last run of each routine and the number of issues per status. That is enough to alert on a lost Claude login, a routine that stopped running or a pile of blocked issues before anyone notices by hand.

It is a single Python file without dependencies, running as a non-root user.

⁠run

$ docker run -d --name paperclip-exporter -p 9878:9878 \
    -e PAPERCLIP_API=https://paperclip.example.com/api \
    -e PAPERCLIP_COMPANY_ID=<company uuid> \
    -e PAPERCLIP_API_KEY=<board api key> \
    visibilityspots/paperclip-exporter:latest
$ curl -s localhost:9878/metrics | grep paperclip_up
paperclip_up 1
⁠API key

The exporter only reads. A user with the viewer role is enough, and also sees AI connections that are shared with the company. Create a dedicated user, log in as that user with the Paperclip CLI and create a board API key without expiry; board keys expire after 30 days by default:

$ curl -s -X POST -H "Authorization: Bearer <cli token>" -H 'Content-Type: application/json' \
    -d '{"name":"paperclip-exporter","expiresAt":null}' \
    https://paperclip.example.com/api/board-api-keys

Leave requestedCompanyId out of that request: with it, Paperclip runs a company check that refuses a POST from a viewer (Viewer access is read-only). Revoke the CLI key afterwards.

⁠Health

/healthz answers 200 ok whenever the process runs, independent of Paperclip. An unreachable API or a revoked key shows up as paperclip_up 0, not as a dead exporter.

⁠Configuration

variabledefault
PAPERCLIP_APIbase url of the API, ending in /api (required)
PAPERCLIP_COMPANY_IDuuid of the company to export (required)
PAPERCLIP_API_KEYboard API key (required)
METRICS_PORT9878listen port for /metrics and /healthz
POLL_INTERVAL60seconds between two polls
HTTP_TIMEOUT20timeout per API request in seconds

When one of the required variables is empty (or the literal <no value> a consul-template render leaves for a missing key), the exporter does not poll and reports paperclip_up 0.

⁠Metrics
metriclabelsmeaning
paperclip_up1 when the last poll of every endpoint succeeded
paperclip_last_poll_success_timestamp_secondslast fully successful poll, 0 = never
paperclip_poll_duration_secondsduration of the last poll
paperclip_poll_errors_totalendpointfailed API calls since start
paperclip_infoversionserver version from /api/health
paperclip_health_ok1 when /api/health reports ok
paperclip_ai_connection_connectedconnection, provider, status, in_use1 when the connection is connected; in_use is true when an agent points to it
paperclip_agent_infoagent, agent_id, status, lifecycle_statealways 1
paperclip_agent_pausedagent, agent_id1 when paused
paperclip_agent_erroragent, agent_id1 when the agent reports an error
paperclip_agent_last_heartbeat_timestamp_secondsagent, agent_idlast heartbeat
paperclip_runsstatusheartbeat runs in the API response
paperclip_runs_truncated1 when the run list hit the 1000 row limit
paperclip_run_last_failure_timestamp_secondserror_codefinish time of the latest failed run per error code
paperclip_run_last_finished_timestamp_secondsfinish time of the latest run
paperclip_routinesnumber of routines
paperclip_routine_activeroutine, routine_id1 when the routine is active
paperclip_routine_last_run_timestamp_secondsroutine, routine_idlast run of the routine
paperclip_routine_last_run_successroutine, routine_id1 when the last run reached completed; issue_created is not success
paperclip_issuesstatusissues per status

Labels never carry free text: names are lowercased and stripped to [a-z0-9_-], template parts like {{date}} are removed, ids are cut to 8 characters and error codes outside a fixed list become other.

Failed runs are a timestamp, not a counter. The exporter keeps no state, so a counter would count the whole run history again after every restart.

⁠build

$ docker build -t visibilityspots/paperclip-exporter:latest .
⁠buildx
$ docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
$ docker buildx build -t visibilityspots/paperclip-exporter:latest --platform linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64 --push .
⁠dgoss

The tests in goss.yaml run the real entrypoint without an API key, so the exporter starts, serves /metrics and /healthz and refuses to poll. goss_wait.yaml waits until it listens:

$ dgoss run -e PAPERCLIP_API=http://127.0.0.1:1/api -e PAPERCLIP_COMPANY_ID=test visibilityspots/paperclip-exporter:dev
INFO: Creating podman container
INFO: Copy goss files into container
INFO: Starting podman container
INFO: Container ID: afc079c3
INFO: Found goss_wait.yaml, waiting for it to pass before running tests
INFO: Sleeping for 0.2
INFO: Container health
INFO: Running Tests
File: /opt/paperclip-exporter/exporter.py: exists: matches expectation: true
User: exporter: exists: matches expectation: true
User: exporter: uid: matches expectation: 10001
Process: python3: running: matches expectation: true
Command: id -u: exit-status: matches expectation: 0
Command: id -u: stdout: matches expectation: ["10001"]
HTTP: http://127.0.0.1:9878/metrics: status: matches expectation: 200
HTTP: http://127.0.0.1:9878/metrics: Body: matches expectation: ["paperclip_up 0","paperclip_last_poll_success_timestamp_seconds 0"]
Command: python3 --version: exit-status: matches expectation: 0
HTTP: http://127.0.0.1:9878/healthz: status: matches expectation: 200
HTTP: http://127.0.0.1:9878/healthz: Body: matches expectation: ["ok"]
Port: tcp:9878: listening: matches expectation: true


Total Duration: 0.002s
Count: 12, Failed: 0, Skipped: 0
INFO: Deleting container
⁠act

using act⁠ for local testing of the written github actions makes my life and commit history a lot easier;

Stage  Job ID  Job name  Workflow name           Workflow file               Events
0      update  update    docker-hub-description  docker-hub-description.yml  push
0      main    main      CI                      main.yml                    push,pull_request
0      scan    scan      trivy                   trivy.yml                   workflow_dispatch,push,schedule
⁠release

Images are built and pushed by the shared workflow in visibilityspots/github-workflows⁠ when a tag is pushed. Pushing to main builds nothing; a pull request only builds and runs dgoss.

⁠License

Distributed under the MIT license⁠

Tag summary

Content type

Image

Digest

sha256:e28d675f4…

Size

20.3 MB

Last updated

2 days ago

docker pull visibilityspots/paperclip-exporter