{"id":20328589,"url":"https://github.com/braedon/prometheus-mysql-exporter","last_synced_at":"2025-04-11T20:40:58.796Z","repository":{"id":49198011,"uuid":"53571491","full_name":"braedon/prometheus-mysql-exporter","owner":"braedon","description":"Prometheus MySQL Exporter","archived":false,"fork":false,"pushed_at":"2023-05-19T18:12:43.000Z","size":76,"stargazers_count":40,"open_issues_count":3,"forks_count":20,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-09T00:51:28.553Z","etag":null,"topics":["mariadb","mysql","prometheus","prometheus-exporter","sql"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/braedon.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}},"created_at":"2016-03-10T09:20:58.000Z","updated_at":"2024-06-14T07:54:10.000Z","dependencies_parsed_at":"2022-09-04T10:42:17.480Z","dependency_job_id":null,"html_url":"https://github.com/braedon/prometheus-mysql-exporter","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/braedon%2Fprometheus-mysql-exporter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/braedon%2Fprometheus-mysql-exporter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/braedon%2Fprometheus-mysql-exporter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/braedon%2Fprometheus-mysql-exporter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/braedon","download_url":"https://codeload.github.com/braedon/prometheus-mysql-exporter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248337635,"owners_count":21087074,"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":["mariadb","mysql","prometheus","prometheus-exporter","sql"],"created_at":"2024-11-14T20:06:59.242Z","updated_at":"2025-04-11T20:40:58.775Z","avatar_url":"https://github.com/braedon.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"Prometheus MySQL Exporter\n====\nThis Prometheus exporter periodically runs configured queries against a MySQL server and exports the results as Prometheus gauge metrics.\n\n[Source Code](https://github.com/braedon/prometheus-mysql-exporter) | [Python Package](https://pypi.org/project/prometheus-mysql-exporter) | [Docker Image](https://hub.docker.com/r/braedon/prometheus-mysql-exporter) | [Helm Chart](https://braedon.github.io/helm/prometheus-mysql-exporter)\n\n# Installation\nThe exporter requires Python 3 and Pip 3 to be installed.\n\nTo install the latest published version via Pip, run:\n```bash\n\u003e pip3 install prometheus-mysql-exporter\n```\nNote that you may need to add the start script location (see pip output) to your `PATH`.\n\n# Usage\nOnce installed, you can run the exporter with the `prometheus-mysql-exporter` command.\n\nBy default, it will bind to port 9207, query MySQL on `localhost:3306` using the `root` user (with no password) and run queries configured in a file `exporter.cfg` in the working directory. You can change any defaults or other settings as required by passing in options:\n```bash\n\u003e prometheus-mysql-exporter -p \u003cport\u003e -s \u003cmysql server\u003e -u \u003cmysql username\u003e -P \u003cmysql password\u003e -z \u003clocal timezone\u003e -c \u003cpath to query config file\u003e\n```\nRun with the `-h` flag to see details on all the available options.\n\nNote that all options can be set via environment variables. The environment variable names are prefixed with `MYSQL_EXPORTER`, e.g. `MYSQL_EXPORTER_MYSQL_USER=fred` is equivalent to `--mysql-user fred`. CLI options take precidence over environment variables.\n\nCommand line options can also be set from a configuration file, by passing `--config FILE`. The format of the file should be [Configobj's unrepre mode](https://configobj.readthedocs.io/en/latest/configobj.html#unrepr-mode), so instead of `--mysql-user fred` you could use a configuration file `config_file` with `mysql-user=\"fred\"` in it, and pass `--config config_file`. CLI options and environment variables take precedence over configuration files.\n\nCLI options, environment variables, and configuration files all override any default options. The full resolution order for a given option is: CLI \u003e Environment \u003e Configuration file \u003e Default.\n\nSee the provided [exporter.cfg](exporter.cfg) file for query configuration examples and explanation.\n\n# Docker\nDocker images for released versions can be found on Docker Hub (note that no `latest` version is provided):\n```bash\n\u003e sudo docker pull braedon/prometheus-mysql-exporter:\u003cversion\u003e\n```\nTo run a container successfully, you will need to mount a query config file to `/usr/src/app/exporter.cfg` and map container port 9207 to a port on the host. Any options placed after the image name (`prometheus-mysql-exporter`) will be passed to the process inside the container. For example, you will need to use this to configure the MySQL server using `-s`.\n```bash\n\u003e sudo docker run --rm --name exporter \\\n    -v \u003cpath to query config file\u003e:/usr/src/app/exporter.cfg \\\n    -p \u003chost port\u003e:9207 \\\n    braedon/prometheus-mysql-exporter:\u003cversion\u003e -s \u003cmysql server\u003e\n```\nIf you don't want to mount the query config file in at run time, you could extend an existing image with your own Dockerfile that copies the config file in at build time.\n\n# Helm\nA Helm chart is available from the Helm repo at [https://braedon.github.io/helm](https://braedon.github.io/helm/).\n```bash\n\u003e helm repo add braedon https://braedon.github.io/helm\n\u003e helm repo update\n\n\u003e helm install braedon/prometheus-mysql-exporter --name \u003crelease name\u003e \\\n                                                 --set mysql.server=\u003cmysql server address\u003e \\\n                                                 --set image.tag=\u003cimage tag\u003e\n```\nSee the [`prometheus-mysql-exporter` chart README](https://braedon.github.io/helm/prometheus-mysql-exporter/) for more details on how to configure the chart.\n\n# Development\nTo install directly from the git repo, run the following in the root project directory:\n```bash\n\u003e pip3 install .\n```\nThe exporter can be installed in \"editable\" mode, using pip's `-e` flag. This allows you to test out changes without having to re-install.\n```bash\n\u003e pip3 install -e .\n```\nTo build a docker image directly from the git repo, run the following in the root project directory:\n```bash\n\u003e sudo docker build -t \u003cyour repository name and tag\u003e .\n```\nSend me a PR if you have a change you want to contribute!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbraedon%2Fprometheus-mysql-exporter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbraedon%2Fprometheus-mysql-exporter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbraedon%2Fprometheus-mysql-exporter/lists"}