From 542436290fe9beef6d3fa62c5ae2e0dad989b664 Mon Sep 17 00:00:00 2001 From: rluisr Date: Fri, 5 Jul 2024 21:35:59 +0900 Subject: [PATCH] change default port to 9152 --- README.md | 72 +++++++++++++++++++++++++++---------------------------- main.go | 2 +- 2 files changed, 36 insertions(+), 38 deletions(-) diff --git a/README.md b/README.md index 0f11d88..8e7b77d 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,20 @@ -mysqlrouter_exporter -===================== +# mysqlrouter_exporter + [![lint](https://github.com/rluisr/mysqlrouter_exporter/actions/workflows/lint.yml/badge.svg)](https://github.com/rluisr/mysqlrouter_exporter/actions/workflows/lint.yml) [![release](https://github.com/rluisr/mysqlrouter_exporter/actions/workflows/release.yml/badge.svg)](https://github.com/rluisr/mysqlrouter_exporter/actions/workflows/release.yml) -Supported MySQL Router version -------------------------------- +## Supported MySQL Router version + check [here](https://github.com/rluisr/mysqlrouter-go#supported-version) -Usage ------ +## Usage + 1. Enable REST API on your MySQL Router [here](https://github.com/rluisr/mysqlrouter-go#supported-version) 2. Download binary from [release](https://github.com/rluisr/mysqlrouter_exporter/releases). 3. Move to /usr/local/bin/ 4. Add systemd script. 5. Start + ``` [Unit] Description=mysqlrouter-exporter @@ -31,8 +32,7 @@ ExecStart=/usr/local/bin/mysqlrouter_exporter WantedBy=multi-user.target ``` -Container ----------- +## Container ```bash docker pull ghcr.io/rluisr/mysqlrouter_exporter:latest @@ -40,19 +40,18 @@ docker pull ghcr.io/rluisr/mysqlrouter_exporter:latest [Packages](https://github.com/rluisr/mysqlrouter_exporter/pkgs/container/mysqlrouter_exporter) -Environment ------------ +## Environment Edit systemd script or add an environment variables. -Name | Default | Require | Description -----------------------------|---------| --------| ---------- -MYSQLROUTER_EXPORTER_URL | - | yes | MySQL Router Rest API URL -MYSQLROUTER_EXPORTER_USER | - | no | Username for REST API -MYSQLROUTER_EXPORTER_PASS | - | no | Password for REST API -MYSQLROUTER_TLS_CACERT_PATH | - | no | TLS CA cert path -MYSQLROUTER_TLS_CERT_PATH | - | no | TLS cert path -MYSQLROUTER_TLS_KEY_PATH | - | no | TLS key path +| Name | Default | Require | Description | +| --------------------------- | ------- | ------- | ------------------------- | +| MYSQLROUTER_EXPORTER_URL | - | yes | MySQL Router Rest API URL | +| MYSQLROUTER_EXPORTER_USER | - | no | Username for REST API | +| MYSQLROUTER_EXPORTER_PASS | - | no | Password for REST API | +| MYSQLROUTER_TLS_CACERT_PATH | - | no | TLS CA cert path | +| MYSQLROUTER_TLS_CERT_PATH | - | no | TLS cert path | +| MYSQLROUTER_TLS_KEY_PATH | - | no | TLS key path | You can also set it as a flag. See below. @@ -61,7 +60,7 @@ Application Options: --url= MySQL Router Rest API URL [$MYSQLROUTER_EXPORTER_URL] --user= Username for REST API [$MYSQLROUTER_EXPORTER_USER] --pass= Password for REST API [$MYSQLROUTER_EXPORTER_PASS] - -p, --listen-port= Listen port (default: 49152) + -p, --listen-port= Listen port (default: 9152) --service-name= Service name for MySQL Router [$MYSQLROUTER_EXPORTER_SERVICE_NAME] --tls-ca-cert-path= TLS CA cacert path [$MYSQLROUTER_TLS_CACERT_PATH] --tls-cert-path= TLS cert path [$MYSQLROUTER_TLS_CERT_PATH] @@ -81,33 +80,32 @@ Help Options: -h, --help Show this help message ``` -Collector Flags ----------------- +## Collector Flags mysqlrouter_exporter can all get metrics. [MySQL Router REST API Reference](https://dev.mysql.com/doc/mysql-router/8.0/en/mysql-router-rest-api-reference.html) -Name | Default | Description --------------------------------------------------------|-----------|------------- -collect.metadata.status | false | Collect metrics from metadata status. CPU usage will increase. -collect.route.connections.byte_from_server | false | Collect metrics from route connections. CPU usage will increase. -collect.route.connections.byte_to_server | false | Collect metrics from route connections. CPU usage will increase. -collect.route.connections.time_started | false | Collect metrics from route connections. CPU usage will increase. -collect.route.connections.time_connected_to_server | false | Collect metrics from route connections. CPU usage will increase. -collect.route.connections.time_last_sent_to_server | false | Collect metrics from route connections. CPU usage will increase. -collect.route.connections.time_received_from_server | false | Collect metrics from route connections. CPU usage will increase. - -Prometheus configuration -------------------------- +| Name | Default | Description | +| --------------------------------------------------- | ------- | ---------------------------------------------------------------- | +| collect.metadata.status | false | Collect metrics from metadata status. CPU usage will increase. | +| collect.route.connections.byte_from_server | false | Collect metrics from route connections. CPU usage will increase. | +| collect.route.connections.byte_to_server | false | Collect metrics from route connections. CPU usage will increase. | +| collect.route.connections.time_started | false | Collect metrics from route connections. CPU usage will increase. | +| collect.route.connections.time_connected_to_server | false | Collect metrics from route connections. CPU usage will increase. | +| collect.route.connections.time_last_sent_to_server | false | Collect metrics from route connections. CPU usage will increase. | +| collect.route.connections.time_received_from_server | false | Collect metrics from route connections. CPU usage will increase. | + +## Prometheus configuration + ```yaml scrape_configs: - - job_name: 'mysqlrouter' + - job_name: "mysqlrouter" static_configs: - targets: - - mysqlrouter01.luis.local:49152 + - mysqlrouter.local:9152 ``` -Grafana Dashboard ------------------------- +## Grafana Dashboard + ![Grafana Dashboard](img/grafana.png "Grafana Dashboard") [Download dashboard](https://grafana.com/grafana/dashboards/10741) diff --git a/main.go b/main.go index cc60ebd..54ab196 100644 --- a/main.go +++ b/main.go @@ -32,7 +32,7 @@ var args struct { RestAPIURL string `short:"" long:"url" required:"true" env:"MYSQLROUTER_EXPORTER_URL" description:"MySQL Router Rest API URL"` RestAPIUser string `short:"" long:"user" required:"false" env:"MYSQLROUTER_EXPORTER_USER" description:"Username for REST API"` RestAPIPass string `short:"" long:"pass" required:"false" env:"MYSQLROUTER_EXPORTER_PASS" description:"Password for REST API"` - ListenPort int `short:"p" long:"listen-port" default:"49152" description:"Listen port"` + ListenPort int `short:"p" long:"listen-port" default:"9152" description:"Listen port"` ServiceName string `short:"" long:"service-name" required:"true" env:"MYSQLROUTER_EXPORTER_SERVICE_NAME" description:"Service name for MySQL Router"` TLSCACertPath string `short:"" long:"tls-ca-cert-path" required:"false" env:"MYSQLROUTER_TLS_CACERT_PATH" description:"TLS CA cacert path"` TLSCertPath string `short:"" long:"tls-cert-path" required:"false" env:"MYSQLROUTER_TLS_CERT_PATH" description:"TLS cert path"`