Skip to content

Commit

Permalink
Fix project_executions_total not accessible (#91)
Browse files Browse the repository at this point in the history
* docs: update CHANGELOG.md

* fix: project_executions_total var definition and metric value
  • Loading branch information
phsmith authored Apr 20, 2024
1 parent bb5498e commit 4186fde
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
- Changed the functions `request_data_from` and `cached_request_data_from` to `request` and `cached_request`, respectively.

### Fixed
- Issue [#89](https://github.com/phsmith/rundeck_exporter/issues/89), correctly started the `project_executions_total` variable and also fixed the metric return.

## [2.6.5] - 2024-03-11
### Added
- Issue [#85](https://github.com/phsmith/rundeck_exporter/issues/85), added new metric `rundeck_project_nodes_total`.
Expand Down
27 changes: 14 additions & 13 deletions rundeck_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,23 +264,24 @@ def get_project_executions(self, project: dict):
project_execution_records = list()
project_executions_limit = self.args.rundeck_projects_executions_limit
project_executions_filter = self.args.rundeck_project_executions_filter
endpoint = f'/project/{project_name}/executions?recentFilter={project_executions_filter}&max={project_executions_limit}'
endpoint_running_executions = f'/project/{project_name}/executions/running?max={project_executions_limit}'
project_executions_total = {'project': project_name, 'total_executions': 0}
endpoint_executions = f'/project/{project_name}/executions?recentFilter={project_executions_filter}&max={project_executions_limit}'
endpoint_executions_running = f'/project/{project_name}/executions/running?max={project_executions_limit}'
endpoint_executions_metrics = f'/project/{project_name}/executions/metrics?recentFilter=1d'

try:
if self.args.rundeck_projects_executions_cache:
project_executions_running_info = self.cached_request(endpoint_running_executions)
project_executions_info = self.cached_request(endpoint)
project_executions_running_info = self.cached_request(endpoint_executions_running)
project_executions_info = self.cached_request(endpoint_executions)
project_executions_total_info = self.cached_request(endpoint_executions_metrics)
else:
project_executions_running_info = self.request(endpoint_running_executions)
project_executions_info = self.request(endpoint)

project_executions_total = {
'project': project_name,
'total_executions': project_executions_info['paging']['total']
}
project_executions = (project_executions_running_info.get('executions', [])
+ project_executions_info.get('executions', []))
project_executions_running_info = self.request(endpoint_executions_running)
project_executions_info = self.request(endpoint_executions)
project_executions_total_info = self.request(endpoint_executions_metrics)

project_executions_running_info_list = project_executions_running_info.get('executions', [])
project_executions_total['total_executions'] = project_executions_total_info['total'] + len(project_executions_running_info_list)
project_executions = (project_executions_running_info_list + project_executions_info.get('executions', []))

for project_execution in project_executions:
job_info = project_execution.get('job', {})
Expand Down

0 comments on commit 4186fde

Please sign in to comment.