Skip to content

Commit

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

## Changelog
`2.2.4`:
* Fix issue Regarding execution status #11 - Modified GaugeMetricFamily location in the function get_project_executions

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

Expand Down
42 changes: 21 additions & 21 deletions rundeck_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,34 +145,34 @@ def get_project_executions(self, project: dict):
else:
project_executions = self.request_data_from(endpoint)

duration_metrics = GaugeMetricFamily(
'rundeck_project_execution_duration_seconds',
f'Rundeck Project {project_name} Execution Duration',
labels=['project_name', 'job_id', 'job_name']
)

start_metrics = GaugeMetricFamily(
'rundeck_project_start_timestamp',
f'Rundeck Project {project_name} Start Timestamp',
labels=['project_name', 'job_id', 'job_name']
)

metrics = GaugeMetricFamily(
'rundeck_project_execution_status',
f'Rundeck Project {project_name} Execution Status',
labels=['project_name', 'job_id', 'job_name', 'status']
)

for project_execution in project_executions['executions']:
job_info = project_execution.get('job', {})
job_id = job_info.get('id', 'None')
job_name = job_info.get('name', 'None')

if not project_executions or job_id in jobs_list:
if job_id in jobs_list:
continue

jobs_list.append(job_id)

start_metrics = GaugeMetricFamily(
'rundeck_project_start_timestamp',
f'Rundeck Project {project_name} Start Timestamp',
labels=['project_name', 'job_id', 'job_name']
)

duration_metrics = GaugeMetricFamily(
'rundeck_project_execution_duration_seconds',
f'Rundeck Project {project_name} Execution Duration',
labels=['project_name', 'job_id', 'job_name']
)

metrics = GaugeMetricFamily(
'rundeck_project_execution_status',
f'Rundeck Project {project_name} Execution Status',
labels=['project_name', 'job_id', 'job_name', 'status']
)

# Job start/end times
job_start_time = project_execution.get('date-started', {}).get('unixtime', 0)
job_end_time = project_execution.get('date-ended', {}).get('unixtime', 0)
Expand Down Expand Up @@ -215,7 +215,7 @@ def get_project_executions(self, project: dict):
value
)

project_executions_status.append(metrics)
project_executions_status.append(metrics)
except Exception: # nosec
pass

Expand Down Expand Up @@ -348,7 +348,7 @@ def collect(self):
for executions in project_executions:
for execution in executions:
if execution is not None:
yield(execution)
yield execution

@staticmethod
def exit_with_msg(msg: str, level: str):
Expand Down

0 comments on commit 55fc3e1

Please sign in to comment.