Skip to content

Commit

Permalink
Fix issue invalid API request #10
Browse files Browse the repository at this point in the history
  • Loading branch information
phsmith committed Feb 26, 2021
1 parent 8accf1b commit 8b45da4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ docker run --rm -d -p 9620:9620 -e RUNDECK_TOKEN=$RUNDECK_TOKEN rundeck_exporter
```

## Changelog
`2.2.3`:
* Fix issue invalid API request #10 - Added warning message for API version < 25

`2.2.2`:
* Fix GaugeMetricFamily definition location on method get_project_executions to correctly shows the HELP/TYPE
Expand Down
16 changes: 11 additions & 5 deletions rundeck_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,12 +300,11 @@ def get_counters(self, metrics: dict):
Method to collect Rundeck metrics
"""
def collect(self):
metrics = self.request_data_from('/metrics/metrics')
system_info = self.request_data_from('/system/info')

"""
Rundeck system info
"""
system_info = self.request_data_from('/system/info')
api_version = system_info['system']['rundeck']['apiversion']
rundeck_system_info = InfoMetricFamily('rundeck_system', 'Rundeck system info')
rundeck_system_info.add_metric([], {x: str(y) for x, y in system_info['system']['rundeck'].items()})
yield rundeck_system_info
Expand All @@ -319,8 +318,15 @@ def collect(self):
"""
Rundeck counters
"""
for counters in self.get_counters(metrics):
yield counters
if api_version >= self.args.rundeck_api_version < 25:
logging.warning(f'Unsupported API version "{self.args.rundeck_api_version}" '
+ f'for API request: /api/{self.args.rundeck_api_version}/metrics/metrics. '
+ 'Minimum supported version is 25')
else:
metrics = self.request_data_from('/metrics/metrics')

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

"""
Rundeck projects executions info
Expand Down

0 comments on commit 8b45da4

Please sign in to comment.