diff --git a/Makefile b/Makefile index 70176a85..7ac7a9e6 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ OS_TYPE ?= $(shell uname -s | tr '[:upper:]' '[:lower:]') ARCH_TYPE ?= $(subst x86_64,amd64,$(patsubst i%86,386,$(ARCH))) GOOS ?= $(shell go env GOOS) GOARCH ?= $(shell go env GOARCH) -VERSION ?= 0.4.0 +VERSION ?= 0.4.1 MAJOR_VERSION ?= 21 MINOR_VERSION ?= 8 ORACLE_VERSION ?= $(MAJOR_VERSION).$(MINOR_VERSION) diff --git a/README.md b/README.md index 4c1ed540..2411ffae 100644 --- a/README.md +++ b/README.md @@ -179,6 +179,8 @@ Usage of oracledb_exporter: File that may contain various custom metrics in a TOML file. --default.metrics string Default TOML file metrics. + --web.systemd-socket + Use systemd socket activation listeners instead of port listeners (Linux only). --web.listen-address string Address to listen on for web interface and telemetry. (default ":9161") --web.telemetry-path string @@ -187,8 +189,8 @@ Usage of oracledb_exporter: Number of maximum idle connections in the connection pool. (default "0") --database.maxOpenConns string Number of maximum open connections in the connection pool. (default "10") - --web.config - Specify which web configuration file to load + --web.config.file + Path to configuration file that can enable TLS or authentication. ``` # Default metrics @@ -497,7 +499,7 @@ If you experience an error `Error scraping for wait_time: sql: Scan error on col export NLS_LANG=AMERICAN_AMERICA.WE8ISO8859P1 export DATA_SOURCE_NAME=system/oracle@myhost -/path/to/binary --log.level error --web.listen-address 9161 +/path/to/binary --log.level error --web.listen-address :9161 ``` If using Docker, set the same variable using the -e flag. diff --git a/main.go b/main.go index 1e06d0bf..2dd55a8a 100644 --- a/main.go +++ b/main.go @@ -28,6 +28,7 @@ import ( "github.com/prometheus/common/promlog" "github.com/prometheus/common/promlog/flag" "github.com/prometheus/exporter-toolkit/web" + webflag "github.com/prometheus/exporter-toolkit/web/kingpinflag" "gopkg.in/alecthomas/kingpin.v2" //Required for debugging //_ "net/http/pprof" @@ -36,14 +37,12 @@ import ( var ( // Version will be set at build time. Version = "0.0.0.dev" - listenAddress = kingpin.Flag("web.listen-address", "Address to listen on for web interface and telemetry. (env: LISTEN_ADDRESS)").Default(getEnv("LISTEN_ADDRESS", ":9161")).String() metricPath = kingpin.Flag("web.telemetry-path", "Path under which to expose metrics. (env: TELEMETRY_PATH)").Default(getEnv("TELEMETRY_PATH", "/metrics")).String() defaultFileMetrics = kingpin.Flag("default.metrics", "File with default metrics in a TOML file. (env: DEFAULT_METRICS)").Default(getEnv("DEFAULT_METRICS", "default-metrics.toml")).String() customMetrics = kingpin.Flag("custom.metrics", "File that may contain various custom metrics in a TOML file. (env: CUSTOM_METRICS)").Default(getEnv("CUSTOM_METRICS", "")).String() queryTimeout = kingpin.Flag("query.timeout", "Query timeout (in seconds). (env: QUERY_TIMEOUT)").Default(getEnv("QUERY_TIMEOUT", "5")).String() maxIdleConns = kingpin.Flag("database.maxIdleConns", "Number of maximum idle connections in the connection pool. (env: DATABASE_MAXIDLECONNS)").Default(getEnv("DATABASE_MAXIDLECONNS", "0")).Int() maxOpenConns = kingpin.Flag("database.maxOpenConns", "Number of maximum open connections in the connection pool. (env: DATABASE_MAXOPENCONNS)").Default(getEnv("DATABASE_MAXOPENCONNS", "10")).Int() - tlsconfigFile = kingpin.Flag("web.config", "Path to config yaml file that can enable TLS or authentication.").Default("").String() scrapeInterval = kingpin.Flag("scrape.interval", "Interval between each scrape. Default is to scrape on collect requests").Default("0s").Duration() ) @@ -587,6 +586,7 @@ func main() { promlogConfig := &promlog.Config{} flag.AddFlags(kingpin.CommandLine, promlogConfig) + var toolkitFlags = webflag.AddFlags(kingpin.CommandLine, ":9161") kingpin.Version("oracledb_exporter " + Version) kingpin.HelpFlag.Short('h') @@ -615,10 +615,9 @@ func main() { w.Write([]byte("Oracle DB Exporter " + Version + "

Oracle DB Exporter " + Version + "

Metrics

")) }) - level.Info(logger).Log("Listening on", *listenAddress) - server := &http.Server{Addr: *listenAddress} - if err := web.ListenAndServe(server, *tlsconfigFile, logger); err != nil { - level.Error(logger).Log("err", err) + server := &http.Server{} + if err := web.ListenAndServe(server, toolkitFlags, logger); err != nil { + level.Error(logger).Log("msg", err) os.Exit(1) } }