{"id":26116969,"url":"https://github.com/meysam81/prometheus-command-timer","last_synced_at":"2026-04-17T07:32:06.359Z","repository":{"id":279020329,"uuid":"937491243","full_name":"meysam81/prometheus-command-timer","owner":"meysam81","description":"Run any command, time its execution and push the metrics to Prometheus Pushgateway","archived":false,"fork":false,"pushed_at":"2026-04-13T18:05:27.000Z","size":124,"stargazers_count":5,"open_issues_count":2,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-04-13T20:06:52.948Z","etag":null,"topics":["cli-tool","command-line","command-wrapper","container-metrics","cross-platform","devops","docker","execution-time","golang","job-monitoring","kubernetes","metrics","metrics-collector","monitoring","observability","performance-monitoring","prometheus","pushgateway","sre","time-tracking"],"latest_commit_sha":null,"homepage":"https://developer-friendly.blog/blog/2025/03/03/3-ways-to-time-kubernetes-job-duration-for-better-devops/","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/meysam81.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-02-23T07:17:15.000Z","updated_at":"2026-02-06T06:54:54.000Z","dependencies_parsed_at":"2025-03-17T18:43:14.179Z","dependency_job_id":"cf2f7197-e390-4c2a-8dc2-201f0999d556","html_url":"https://github.com/meysam81/prometheus-command-timer","commit_stats":null,"previous_names":["meysam81/prometheus-command-timer"],"tags_count":22,"template":false,"template_full_name":null,"purl":"pkg:github/meysam81/prometheus-command-timer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meysam81%2Fprometheus-command-timer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meysam81%2Fprometheus-command-timer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meysam81%2Fprometheus-command-timer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meysam81%2Fprometheus-command-timer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/meysam81","download_url":"https://codeload.github.com/meysam81/prometheus-command-timer/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meysam81%2Fprometheus-command-timer/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31919943,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-16T18:22:33.417Z","status":"online","status_checked_at":"2026-04-17T02:00:06.879Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli-tool","command-line","command-wrapper","container-metrics","cross-platform","devops","docker","execution-time","golang","job-monitoring","kubernetes","metrics","metrics-collector","monitoring","observability","performance-monitoring","prometheus","pushgateway","sre","time-tracking"],"created_at":"2025-03-10T10:53:27.092Z","updated_at":"2026-04-17T07:32:06.350Z","avatar_url":"https://github.com/meysam81.png","language":"Go","readme":"# Prometheus Command Timer\n\n[![Renovate](https://img.shields.io/badge/renovate-enabled-brightgreen.svg)](https://developer.mend.io/github/meysam81/prometheus-command-timer)\n[![GitHub Tag](https://img.shields.io/github/v/tag/meysam81/prometheus-command-timer)](https://github.com/meysam81/prometheus-command-timer)\n[![Stars](https://img.shields.io/github/stars/meysam81/prometheus-command-timer?label=GitHub%20stars\u0026style=flat)](https://github.com/meysam81/prometheus-command-timer/stargazers)\n[![GitHub top language](https://img.shields.io/github/languages/top/meysam81/prometheus-command-timer)](https://github.com/meysam81/prometheus-command-timer)\n[![GitHub go.mod Go version](https://img.shields.io/github/go-mod/go-version/meysam81/prometheus-command-timer)](https://github.com/meysam81/prometheus-command-timer)\n[![Open Issues](https://img.shields.io/github/issues-raw/meysam81/prometheus-command-timer)](https://github.com/meysam81/prometheus-command-timer/issues)\n[![Open PRs](https://img.shields.io/github/issues-pr-raw/meysam81/prometheus-command-timer)](https://github.com/meysam81/prometheus-command-timer/pulls)\n[![Contributors](https://img.shields.io/github/contributors/meysam81/prometheus-command-timer)](https://github.com/meysam81/prometheus-command-timer/graphs/contributors)\n[![Repo Size](https://img.shields.io/github/repo-size/meysam81/prometheus-command-timer)](https://github.com/meysam81/prometheus-command-timer/)\n[![Code Size](https://img.shields.io/github/languages/code-size/meysam81/prometheus-command-timer)](https://github.com/meysam81/prometheus-command-timer/)\n[![License](https://img.shields.io/github/license/meysam81/prometheus-command-timer)](./LICENSE)\n\n\u003c!-- START doctoc generated TOC please keep comment here to allow auto update --\u003e\n\u003c!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --\u003e\n\n- [Overview](#overview)\n- [Features](#features)\n- [Installation](#installation)\n  - [Using the Docker Image](#using-the-docker-image)\n  - [Direct Download](#direct-download)\n  - [Manual Installation](#manual-installation)\n- [Quick Start](#quick-start)\n- [Kubernetes Example](#kubernetes-example)\n- [Usage](#usage)\n- [Metrics](#metrics)\n- [Building from Source](#building-from-source)\n- [Contributing](#contributing)\n- [License](#license)\n- [Author](#author)\n- [Acknowledgments](#acknowledgments)\n\n\u003c!-- END doctoc generated TOC please keep comment here to allow auto update --\u003e\n\nA utility that executes commands and reports execution metrics to a Prometheus\nPushgateway.\n\n## Overview\n\nPrometheus Command Timer is a lightweight tool that wraps around command\nexecution to collect and send performance metrics to a Prometheus Pushgateway.\n\nIt measures execution time, tracks exit status, and records timestamps, making\nit ideal for monitoring batch jobs, cron tasks, and other command-line\noperations in a Kubernetes environment.\n\n## Features\n\n- Measures command execution duration\n- Records command exit status\n- Tracks execution timestamps\n- Sends metrics to Prometheus Pushgateway\n- Supports custom labels for metrics\n- Works on Linux, macOS, and Windows\n- Architecture support for x86_64, arm64, and i386\n\n## Installation\n\n### Using the Docker Image\n\n```bash\ndocker run --rm -v \\\n  $(pwd):/cwd ghcr.io/meysam81/prometheus-command-timer \\\n  -d /cwd\n```\n\n### Direct Download\n\nThe script will automatically detect your OS and architecture:\n\n```bash\ncurl -sL https://raw.githubusercontent.com/meysam81/prometheus-command-timer/main/install.sh | sh\n./prometheus-command-timer -version\n```\n\n### Manual Installation\n\n1. Download the appropriate binary for your platform from the [releases page].\n2. Extract the archive\n3. Place the binary in your `$PATH`\n\n## Quick Start\n\nBasic usage:\n\n```bash\nprometheus-command-timer \\\n  --pushgateway-url http://pushgateway:9091 \\\n  --job-name backup \\\n  -- \\\n  pg_dump database\n```\n\n## Kubernetes Example\n\nCreate a job that runs a command with timing metrics:\n\n```yaml\napiVersion: batch/v1\nkind: Job\nmetadata:\n  name: sleep\nspec:\n  template:\n    spec:\n      containers:\n        - args:\n            - |\n              sleep 10\n          command:\n            - prometheus-command-timer\n            - --pushgateway-url=http://pushgateway.monitoring.svc.cluster.local:9091\n            - --job-name=sleep\n            - \"--\"\n          image: busybox:1\n          name: sleep\n          volumeMounts:\n            - mountPath: /usr/local/bin/prometheus-command-timer\n              name: tmp\n              subPath: prometheus-command-timer\n      initContainers:\n        - args:\n            - -d\n            - /tmp\n          image: ghcr.io/meysam81/prometheus-command-timer\n          name: install-prometheus-command-timer\n          securityContext:\n            allowPrivilegeEscalation: false\n            capabilities:\n              drop:\n                - ALL\n            readOnlyRootFilesystem: true\n            runAsGroup: 65534\n            runAsNonRoot: true\n            runAsUser: 65534\n          volumeMounts:\n            - mountPath: /tmp\n              name: tmp\n      restartPolicy: OnFailure\n      volumes:\n        - emptyDir: {}\n          name: tmp\n```\n\n## Usage\n\n```\nUsage: prometheus-command-timer [OPTIONS] -- COMMAND [ARGS...]\n\nExecutes a command and reports its duration to a Prometheus Pushgateway.\n\nOptions:\n  -pushgateway-url string\n        Pushgateway URL (required)\n  -job-name string\n        Job name for metrics (required)\n  -instance-name string\n        Instance name for metrics (default: hostname)\n  -labels string\n        Additional labels in key=value format, comma-separated (e.g., env=prod,team=infra)\n  -version\n        Output version\n  -help, -h\n        Show help message\n\nExample:\n    prometheus-command-timer \\\n        --pushgateway-url http://pushgateway:9091 \\\n        --job-name backup --instance-name db01 \\\n        --labels env=prod,team=infra,type=full \\\n        -- \\\n        pg_dump database\n\nNote: Use -- to separate the wrapper options from the command to be executed.\n```\n\n## Metrics\n\nThe following metrics are collected:\n\n- `job_duration_seconds` - Total time taken for job execution in seconds\n- `job_exit_status` - Exit status code of the last job execution (0=success)\n- `job_last_execution_timestamp` - Timestamp of the last job execution\n- `job_executions_total` - Total number of job executions\n\n## Building from Source\n\n```bash\ngit clone https://github.com/meysam81/prometheus-command-timer.git\ncd prometheus-command-timer\ngo build -o prometheus-command-timer\n```\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n## License\n\nThis project is licensed under the Apache License 2.0 - see the\n[LICENSE](LICENSE) file for details.\n\n[releases page]: https://github.com/meysam81/prometheus-command-timer/releases\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmeysam81%2Fprometheus-command-timer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmeysam81%2Fprometheus-command-timer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmeysam81%2Fprometheus-command-timer/lists"}