Skip to content
This repository has been archived by the owner on May 20, 2024. It is now read-only.

Commit

Permalink
Merge pull request #12 from azrod/devel
Browse files Browse the repository at this point in the history
Devel
  • Loading branch information
azrod authored Jan 9, 2022
2 parents a697c8c + ba867a6 commit ac8386c
Show file tree
Hide file tree
Showing 7 changed files with 135 additions and 96 deletions.
32 changes: 18 additions & 14 deletions docs/advanced/metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,35 @@ You have some options to enable metrics server.

### Config File

| Options | Default | Required | Actions |
| -------------- | -------- | ------------------------ | --------------------------------------- |
| metrics.enable | false | :heavy_multiplication_x: | Define if start metrics web server |
| metrics.host | 0.0.0.0 | :heavy_multiplication_x: | Set IP address for metrics web server |
| metrics.port | 8080 | :heavy_multiplication_x: | Set port for metrics web server |
| metrics.path | /metrics | :heavy_multiplication_x: | Path for acceding to metrics web server |
| | | | |
| Options | Default | Required | Actions |
| --------------- | -------- | ------------------------ | --------------------------------------- |
| metrics.enable | false | :heavy_multiplication_x: | Define if start metrics web server |
| metrics.host | 0.0.0.0 | :heavy_multiplication_x: | Set IP address for metrics web server |
| metrics.port | 8080 | :heavy_multiplication_x: | Set port for metrics web server |
| metrics.path | /metrics | :heavy_multiplication_x: | Path for acceding to metrics web server |
| metrics.logging | false | :heavy_multiplication_x: | Logging request http endpoint |

!!! warning "metrics.logging"

If you enable **metrics.logging**, you will see a lot of logs.

```yaml title="config.yaml"
metrics:
enable: true # Default: false
port: 8080 # Default : 8080
host: 0.0.0.0 # Default: 0.0.0.0
path: /metrics # Default: /metrics

```
## Env Variables
| Options | Actions |
| -------------- | --------------------------------------- |
| METRICS_ENABLE | Define if start metrics web server |
| METRICS_HOST | Set IP address for metrics web server |
| METRICS_PORT | Set port for metrics web server |
| METRICS_PATH | Path for acceding to metrics web server |
| Options | Actions |
| --------------- | --------------------------------------- |
| METRICS_ENABLE | Define if start metrics web server |
| METRICS_HOST | Set IP address for metrics web server |
| METRICS_PORT | Set port for metrics web server |
| METRICS_PATH | Path for acceding to metrics web server |
| METRICS_LOGGING | Logging request http on endpoint |
```bash title="exemple"
METRICS_ENABLE=true ./updateip
Expand Down
4 changes: 3 additions & 1 deletion docs/setup/configfile.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ it is possible to change the directory and the configuration file which are call
| metrics.host | 0.0.0.0 | :heavy_multiplication_x: | Set IP address for metrics web server |
| metrics.port | 8080 | :heavy_multiplication_x: | Set port for metrics web server |
| metrics.path | /metrics | :heavy_multiplication_x: | Path for acceding to metrics web server |
| metrics.logging | false | :heavy_multiplication_x: | Logging request http endpoint |
| | | | |
| providers.aws.enable | false | :heavy_multiplication_x: | Enable AWS Route 53 Provider |
| providers.aws.secret.access_key_id | "" | :heavy_check_mark: | AccessKey for AWS Account |
Expand Down Expand Up @@ -54,6 +55,7 @@ metrics:
port: 8080 # Default : 8080
host: 0.0.0.0 # Default: 0.0.0.0
path: /metrics # Default: /metrics
logging: true # Default: false

providers:
aws_account:
Expand Down Expand Up @@ -88,4 +90,4 @@ providers:
name: "subdomain.domain.com"
ttl: 60
domain: "domain.com"
```
```
1 change: 1 addition & 0 deletions docs/setup/envvars.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ All parameters can be overloaded by environment variables
| METRICS_HOST | Set IP address for metrics web server |
| METRICS_PORT | Set port for metrics web server |
| METRICS_PATH | Path for acceding to metrics web server |
| METRICS_LOGGING | Logging request http on endpoint |
| | |
| AWS_ACCOUNT_ENABLE | Enable AWS Route 53 Provider |
| AWS_ACCESS_KEY_ID | AccessKey for AWS Account |
Expand Down
22 changes: 12 additions & 10 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"

"github.com/azrod/updateip/config"
"github.com/azrod/updateip/pkg/config"
"github.com/azrod/updateip/pkg/metrics"
uip_aws "github.com/azrod/updateip/pkg/providers/aws"
uip_cloudflare "github.com/azrod/updateip/pkg/providers/cloudflare"
Expand All @@ -28,7 +28,10 @@ func main() {
zerolog.TimeFieldFormat = zerolog.TimeFormatUnix

// Load config
c := config.LoadConfig()
c, err := config.LoadConfig()
if err != nil {
log.Fatal().Err(err).Msg("Failed to load config")
}

if c.Log.Humanize {
log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr, TimeFormat: time.RFC3339})
Expand Down Expand Up @@ -108,6 +111,7 @@ func main() {
if c.Metrics.Enable {
log.Info().Msg("Starting Metrics Server")
m = metrics.Init(c.Metrics)

if c.Providers.AWSAccount.Enable {
m.RegisterPkg(Paws.RegistryMetrics())
}
Expand All @@ -126,12 +130,10 @@ func main() {
sigs := make(chan os.Signal, 1)
signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)

LOOP:
for {
select {
case sig := <-sigs:
log.Info().Msg(sig.String())
break LOOP
}
}
func() {
<-sigs
log.Info().Msg("Shutting down")
os.Exit(1)
}()

}
Loading

0 comments on commit ac8386c

Please sign in to comment.