Public | Automated Build

Last pushed: a year ago
Short Description
Initially for testing purposes only.
Full Description

prometheus-rancher-exporter

Exposes Rancher environment status to Prometheus. Makes use of Rancher labels to create a connection to the API.
Expects to get the following environment variables from the host, if not using rancher-compose then you can update these yourself:

  • CATTLE_ACCESS_KEY
  • CATTLE_SECRET_KEY
  • CATTLE_CONFIG_URL

Install and deploy

Run from Docker Hub:

docker run -d --restart=always -p 9010:9010 jolyonbrown/prometheus-rancher-exporter

Build a docker image:

docker build -t <image-name> .
docker run -d --restart=always -p 9010:9010 <image-name>

Running the node process:

DEBUG=re node app.js

Docker compose

prometheus-rancher-exporter:
    tty: true
    labels:
      io.rancher.container.create_agent: true
      io.rancher.container.agent.role: environment
    expose:
      - 9010:9010
    image: jolyonbrown/prometheus-rancher-exporter

Metrics

Metrics will be made available on port 9010 by default, or you can pass environment variable LISTEN_PORT to override this.

# HELP rancher_environment Value of 1 if all containers in a stack are active
# TYPE rancher_environment gauge
rancher_environment{name="test1"} 1
rancher_environment{name="test2"} 0
rancher_environment{name="load_test"} 1
rancher_environment{name="preprod"} 1
Docker Pull Command
Owner
rucknar

Comments (3)
nileshd
a year ago

same here.. getting the same error -- /app/app.js:111
return name.replace(/[^a-zA-Z0-9:]/g, '')

yekeqiang
a year ago

/app/app.js:111
return name.replace(/[^a-zA-Z0-9:]/g, '')
^
TypeError: Cannot call method 'replace' of null
at getSafeName (/app/app.js:111:17)
at /app/app.js:95:32
at Array.map (native)
at /app/app.js:93:22
at /app/app.js:218:9
at /app/node_modules/async/lib/async.js:52:16
at Object._onImmediate (/app/node_modules/async/lib/async.js:1206:34)
at processImmediate [as _immediateCallback] (timers.js:363:15)

npm ERR! prometheus-rancher-exporter@0.1.0 start: node app.js
npm ERR! Exit status 8
npm ERR!
npm ERR! Failed at the prometheus-rancher-exporter@0.1.0 start script.
npm ERR! This is most likely a problem with the prometheus-rancher-exporter package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node app.js
npm ERR! You can get their info via:
npm ERR! npm owner ls prometheus-rancher-exporter
npm ERR! There is likely additional logging output above.
npm ERR! System Linux 3.10.0-327.el7.x86_64
npm ERR! command "/usr/bin/node" "/usr/bin/npm" "start"
npm ERR! cwd /app
npm ERR! node -v v0.10.42
npm ERR! npm -v 1.4.29
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /app/npm-debug.log
npm ERR! not ok code 0

yekeqiang
a year ago

when i use rancher catalog run prometheus, it cann't work properly,