Skip to content

Commit

Permalink
change default listen port (#68)
Browse files Browse the repository at this point in the history
* chore: remove JetBrains IntelliJ IDEA files and configuration

* Update dependencies to latest versions

* change default port to 9152
  • Loading branch information
rluisr authored Jul 5, 2024
1 parent 9682657 commit adb5f30
Show file tree
Hide file tree
Showing 11 changed files with 60 additions and 112 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
.idea
.env
.envrc
mysqlrouter_exporter
8 changes: 0 additions & 8 deletions .idea/.gitignore

This file was deleted.

7 changes: 0 additions & 7 deletions .idea/dictionaries/s01082.xml

This file was deleted.

8 changes: 0 additions & 8 deletions .idea/modules.xml

This file was deleted.

9 changes: 0 additions & 9 deletions .idea/mysqlrouter_exporter.iml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/vcs.xml

This file was deleted.

29 changes: 0 additions & 29 deletions .idea/watcherTasks.xml

This file was deleted.

72 changes: 35 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -31,28 +32,26 @@ ExecStart=/usr/local/bin/mysqlrouter_exporter
WantedBy=multi-user.target
```

Container
----------
## Container

```bash
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.

Expand All @@ -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]
Expand All @@ -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)
15 changes: 8 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
)
14 changes: 14 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down

0 comments on commit adb5f30

Please sign in to comment.