diff --git a/README.md b/README.md index 5355eb1..7af63c2 100644 --- a/README.md +++ b/README.md @@ -166,17 +166,9 @@ rundeck_project_execution_duration_seconds{job_id="servcom_install",job_name="Se # HELP rundeck_project_execution_status Rundeck Project servcom_install Execution Status # TYPE rundeck_project_execution_status gauge rundeck_project_execution_status{job_id="servcom_install",job_name="Servcom Client",project_name="servcom_install",status="succeeded"} 1.0 -# HELP rundeck_project_execution_status Rundeck Project servcom_install Execution Status -# TYPE rundeck_project_execution_status gauge rundeck_project_execution_status{job_id="servcom_install",job_name="Servcom Client",project_name="servcom_install",status="running"} 0.0 -# HELP rundeck_project_execution_status Rundeck Project servcom_install Execution Status -# TYPE rundeck_project_execution_status gauge rundeck_project_execution_status{job_id="servcom_install",job_name="Servcom Client",project_name="servcom_install",status="failed"} 0.0 -# HELP rundeck_project_execution_status Rundeck Project servcom_install Execution Status -# TYPE rundeck_project_execution_status gauge rundeck_project_execution_status{job_id="servcom_install",job_name="Servcom Client",project_name="servcom_install",status="aborted"} 0.0 -# HELP rundeck_project_execution_status Rundeck Project servcom_install Execution Status -# TYPE rundeck_project_execution_status gauge rundeck_project_execution_status{job_id="servcom_install",job_name="Servcom Client",project_name="servcom_install",status="unknown"} 0.0 # HELP rundeck_project_execution_status Rundeck Project oracle_client_install Execution Druation # TYPE rundeck_project_execution_duration_seconds gauge @@ -184,17 +176,9 @@ rundeck_project_execution_duration_seconds{job_id="oracle_client_install",job_na # HELP rundeck_project_execution_status Rundeck Project oracle_client_install Execution Status # TYPE rundeck_project_execution_status gauge rundeck_project_execution_status{job_id="oracle_client_install",job_name="Oracle Client Install",project_name="oracle_client_install",status="succeeded"} 1.0 -# HELP rundeck_project_execution_status Rundeck Project oracle_client_install Execution Status -# TYPE rundeck_project_execution_status gauge rundeck_project_execution_status{job_id="oracle_client_install",job_name="Oracle Client Install",project_name="oracle_client_install",status="running"} 0.0 -# HELP rundeck_project_execution_status Rundeck Project oracle_client_install Execution Status -# TYPE rundeck_project_execution_status gauge rundeck_project_execution_status{job_id="oracle_client_install",job_name="Oracle Client Install",project_name="oracle_client_install",status="failed"} 0.0 -# HELP rundeck_project_execution_status Rundeck Project oracle_client_install Execution Status -# TYPE rundeck_project_execution_status gauge rundeck_project_execution_status{job_id="oracle_client_install",job_name="Oracle Client Install",project_name="oracle_client_install",status="aborted"} 0.0 -# HELP rundeck_project_execution_status Rundeck Project oracle_client_install Execution Status -# TYPE rundeck_project_execution_status gauge rundeck_project_execution_status{job_id="oracle_client_install",job_name="Oracle Client Install",project_name="oracle_client_install",status="unknown"} 0.0 .... ``` @@ -256,3 +240,6 @@ docker run --rm -d -p 9620:9620 -e RUNDECK_TOKEN=$RUNDECK_TOKEN rundeck_exporter `2.2.1`: * Fix exception messages on failed Rundeck api requests + +`2.2.2`: +* Fix GaugeMetricFamily definition location on method get_project_executions to correctly shows the HELP/TYPE diff --git a/rundeck_exporter.py b/rundeck_exporter.py index 02f7c44..39bcfa7 100755 --- a/rundeck_exporter.py +++ b/rundeck_exporter.py @@ -145,6 +145,24 @@ 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') @@ -160,11 +178,6 @@ def get_project_executions(self, project: dict): job_end_time = project_execution.get('date-ended', {}).get('unixtime', 0) job_execution_duration = (job_end_time - job_start_time) - start_metrics = GaugeMetricFamily( - 'rundeck_project_start_timestamp', - f'Rundeck Project {project_name} Start Timestamp', - labels=['project_name', 'job_id', 'job_name'] - ) start_metrics.add_metric( [ project_name, @@ -175,12 +188,6 @@ def get_project_executions(self, project: dict): ) project_executions_status.append(start_metrics) - duration_metrics = GaugeMetricFamily( - 'rundeck_project_execution_duration_seconds', - f'Rundeck Project {project_name} Execution Duration', - labels=['project_name', 'job_id', 'job_name'] - ) - duration_metrics.add_metric( [ project_name, @@ -198,12 +205,6 @@ def get_project_executions(self, project: dict): if project_execution.get('status', 'unknown') == status: value = 1 - metrics = GaugeMetricFamily( - 'rundeck_project_execution_status', - f'Rundeck Project {project_name} Execution Status', - labels=['project_name', 'job_id', 'job_name', 'status'] - ) - metrics.add_metric( [ project_name, @@ -215,7 +216,7 @@ def get_project_executions(self, project: dict): ) project_executions_status.append(metrics) - except: + except Exception: # nosec pass return project_executions_status