{"id":34146849,"url":"https://github.com/kyronio/ci-templates-metrics","last_synced_at":"2026-03-11T12:49:29.709Z","repository":{"id":175265804,"uuid":"653544243","full_name":"kyronio/ci-templates-metrics","owner":"kyronio","description":"Prometheus metrics for your custom CI","archived":false,"fork":false,"pushed_at":"2023-06-18T11:05:01.000Z","size":1103,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-14T13:17:55.029Z","etag":null,"topics":["ci","continous-integration","devops","prom","prometheus"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kyronio.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}},"created_at":"2023-06-14T08:57:21.000Z","updated_at":"2023-09-17T04:01:00.000Z","dependencies_parsed_at":"2024-01-22T04:07:23.403Z","dependency_job_id":null,"html_url":"https://github.com/kyronio/ci-templates-metrics","commit_stats":null,"previous_names":["zigelboim-misha/ci-templates-metrics-receiver","kyronio/ci-templates-metrics","zigelboim-misha/ci-templates-metrics"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/kyronio/ci-templates-metrics","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kyronio%2Fci-templates-metrics","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kyronio%2Fci-templates-metrics/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kyronio%2Fci-templates-metrics/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kyronio%2Fci-templates-metrics/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kyronio","download_url":"https://codeload.github.com/kyronio/ci-templates-metrics/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kyronio%2Fci-templates-metrics/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30381733,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-11T06:09:32.197Z","status":"ssl_error","status_checked_at":"2026-03-11T06:09:17.086Z","response_time":84,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["ci","continous-integration","devops","prom","prometheus"],"created_at":"2025-12-15T04:11:53.861Z","updated_at":"2026-03-11T12:49:29.701Z","avatar_url":"https://github.com/kyronio.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CI Jobs Metrics\n\nThere was a need to export metrics about the usage of our CI templates for KPI. This µservice will help us understand the state of our CI templates and where can it be improved.\n\nOne way this can be achieved is by exporting Prometheus metrics and create a KPI dashboard that will show the overall usage of our CI templates.\n\n## Final Result\n\nOur final ci templates KPI dashboard looks like this:\n\n![KPI dashboard gif](/docs/images/kpi-example.gif)\n\n## Metrics Example\n\nRegistering a new CI job will result in the following metrics:\n\n```prometheus\n# HELP ci_dotnet_build_total The number of dotnet build used\n# TYPE ci_dotnet_build_total counter\nci_dotnet_build_total{project=\"dummy-project\",status=\"success\"} 3\nci_dotnet_build_total{project=\"dummy-project2\",status=\"success\"} 5\nci_dotnet_build_total{project=\"dummy-project2\",status=\"failed\"} 12\nci_dotnet_build_total{project=\"dummy-project3\",status=\"success\"} 8\n\n# HELP ci_helm_restore_duration The duration of the helm restore usage\n# TYPE ci_helm_restore_duration histogram\nci_helm_restore_duration_bucket{status=\"success\",le=\"60\"} 60\nci_helm_restore_duration_bucket{status=\"success\",le=\"120\"} 67\nci_helm_restore_duration_bucket{status=\"success\",le=\"300\"} 68\nci_helm_restore_duration_bucket{status=\"success\",le=\"600\"} 72\nci_helm_restore_duration_bucket{status=\"success\",le=\"900\"} 74\nci_helm_restore_duration_bucket{status=\"success\",le=\"1200\"} 75\nci_helm_restore_duration_bucket{status=\"success\",le=\"+Inf\"} 76\nci_helm_restore_duration_sum_{status=\"success\"} 7005.646230537002\n```\n\n## How Does It Work\n\n1. User runs a CI job\n\n1. Jobs scripts are completed\n\n1. `after_scripts` saves the metrics into a `.json` file in the mounted volume\n\n1. Sidecar reads the `.json` file and sends it to the `Receiver µservice`\n\n1. The `Receiver µservice` increases the correct `metrics` of the complete job\n\n## Receiver\n\nThis µservice receives `HTTP` requests and increases the requested metrics.\n\n```cmd\ndocker run -p 80:80 \u003cimage-name\u003e receiver\n```\n\n### Receiving Metrics\n\nThis µservice waits for `HTTP` requests to register metrics:\n\n```cmd\ncurl -G -d started=2023-05-23T13:01:00Z -d status=failed -d project=dummy-project -d name=dotnet_build http://localhost:80/jobs\n```\n\nThis will register the new CI job (if it's the first time its used) and increase it accordingly.\n\n## Exporter\n\nThis µservice runs a sidecar to the `build` and `helper` containers and shares their volume mount.\n\n```sh\nexporter \u003cfile-path\u003e \u003creceiver-hostname\u003e\n```\n\nAt the end of each CI job, there is an `after_script` that echos some variables into a `.json` file:\n\n```sh\nafter_script:\n  - mkdir -p /builds/.metrics\n  - echo '{\"started\":\"'\"$CI_JOB_STARTED_AT\"'\",\"status\":\"'\"CI_JOB_STATUS\"'\",\"project\":\"'\"CI_PROJECT_PATH\"'\",\"name\":\"'\"$CI_JOB_NAME\"'\"}' \u003e /builds/.metrics/metrics.json\n```\n\nThe `Exporter` µservice will wait for this file and then send it to the [Receiver](/README.md/#receiver) µservice which will export the metrics.\n\n## See Yourself\n\n### Run the Receiver\n\nFirst make sure your [Receiver](/README.md/#receiver) is up and running.\n\n### Simulate CI Jobs\n\nNow we mimic a CI jobs usage scenario by running the [curl.bash](/docs/curl.sh) file which will mimic 5 minutes of `dotnet` CI usage.\n\n- Please make sure to override the `starting-time` value! Or all the jobs will arrive with an infinite duration.\n\n### Prometheus\n\nCollect the metrics using a [Prometheus](https://prometheus.io/) instance:\n\n![Prometheus Query](/docs/images/prometheus-dotnet-build-example.PNG)\n\nOr run a new instance using:\n\n```cmd\ndocker run -p 9090:9090 -v path\\to\\prometheus.yml:/etc/prometheus/prometheus.yml prom/prometheus\n```\n\n### Grafana\n\nNext step is to connect your [Prometheus](https://prometheus.io/) instance to your [Grafana](https://grafana.com/) and create a [dashboard](/dashboards/ci-jobs-status.json):\n\n![Grafana Dashboard](/docs/images/grafana-dotnet-restore-example.PNG)\n\nOr run a new Grafana instance by:\n\n```cmd\ndocker run -d --name=grafana -p 3000:3000 grafana/grafana\n```\n\n#### General Section\n\nGeneral information about the usage generally.\n\n![general row](/docs/images/general-section.PNG)\n\n#### Per Job Section\n\nInformation about each CI job.\n\n![per job](/docs/images/per-job.PNG)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkyronio%2Fci-templates-metrics","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkyronio%2Fci-templates-metrics","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkyronio%2Fci-templates-metrics/lists"}