Skip to content

Commit

Permalink
Fix 0.4.0 compilation problem (#277)
Browse files Browse the repository at this point in the history
* Fix parsing kingpin flags according to exporter-toolkit v0.8.2

Fixes #275

Signed-off-by: Nikolay Pelov <[email protected]>

* Update README file to reflect the changed options from exporter-toolkit.

* Update release version to 0.4.1

---------

Signed-off-by: Nikolay Pelov <[email protected]>
  • Loading branch information
pelov authored Feb 6, 2023
1 parent 3bd4633 commit 44ce18c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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.
Expand Down
11 changes: 5 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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()
)

Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -615,10 +615,9 @@ func main() {
w.Write([]byte("<html><head><title>Oracle DB Exporter " + Version + "</title></head><body><h1>Oracle DB Exporter " + Version + "</h1><p><a href='" + *metricPath + "'>Metrics</a></p></body></html>"))
})

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)
}
}

0 comments on commit 44ce18c

Please sign in to comment.