You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: main.go
+13-5Lines changed: 13 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -26,12 +26,12 @@ import (
26
26
var (
27
27
// Version will be set at build time.
28
28
Version="0.0.0.dev"
29
-
listenAddress=flag.String("web.listen-address", ":9161", "Address to listen on for web interface and telemetry.")
30
-
metricPath=flag.String("web.telemetry-path", "/metrics", "Path under which to expose metrics.")
29
+
listenAddress=flag.String("web.listen-address", getEnv("LISTEN_ADDRESS", ":9161"), "Address to listen on for web interface and telemetry. (env: LISTEN_ADDRESS)")
30
+
metricPath=flag.String("web.telemetry-path", getEnv("TELEMETRY_PATH", "/metrics"), "Path under which to expose metrics. (env: TELEMETRY_PATH)")
31
31
landingPage= []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>")
32
-
defaultFileMetrics=flag.String("default.metrics", "default-metrics.toml", "File with default metrics in a TOML file.")
33
-
customMetrics=flag.String("custom.metrics", os.Getenv("CUSTOM_METRICS"), "File that may contain various custom metrics in a TOML file.")
34
-
queryTimeout=flag.String("query.timeout", "5", "Query timeout (in seconds).")
32
+
defaultFileMetrics=flag.String("default.metrics", getEnv("DEFAULT_METRICS", "default-metrics.toml"), "File with default metrics in a TOML file. (env: DEFAULT_METRICS)")
33
+
customMetrics=flag.String("custom.metrics", getEnv("CUSTOM_METRICS", ""), "File that may contain various custom metrics in a TOML file. (env: CUSTOM_METRICS)")
34
+
queryTimeout=flag.String("query.timeout", getEnv("QUERY_TIMEOUT", "5"), "Query timeout (in seconds). (env: QUERY_TIMEOUT)")
35
35
)
36
36
37
37
// Metric name parts.
@@ -73,6 +73,14 @@ type Exporter struct {
73
73
74
74
}
75
75
76
+
// getEnv returns the value of an environment variable, or returns the provided fallback value
77
+
funcgetEnv(key, fallbackstring) string {
78
+
ifvalue, ok:=os.LookupEnv(key); ok {
79
+
returnvalue
80
+
}
81
+
returnfallback
82
+
}
83
+
76
84
// NewExporter returns a new Oracle DB exporter for the provided DSN.
0 commit comments