diff --git a/CHANGELOG.md b/CHANGELOG.md index f40f3c4..b6986dd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [2.5.0] - 2022-09-29 + +### Added +- Added new metric rundeck_project_executions_total + +### Fixed +- Fixed issue #59, unable to pass the RUNDECK_PROJECTS_FILTER environment variables + ## [2.4.14] - 2022-07-21 ### Added diff --git a/README.md b/README.md index 2af0068..6718b90 100644 --- a/README.md +++ b/README.md @@ -390,6 +390,10 @@ Optionally, it's possible to pass the following environment variables to the run rundeck_project_execution_status{execution_id="7375",execution_type="scheduled",instance_address="localhost:4440",job_group="",job_id="3fcc1617-74d4-422b-b7cf-bd3123b3f97c",job_name="Fail after 60s",project_name="Test",status="failed",user="admin"} 1.0 rundeck_project_execution_status{execution_id="7375",execution_type="scheduled",instance_address="localhost:4440",job_group="",job_id="3fcc1617-74d4-422b-b7cf-bd3123b3f97c",job_name="Fail after 60s",project_name="Test",status="aborted",user="admin"} 0.0 rundeck_project_execution_status{execution_id="7375",execution_type="scheduled",instance_address="localhost:4440",job_group="",job_id="3fcc1617-74d4-422b-b7cf-bd3123b3f97c",job_name="Fail after 60s",project_name="Test",status="unknown",user="admin"} 0.0 + # HELP rundeck_project_executions_total Rundeck Project ProjectName Total Executions + # TYPE rundeck_project_executions_total counter + rundeck_project_executions_total{instance_address="localhost:4440",project_name="Test"} 300.0 + ``` diff --git a/rundeck_exporter.py b/rundeck_exporter.py index b8ae2df..ebc7b42 100755 --- a/rundeck_exporter.py +++ b/rundeck_exporter.py @@ -26,7 +26,7 @@ __author__ = 'Phillipe Smith' __author_email__ = 'phsmithcc@gmail.com' __app__ = 'rundeck_exporter' -__version__ = '2.4.13' +__version__ = '2.5.0' # Disable InsecureRequestWarning requests.urllib3.disable_warnings() @@ -237,6 +237,10 @@ def get_project_executions(self, project: dict): project_executions_running_info = self.request_data_from(endpoint_running_executions) project_executions_info = self.request_data_from(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', [])) @@ -279,10 +283,10 @@ def get_project_executions(self, project: dict): RundeckProjectExecutionRecord(default_metrics + [status], value, RundeckProjectExecution.STATUS) ) - except Exception: # nosec - pass + except Exception as error: # nosec + logging.error(error) - return project_execution_records + return project_execution_records, project_executions_total """ @@ -468,7 +472,17 @@ def collect(self): labels=default_labels + ['status'] ) - for project_execution_record_group in project_execution_records: + project_executions_total_metrics = CounterMetricFamily( + 'rundeck_project_executions_total', + f'Rundeck Project ProjectName Total Executions', + labels=self.default_labels + ['project_name'] + ) + + for project_execution_record_group, project_executions_total in project_execution_records: + project_executions_total_metrics.add_metric( + self.default_labels_values + [project_executions_total['project']], + project_executions_total['total_executions'] + ) for project_execution_record in project_execution_record_group: if project_execution_record.execution_type == RundeckProjectExecution.START: project_start_metrics.add_metric(project_execution_record.tags, project_execution_record.value) @@ -480,6 +494,7 @@ def collect(self): yield project_start_metrics yield project_duration_metrics yield project_metrics + yield project_executions_total_metrics @staticmethod def exit_with_msg(msg: str, level: str):