Skip to content

Commit

Permalink
Add Rundeck execution mode metrics and other fixes (#99)
Browse files Browse the repository at this point in the history
* chore: update docker-compose example

* fix(#98): move metrics variable for correct permission issue message.

* feat(#97): add rundeck_execution_mode_<active/passive> metrics
  • Loading branch information
phsmith authored Aug 31, 2024
1 parent 75dbdcf commit 8ce4a72
Show file tree
Hide file tree
Showing 9 changed files with 169 additions and 30 deletions.
17 changes: 16 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [2.8.0] - 2024-08-31
### Added

- Issue [#97](https://github.com/phsmith/rundeck_exporter/issues/97), new rundeck_execution_mode_<active/passive> metrics.

### Changed

- Update Docker Compose example files.

## Fixed

- Issue [#95](https://github.com/phsmith/rundeck_exporter/issues/95), improved and fixed the exporter helm chart.
- Issue [#98](https://github.com/phsmith/rundeck_exporter/issues/98), fixed exception errors when the user does not have the required permissions.

## [2.7.1] - 2024-05-30
### Added

Expand Down Expand Up @@ -284,7 +298,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- Initial release

[unreleased]: https://github.com/phsmith/rundeck_exporter/compare/v2.7.1...HEAD
[unreleased]: https://github.com/phsmith/rundeck_exporter/compare/v2.8.0...HEAD
[2.8.0]: https://github.com/phsmith/rundeck_exporter/compare/v2.7.1...v2.8.0
[2.7.1]: https://github.com/phsmith/rundeck_exporter/compare/v2.7.0...v2.7.1
[2.7.0]: https://github.com/phsmith/rundeck_exporter/compare/v2.6.5...v2.7.0
[2.6.5]: https://github.com/phsmith/rundeck_exporter/compare/v2.6.4...v2.6.5
Expand Down
30 changes: 15 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,20 +61,20 @@ The ACL associated with the token/user must have the following policy rules as a
Example ACL Policy allowing a user named "exporter" to get system metrics as well as execution metrics for any project:

```yaml
by:
username: exporter
description: system:read
for:
resource:
- allow:
- read
equals:
kind: system
context:
application: rundeck
by:
username: user
description: system:read
for:
resource:
- allow:
- read
equals:
kind: system
context:
application: rundeck
---
by:
username: exporter
username: user
description: project:read
for:
project:
Expand All @@ -86,7 +86,7 @@ context:
application: rundeck
---
by:
username: exporter
username: user
description: events:read
for:
resource:
Expand All @@ -102,7 +102,7 @@ context:
project: .*
---
by:
username: exporter
username: user
description: Allow [read] for node
for:
node:
Expand All @@ -115,7 +115,7 @@ context:

---
by:
username: exporter
username: user
description: Allow [read] for (All) node
for:
resource:
Expand Down
9 changes: 4 additions & 5 deletions charts/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ replicaCount: 1
image:
repository: phsmith/rundeck-exporter
pullPolicy: IfNotPresent
tag: 2.7.1
tag: 2.8.0

env:
RUNDECK_EXPORTER_DEBUG: true
RUNDECK_EXPORTER_HOST: 0.0.0.0
RUNDECK_EXPORTER_PORT: 9620
RUNDECK_URL: "your-rundeck-url"
RUNDECK_TOKEN: "your-rundeck-token"
RUNDECK_URL: "http://localhost:4440"
RUNDECK_TOKEN: "exporter_auth_token"
# RUNDECK_USERNAME: "your-rundeck-username"
# RUNDECK_USERPASSWORD: "your-rundeck-password"
RUNDECK_API_VERSION: 40
Expand Down Expand Up @@ -80,9 +80,8 @@ serviceMonitor:
enabled: true
# name: <defaults to rundeck-exporter-monitor>
# namespace: <defaults to helm release namespace>
interval: 30s

path: /
interval: 30s
scrapeTimeout: 10s

resources: {}
Expand Down
20 changes: 20 additions & 0 deletions docs/METRICS.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,3 +229,23 @@ rundeck_project_execution_status{execution_id="2016583",job_id="39156aa3-978d-43
rundeck_project_execution_status{execution_id="2016583",job_id="39156aa3-978d-43d3-a642-1fb217b5822f",job_name="rundeck_job",project_name="rundeck_project",status="aborted"} 0.0
rundeck_project_execution_status{execution_id="2016583",job_id="39156aa3-978d-43d3-a642-1fb217b5822f",job_name="rundeck_job",project_name="rundeck_project",status="unknown"} 0.0
```

## rundeck_execution_mode_active

Rundeck active execution mode status.

```
# HELP rundeck_execution_mode_active Rundeck Active Execution Mode Status
# TYPE rundeck_execution_mode_active gauge
rundeck_execution_mode_active{instance_address="rundeck:4440"} 1.0
```

## rundeck_execution_mode_passive

Rundeck passive execution mode status.

```
# HELP rundeck_execution_mode_passive Rundeck Passive Execution Mode Status
# TYPE rundeck_execution_mode_passive gauge
rundeck_execution_mode_passive{instance_address="rundeck:4440"} 0.0
```
64 changes: 64 additions & 0 deletions examples/docker-compose/configs/rundeck/etc/exporter.aclpolicy
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
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: .*
12 changes: 12 additions & 0 deletions examples/docker-compose/configs/rundeck/etc/realm.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#
# This file defines users passwords and roles for a HashUserRealm
#
# The format is
# <username>: <password>[,<rolename> ...]
#
# Passwords may be clear text, obfuscated or checksummed.
#
# This sets the default user accounts for the Rundeck apps
#
admin:admin,user,admin
exporter:exporter,user
2 changes: 2 additions & 0 deletions examples/docker-compose/configs/rundeck/etc/tokens.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
admin: exporter_admin_auth_token, admin
exporter: exporter_auth_token, user
14 changes: 10 additions & 4 deletions examples/docker-compose/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
version: "3"
services:
rundeck:
image: rundeck/rundeck:4.6.1
image: rundeck/rundeck:4.8.0
ports:
- 4440:4440
environment:
RUNDECK_GRAILS_URL: http://localhost:4440
RUNDECK_SERVER_ADDRESS: 0.0.0.0
RUNDECK_TOKENS_FILE: /home/rundeck/etc/tokens.properties
RUNDECK_METRICS_ENABLED: true
tty: true
volumes:
- ./data/rundeck:/home/rundeck/server/data
- ./configs/rundeck/remco/templates/rundeck-config.properties:/etc/remco/templates/rundeck-config.properties
- ./configs/rundeck/etc/exporter.aclpolicy:/home/rundeck/etc/exporter.aclpolicy
- ./configs/rundeck/etc/realm.properties:/home/rundeck/etc/realm.properties
- ./configs/rundeck/etc/tokens.properties:/home/rundeck/etc/tokens.properties
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:4440"]
interval: 30s
Expand All @@ -20,11 +25,11 @@ services:
ports:
- 9620:9620
environment:
RUNDECK_EXPORTER_DEBUG: "False"
RUNDECK_EXPORTER_DEBUG: "True"
RUNDECK_EXPORTER_HOST: 0.0.0.0
RUNDECK_EXPORTER_PORT: 9620
RUNDECK_URL: "http://rundeck:4440"
RUNDECK_TOKEN: "PLACE_RUNDECK_API_TOKEN_HERE"
RUNDECK_TOKEN: "exporter_auth_token"
RUNDECK_API_VERSION: 40
RUNDECK_SKIP_SSL: "False"
RUNDECK_PROJECTS_EXECUTIONS: "True"
Expand All @@ -33,6 +38,7 @@ services:
# RUNDECK_CACHED_REQUESTS_TTL: 120
RUNDECK_CPU_STATS: "True"
RUNDECK_MEMORY_STATS: "True"
RUNDECK_PROJECTS_NODES_INFO: "True"
depends_on:
rundeck:
condition: service_healthy
Expand Down
31 changes: 26 additions & 5 deletions rundeck_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
__author__ = 'Phillipe Smith'
__author_email__ = '[email protected]'
__app__ = 'rundeck_exporter'
__version__ = '2.7.1'
__version__ = '2.8.0'

# Disable InsecureRequestWarning
requests.urllib3.disable_warnings()
Expand Down Expand Up @@ -223,6 +223,7 @@ def request(self, endpoint: str) -> dict:
session.post(
f'{self.args.rundeck_url}/j_security_check',
data={"j_username": self.args.rundeck_username, "j_password": self.rundeck_userpassword},
allow_redirects=True,
verify=not self.args.rundeck_skip_ssl
)

Expand Down Expand Up @@ -443,6 +444,7 @@ def collect(self):
"""
Rundeck system info
"""
metrics = self.request('/metrics/metrics')
system_info = self.request('/system/info')
api_version = int(system_info['system']['rundeck']['apiversion'])
execution_mode = system_info['system'].get('executions', {}).get('executionMode')
Expand All @@ -453,12 +455,33 @@ def collect(self):
)
rundeck_system_info.add_metric(self.default_labels_values, {x: str(y) for x, y in system_info['system']['rundeck'].items()})

"""
Rundeck server execution mode
"""
logging.debug(f'Rundeck execution mode: {execution_mode}.')

if self.args.no_checks_in_passive_mode and execution_mode == 'passive':
return
rundeck_execution_mode_active = GaugeMetricFamily(
'rundeck_execution_mode_active',
f'Rundeck Active Execution Mode Status',
labels=self.default_labels
)

rundeck_execution_mode_passive = GaugeMetricFamily(
'rundeck_execution_mode_passive',
f'Rundeck Passive Execution Mode Status',
labels=self.default_labels
)

if execution_mode == 'passive':
rundeck_execution_mode_active.add_metric(self.default_labels_values, 0)
rundeck_execution_mode_passive.add_metric(self.default_labels_values, 1)
else:
rundeck_execution_mode_active.add_metric(self.default_labels_values, 1)
rundeck_execution_mode_passive.add_metric(self.default_labels_values, 0)

yield rundeck_system_info
yield rundeck_execution_mode_active
yield rundeck_execution_mode_passive

"""
Rundeck system stats
Expand All @@ -477,8 +500,6 @@ def collect(self):
+ ' Some metrics like rundeck_scheduler_quartz_* will not be available.'
+ ' Use Username and Password options to get the metrics.')
else:
metrics = self.request('/metrics/metrics')

for counters in self.get_counters(metrics):
yield counters

Expand Down

0 comments on commit 8ce4a72

Please sign in to comment.