Package: prometheus-mysql-exporter
Prometheus MySQL ExporterThis Prometheus exporter periodically runs configured queries against a MySQL server and exports the results as Prometheus gauge metrics.Source Code|Python Package|Docker Image|Helm ChartInstallationThe exporter requires Python 3 and Pip 3 to be installed.To install the latest published version via Pip, run:>pip3installprometheus-mysql-exporterNote that you may need to add the start script location (see pip output) to yourPATH.UsageOnce installed, you can run the exporter with theprometheus-mysql-exportercommand.By default, it will bind to port 9207, query MySQL onlocalhost:3306using therootuser (with no password) and run queries configured in a fileexporter.cfgin the working directory. You can change any defaults or other settings as required by passing in options:>prometheus-mysql-exporter-p<port>-s<mysqlserver>-u<mysqlusername>-P<mysqlpassword>-z<localtimezone>-c<pathtoqueryconfigfile>Run with the-hflag to see details on all the available options.Note that all options can be set via environment variables. The environment variable names are prefixed withMYSQL_EXPORTER, e.g.MYSQL_EXPORTER_MYSQL_USER=fredis equivalent to--mysql-user fred. CLI options take precidence over environment variables.Command line options can also be set from a configuration file, by passing--config FILE. The format of the file should beConfigobj's unrepre mode, so instead of--mysql-user fredyou could use a configuration fileconfig_filewithmysql-user="fred"in it, and pass--config config_file. CLI options and environment variables take precedence over configuration files.CLI options, environment variables, and configuration files all override any default options. The full resolution order for a given option is: CLI > Environment > Configuration file > Default.See the providedexporter.cfgfile for query configuration examples and explanation.DockerDocker images for released versions can be found on Docker Hub (note that nolatestversion is provided):>sudodockerpullbraedon/prometheus-mysql-exporter:<version>To run a container successfully, you will need to mount a query config file to/usr/src/app/exporter.cfgand 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.>sudodockerrun--rm--nameexporter\-v<pathtoqueryconfigfile>:/usr/src/app/exporter.cfg\-p<hostport>:9207\braedon/prometheus-mysql-exporter:<version>-s<mysqlserver>If 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.HelmA Helm chart is available from the Helm repo athttps://braedon.github.io/helm.>helmrepoaddbraedonhttps://braedon.github.io/helm
>helmrepoupdate

>helminstallbraedon/prometheus-mysql-exporter--name<releasename>\--setmysql.server=<mysqlserveraddress>\--setimage.tag=<imagetag>See theprometheus-mysql-exporterchart READMEfor more details on how to configure the chart.DevelopmentTo install directly from the git repo, run the following in the root project directory:>pip3install.The exporter can be installed in "editable" mode, using pip's-eflag. This allows you to test out changes without having to re-install.>pip3install-e.To build a docker image directly from the git repo, run the following in the root project directory:>sudodockerbuild-t<yourrepositorynameandtag>.Send me a PR if you have a change you want to contribute!