{"id":19208026,"url":"https://github.com/ubuntu/ubuntu-release-metrics","last_synced_at":"2025-05-12T18:48:19.338Z","repository":{"id":48503215,"uuid":"317844755","full_name":"ubuntu/ubuntu-release-metrics","owner":"ubuntu","description":"Code to fetch data to display on https://ubuntu-release.kpi.ubuntu.com/","archived":false,"fork":false,"pushed_at":"2024-07-28T21:21:23.000Z","size":966,"stargazers_count":6,"open_issues_count":3,"forks_count":14,"subscribers_count":6,"default_branch":"metrics","last_synced_at":"2024-07-28T22:48:27.059Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ubuntu.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}},"created_at":"2020-12-02T11:45:49.000Z","updated_at":"2024-07-28T22:48:30.113Z","dependencies_parsed_at":"2024-07-28T22:58:40.307Z","dependency_job_id":null,"html_url":"https://github.com/ubuntu/ubuntu-release-metrics","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ubuntu%2Fubuntu-release-metrics","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ubuntu%2Fubuntu-release-metrics/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ubuntu%2Fubuntu-release-metrics/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ubuntu%2Fubuntu-release-metrics/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ubuntu","download_url":"https://codeload.github.com/ubuntu/ubuntu-release-metrics/tar.gz/refs/heads/metrics","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223831172,"owners_count":17210411,"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":[],"created_at":"2024-11-09T13:23:52.189Z","updated_at":"2024-11-09T13:23:52.658Z","avatar_url":"https://github.com/ubuntu.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ubuntu community metrics\n\n## Introduction\n\nThe Ubuntu project has an [instance of\nGrafana](https://ubuntu-release.kpi.ubuntu.com/) which is a place for Ubuntu\nteams to track their metrics.\n\nThis repository hosts the scripts which collect data and push it to the\nInfluxdb database that the Grafana reads from.\n\n## Architecture\n\nThere are three branches in this repository:\n\n* `metrics`. The default branch which contains the scripts themselves. These\n  will be run periodically.\n* `charm`. This branch contains the Juju charm to deploy an instance which\n  checks out `metrics` and arranges for them to be run regularly.\n* `mojo`. This is [a delivery system for Juju\n  charms](https://mojo.canonical.com/). Most people won't need to touch this,\n  but the Mojo spec is run on a \"controller\" host to arrange to collect\n  secrets - the InfluxDB credentials - and deploy the charm.\n\n## Writing a collector\n\nCollectors are python modules in the `metrics.collectors` namespace which\nexpose a `run_metric()` function.\n\nThe simplest way to write a collector is to `import metrics.lib.basemetric`\nand write a class which inherits from `Metric` in there. Provide a `collect`\nfunction which returns data points suitable for passing to\n[InfluxDBClient.write_points()](https://influxdb-python.readthedocs.io/en/latest/api-documentation.html#influxdb.InfluxDBClient.write_points).\n`Metric` will take care of submitting to Influx for you when you invoke\n`run()`, which your `run_metric()` top level function should do. For\ndevelopment, when invoked as a script (by providing a `__main__.py` file),\nyou can pass `--dry-run` to see what would be submitted. Make use of\n`self.log` to log progress. With `--verbose`, debug messages will be logged.\n\nRaise a `metrics.lib.errors.CollectorError` on error, and the message will be\nreported along with the failure.\n\nIf you make your collector run when executed too (`python3 -m\nmetrics.collectors.your_collector`), you can provide a symlink in `bin/` so\nthat it's easier for people to run for testing purposes.\n\nBut when starting a new metric, just copy the structure of an existing script!\n\nThe `metrics` branch is auto pulled, so after merging your new collector will\nbe run automatically.\n\n## Controlling how often metrics are collected\n\nThe charm will handle arranging for each metric to be run periodically, but\nyou can control how frequently this happens. Provide a top level variable in\nyour `__init__.py` called `RUN_INTERVAL` with a value [suitable for passing\nto `OnUnitInactiveSec` in a systemd timer\nunit](https://www.freedesktop.org/software/systemd/man/systemd.timer.html).\nThe default value if you don't specify this is `5m`.\n\n## Deploying the charm\n\n*This is for the deployment itself, and not any collectors which run inside it*.\n\nYou need to have access to the live environment, which means you need to be a\nCanonical employee.\n\nBuild the charm using `charmcraft build` (`charmcraft` comes from a snap:\n`snap install charmcraft`). Copy the output of the `build` directory to the\n`build` branch, and push it. Then execute `mojo run -m manifest-upgrade` in\nthe live environment to re-run the Mojo spec (which anyone can see in the\n`mojo` branch here).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fubuntu%2Fubuntu-release-metrics","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fubuntu%2Fubuntu-release-metrics","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fubuntu%2Fubuntu-release-metrics/lists"}