Skip to content

Commit

Permalink
Merge pull request #80 from Chaostheorie/main
Browse files Browse the repository at this point in the history
chore: make listen address fully configurable
  • Loading branch information
fishgrimsby authored Oct 13, 2024
2 parents 0bc1013 + 92111af commit 0ade8d7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,9 @@ A multi-architecture docker image with usage instructions is available at https:

## Configuration options
The following configuration options are available and must be set via Environment variable:
- BORGMATIC_EXPORTER_HOST - Set the http listen address. Default to `0.0.0.0`
- BORGMATIC_EXPORTER_PORT - Set the http listen port. Default to `8090`
- BORGMATIC_EXPORTER_ENDPOINT - Set the metrics endpoint. Defaults to `metrics`
- BORGMATIC_EXPORTER_CONFIG - Overrides the default config paths using `borgmatic -c`. Uses Borgmatic defaults if not set. Multiple config paths must be separated with spaces, i.e `/path/to/config1.yaml /path/to/config2.yaml`
- BORGMATIC_EXPORTER_DEBUG - Enable debug messages to stdout
- BORGMATIC_EXPORTER_LOGFORMAT - Set the format of logs. Valid options are `keyvalue` (default) and `json`
- BORGMATIC_EXPORTER_LOGFORMAT - Set the format of logs. Valid options are `keyvalue` (default) and `json`
5 changes: 3 additions & 2 deletions cmd/borgmatic-exporter/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ func main() {
prometheus.MustRegister(collector)

http.Handle(fmt.Sprintf("/%s", config.Endpoint), promhttp.Handler())
logs.Logger.Info(fmt.Sprintf("listening on http://localhost:%s/%s", config.Port, config.Endpoint))
err = http.ListenAndServe(fmt.Sprintf(":%s", config.Port), nil)
addr := config.Host + ":" + config.Port
logs.Logger.Info(fmt.Sprintf("listening on http://%s/%s", addr, config.Endpoint))
err = http.ListenAndServe(addr, nil)

if errors.Is(err, http.ErrServerClosed) {
logs.Logger.Error("server closed",
Expand Down
1 change: 1 addition & 0 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
)

type specification struct {
Host string `default:"0.0.0.0"`
Port string `default:"8090"`
Endpoint string `default:"metrics"`
Config string `default:""`
Expand Down

0 comments on commit 0ade8d7

Please sign in to comment.