{"id":13754892,"url":"https://github.com/slok/brigade-exporter","last_synced_at":"2025-03-25T03:31:27.473Z","repository":{"id":57532234,"uuid":"147187103","full_name":"slok/brigade-exporter","owner":"slok","description":"Exporter for brigade metrics","archived":false,"fork":false,"pushed_at":"2019-01-07T10:55:55.000Z","size":3512,"stargazers_count":11,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-19T08:39:25.625Z","etag":null,"topics":["brigade","ci","ci-cd","kubernetes","metrics","observability","pipelines","prometheus"],"latest_commit_sha":null,"homepage":null,"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/slok.png","metadata":{"files":{"readme":"Readme.md","changelog":"CHANGELOG","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-09-03T10:09:21.000Z","updated_at":"2020-11-03T07:37:27.000Z","dependencies_parsed_at":"2022-09-14T00:12:00.841Z","dependency_job_id":null,"html_url":"https://github.com/slok/brigade-exporter","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slok%2Fbrigade-exporter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slok%2Fbrigade-exporter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slok%2Fbrigade-exporter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slok%2Fbrigade-exporter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/slok","download_url":"https://codeload.github.com/slok/brigade-exporter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245394737,"owners_count":20608122,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["brigade","ci","ci-cd","kubernetes","metrics","observability","pipelines","prometheus"],"created_at":"2024-08-03T10:00:36.077Z","updated_at":"2025-03-25T03:31:27.123Z","avatar_url":"https://github.com/slok.png","language":"Go","funding_links":[],"categories":["Uncategorized"],"sub_categories":["Uncategorized"],"readme":"# brigade-exporter [![Build Status][travis-image]][travis-url] [![Go Report Card][goreport-image]][goreport-url] [![docker image][quay-image]][quay-url]\n\nbrigade-exporter is a Prometheus metrics exporter for [Brigade].\n\nThis exporter is designed to be run along with a brigade installation, if you have multiple brigades you will have multiple brigade-exporters, one per brigade installation. This follows the philosophy of prometheus exporters of one exporter per app instance.\n\n## Run\n\nThere is already a docker image ready to run the exporter in `quay.io/slok/brigade-exporter`. It has different options to run.\n\n### Run outside the cluster\n\nIf you want to test the exporter outside the cluster in a brigade installation, you can use `--development` flag. You will need kubectl configuration and the context set pointing to the desired cluster.\n\n```bash\ndocker run --rm \\\n    -p 9480:9480 \\\n    -v ${HOME}/.kube:/root/.kube:ro \\\n    quay.io/slok/brigade-exporter:latest \\\n    --debug \\\n    --development \\\n    --namespace ${MY_BRIGADE_NAMESPACE}\n```\n\ngo to http://127.0.0.1:9480/metrics\n\n## Grafana dashboard\n\n- [Brigade dashboard][brigade-dashboard]: A grafana dashboard for brigade.\n\n![grafana brigade dashboard](img/brigade-dashboard.png)\n\n## Deployment\n\nTODO\n\n### RBAC\n\nTODO\n\n## Metrics\n\n### Exporter metrics\n\n| Metric                                      | Type  | Meaning                            | Labels    |\n| ------------------------------------------- | ----- | ---------------------------------- | --------- |\n| brigade_exporter_collector_success          | gauge | Whether a collector succeeded      | collector |\n| brigade_exporter_collector_duration_seconds | gauge | Collector time duration in seconds | collector |\n\n### Project metrics\n\n| Metric               | Type  | Meaning                     | Labels                                  |\n| -------------------- | ----- | --------------------------- | --------------------------------------- |\n| brigade_project_info | gauge | Brigade project information | id, name, namespace, repository, worker |\n\n### Build metrics\n\n| Metric                         | Type  | Meaning                           | Labels                                        |\n| ------------------------------ | ----- | --------------------------------- | --------------------------------------------- |\n| brigade_build_info             | gauge | Brigade build information         | id, project_id, event_type, provider, version |\n| brigade_build_status           | gauge | Brigade build status              | id, status                                    |\n| brigade_build_duration_seconds | gauge | Brigade build duration in seconds | id                                            |\n\n### Job metrics\n\n| Metric                          | Type  | Meaning                                     | Labels                    |\n| ------------------------------- | ----- | ------------------------------------------- | ------------------------- |\n| brigade_job_info                | gauge | Brigade job information                     | id, build_id, image, name |\n| brigade_job_status              | gauge | Brigade job status                          | id, status                |\n| brigade_job_duration_seconds    | gauge | Brigade job duration in seconds             | id                        |\n| brigade_job_create_time_seconds | gauge | Brigade job creation time in unix timestamp | id                        |\n| brigade_job_start_time_seconds  | gauge | Brigade job start time in unix timestamp    | id                        |\n\n### Disabling metrics\n\nYou can disable metrics using flags.\n\n- `--disable-project-collector`: Disables all the metrics of projects.\n- `--disable-build-collector`: Disables all the metircs of builds.\n- `--disable-job-collector`: Disables all the jobs metrics. If you have lots of jobs, this could improve the gathering and storage of metrics.\n\n## Build from source\n\nYou can build your own brigade-exporter from source using:\n\n```bash\nmake build-binary\n```\n\nto build the binary or\n\n```bash\nmake build-image\n```\n\nto build the image.\n\n## Development\n\n### Run in fake mode\n\nIf you are developing, the exporter can fake a brigade installation and return fake data using `--fake` flag.\n\n### Run the stack with a configured Prometheus\n\nIf you want to run a local exporter+prometheus stack run.\n\n```bash\nmake stack\n```\n\nAnd you will have a prometheus on http://127.0.0.1:9090 that will scrape a faked brigade-exporter.\n\n## Query examples\n\n% of running builds per provider.\n\n```text\nsum(\n    brigade_build_status{status=\"Running\"} * on(id) group_right brigade_build_info\n) by (provider)\n/ on() group_left\nsum(\n    brigade_build_status{status=\"Running\"})\n* 100\n```\n\nGet the jobs and their states of a build\n\n```text\nbrigade_job_info{build_id=\"build-xxxx\"}\n*on(id) group_right brigade_job_status\n```\n\nGet how long the jobs have been in pending state before started to run.\n\n```text\n(brigade_job_start_time_seconds \u003e 0) - (brigade_job_create_time_seconds \u003e 0)\n```\n\nGet the top 10 project builds duration by event and provider (in the last 30m)\n\n```text\ntopk(10,\n  avg(\n    max_over_time(brigade_build_duration_seconds[30m])\n      * on(id) group_right brigade_build_info\n    * on(project_id) group_left(name)\n      label_replace(brigade_project_info , \"project_id\", \"$1\", \"id\", \"(.*)\")\n  ) by(name, provider, event_type))\n```\n\nAverage job duration seconds per project\n**Note This is an extreme example of how you owuld scalate IDs in metrics. This is not recommended.**\n\n```text\navg(\nlabel_replace(\n    label_replace(\n      avg(\n        (brigade_job_duration_seconds \u003e 0) * on(id) group_right brigade_job_info\n      ) by (build_id)\n    , \"id\", \"$1\", \"build_id\", \"(.*)\")\n    * on(id) group_right brigade_build_info\n, \"id\", \"$1\", \"project_id\", \"(.*)\")\n) by (id)\n* on(id) group_right brigade_project_info\n```\n\n[brigade]: https://brigade.sh\n[travis-image]: https://travis-ci.org/slok/brigade-exporter.svg?branch=master\n[travis-url]: https://travis-ci.org/slok/brigade-exporter\n[goreport-image]: https://goreportcard.com/badge/github.com/slok/brigade-exporter\n[goreport-url]: https://goreportcard.com/report/github.com/slok/brigade-exporter\n[quay-image]: https://quay.io/repository/slok/brigade-exporter/status\n[quay-url]: https://quay.io/repository/slok/brigade-exporter\n[brigade-dashboard]: https://grafana.com/dashboards/7800\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fslok%2Fbrigade-exporter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fslok%2Fbrigade-exporter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fslok%2Fbrigade-exporter/lists"}