diff --git a/.gitignore b/.gitignore
index c1b2078..d316691 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,4 @@
.idea
+.env
+.envrc
mysqlrouter_exporter
\ No newline at end of file
diff --git a/.idea/.gitignore b/.idea/.gitignore
deleted file mode 100644
index 73f69e0..0000000
--- a/.idea/.gitignore
+++ /dev/null
@@ -1,8 +0,0 @@
-# Default ignored files
-/shelf/
-/workspace.xml
-# Datasource local storage ignored files
-/dataSources/
-/dataSources.local.xml
-# Editor-based HTTP Client requests
-/httpRequests/
diff --git a/.idea/dictionaries/s01082.xml b/.idea/dictionaries/s01082.xml
deleted file mode 100644
index b38c17e..0000000
--- a/.idea/dictionaries/s01082.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
- goreleaser
-
-
-
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
deleted file mode 100644
index 710d391..0000000
--- a/.idea/modules.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/mysqlrouter_exporter.iml b/.idea/mysqlrouter_exporter.iml
deleted file mode 100644
index 5e764c4..0000000
--- a/.idea/mysqlrouter_exporter.iml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
deleted file mode 100644
index 94a25f7..0000000
--- a/.idea/vcs.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/watcherTasks.xml b/.idea/watcherTasks.xml
deleted file mode 100644
index 97ad6d2..0000000
--- a/.idea/watcherTasks.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
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/go.mod b/go.mod
index 3e87cf1..eeab6db 100644
--- a/go.mod
+++ b/go.mod
@@ -1,6 +1,6 @@
module github.com/rluisr/mysqlrouter_exporter
-go 1.20
+go 1.22
require (
github.com/jessevdk/go-flags v1.6.1
@@ -10,10 +10,11 @@ require (
require (
github.com/beorn7/perks v1.0.1 // indirect
- github.com/cespare/xxhash/v2 v2.2.0 // indirect
- github.com/prometheus/client_model v0.5.0 // indirect
- github.com/prometheus/common v0.48.0 // indirect
- github.com/prometheus/procfs v0.12.0 // indirect
- golang.org/x/sys v0.21.0 // indirect
- google.golang.org/protobuf v1.33.0 // indirect
+ github.com/cespare/xxhash/v2 v2.3.0 // indirect
+ github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
+ github.com/prometheus/client_model v0.6.1 // indirect
+ github.com/prometheus/common v0.55.0 // indirect
+ github.com/prometheus/procfs v0.15.1 // indirect
+ golang.org/x/sys v0.22.0 // indirect
+ google.golang.org/protobuf v1.34.2 // indirect
)
diff --git a/go.sum b/go.sum
index e307773..68b9990 100644
--- a/go.sum
+++ b/go.sum
@@ -2,24 +2,38 @@ github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
+github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
+github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/jessevdk/go-flags v1.6.1 h1:Cvu5U8UGrLay1rZfv/zP7iLpSHGUZ/Ou68T0iX1bBK4=
github.com/jessevdk/go-flags v1.6.1/go.mod h1:Mk8T1hIAWpOiJiHa9rJASDK2UGWji0EuPGBnNLMooyc=
+github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
+github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/prometheus/client_golang v1.19.1 h1:wZWJDwK+NameRJuPGDhlnFgx8e8HN3XHQeLaYJFJBOE=
github.com/prometheus/client_golang v1.19.1/go.mod h1:mP78NwGzrVks5S2H6ab8+ZZGJLZUq1hoULYBAYBw1Ho=
github.com/prometheus/client_model v0.5.0 h1:VQw1hfvPvk3Uv6Qf29VrPF32JB6rtbgI6cYPYQjL0Qw=
github.com/prometheus/client_model v0.5.0/go.mod h1:dTiFglRmd66nLR9Pv9f0mZi7B7fk5Pm3gvsjB5tr+kI=
+github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E=
+github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY=
github.com/prometheus/common v0.48.0 h1:QO8U2CdOzSn1BBsmXJXduaaW+dY/5QLjfB8svtSzKKE=
github.com/prometheus/common v0.48.0/go.mod h1:0/KsvlIEfPQCQ5I2iNSAWKPZziNCvRs5EC6ILDTlAPc=
+github.com/prometheus/common v0.55.0 h1:KEi6DK7lXW/m7Ig5i47x0vRzuBsHuvJdi5ee6Y3G1dc=
+github.com/prometheus/common v0.55.0/go.mod h1:2SECS4xJG1kd8XF9IcM1gMX6510RAEL65zxzNImwdc8=
github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo=
github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo=
+github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc=
+github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
github.com/rluisr/mysqlrouter-go v1.2.0 h1:2E65PtqEiCgQRE14SSsi8+I6IPPrqKveFcO2JG+pHck=
github.com/rluisr/mysqlrouter-go v1.2.0/go.mod h1:TakU6i+cdcQhI4uRiAIpMa51lV/IJiAMHGyDxeFSVuc=
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws=
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
+golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI=
+golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI=
google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
+google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
+google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
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"`