Skip to content

Commit

Permalink
fix(#108): add timestamp to project executions metrics (#109)
Browse files Browse the repository at this point in the history
* chore: update requirements.txt

* docs: update CHANGELOG.md

* fix(#108): add timestamp to project_executions metrics
  • Loading branch information
phsmith authored Jan 13, 2025
1 parent dbecf8b commit 49d7e05
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [2.8.4] - 2025-01-13
### Changed

- Bump chart version (`0.3.1`)
Expand All @@ -15,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Helm chart error when using `serviceMonitor.name` (formatting error)
- Remove default `RUNDECK_TOKEN` env variable (default value overrules value from secret if set)
- Issue [#108](https://github.com/phsmith/rundeck_exporter/issues/108), fix Prometheus duplicate metrics error report when `rundeck.projects.executions.cache` option is enabled.

## [2.8.3] - 2024-10-16
### Fixed
Expand Down Expand Up @@ -322,7 +324,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- Initial release

[unreleased]: https://github.com/phsmith/rundeck_exporter/compare/v2.8.3...HEAD
[unreleased]: https://github.com/phsmith/rundeck_exporter/compare/v2.8.4...HEAD
[2.8.4]: https://github.com/phsmith/rundeck_exporter/compare/v2.8.3...v2.8.4
[2.8.3]: https://github.com/phsmith/rundeck_exporter/compare/v2.8.2...v2.8.3
[2.8.2]: https://github.com/phsmith/rundeck_exporter/compare/v2.8.1...v2.8.2
[2.8.1]: https://github.com/phsmith/rundeck_exporter/compare/v2.8.0...v2.8.1
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
cachetools==5.3.3
prometheus-client==0.20.0
cachetools==5.5.0
prometheus-client==0.21.1
requests==2.32.3
12 changes: 7 additions & 5 deletions rundeck_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
__author__ = 'Phillipe Smith'
__author_email__ = '[email protected]'
__app__ = 'rundeck_exporter'
__version__ = '2.8.3'
__version__ = '2.8.4'

# Disable InsecureRequestWarning
requests.urllib3.disable_warnings()
Expand Down Expand Up @@ -527,6 +527,7 @@ def collect(self):

with ThreadPoolExecutor(thread_name_prefix='project_executions', max_workers=self.args.threadpool_max_workers) as project_executions_threadpool:
project_execution_records = project_executions_threadpool.map(self.get_project_executions, projects)
timestamp = datetime.now().timestamp()

default_labels = self.default_labels + [
'project_name',
Expand Down Expand Up @@ -565,15 +566,16 @@ def collect(self):
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']
project_executions_total['total_executions'],
timestamp=timestamp
)
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)
project_start_metrics.add_metric(project_execution_record.tags, project_execution_record.value, timestamp=timestamp)
elif project_execution_record.execution_type == RundeckProjectExecution.DURATION:
project_duration_metrics.add_metric(project_execution_record.tags, project_execution_record.value)
project_duration_metrics.add_metric(project_execution_record.tags, project_execution_record.value, timestamp=timestamp)
elif project_execution_record.execution_type == RundeckProjectExecution.STATUS:
project_metrics.add_metric(project_execution_record.tags, project_execution_record.value)
project_metrics.add_metric(project_execution_record.tags, project_execution_record.value, timestamp=timestamp)

yield project_start_metrics
yield project_duration_metrics
Expand Down

0 comments on commit 49d7e05

Please sign in to comment.