Skip to content

Commit

Permalink
Fix GaugeMetricFamily definition location on method get_project_execu…
Browse files Browse the repository at this point in the history
…tions
  • Loading branch information
phsmith committed Jan 5, 2021
1 parent f924b99 commit a7f98e7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 34 deletions.
19 changes: 3 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,35 +166,19 @@ 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
rundeck_project_execution_duration_seconds{job_id="oracle_client_install",job_name="Oracle Client Install",project_name="oracle_client_install"} 20000.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="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
....
```
Expand Down Expand Up @@ -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
37 changes: 19 additions & 18 deletions rundeck_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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
Expand Down

0 comments on commit a7f98e7

Please sign in to comment.