diff --git a/README.md b/README.md index 55c85f3..11f4d92 100644 --- a/README.md +++ b/README.md @@ -54,22 +54,25 @@ go run main.go ### Flags -- `locust.uri` +- `--locust.uri` Address of Locust. Default is `http://localhost:8089`. -- `locust.timeout` +- `--locust.timeout` Timeout request to Locust. Default is `5s`. -- `web.listen-address` +- `--web.listen-address` Address to listen on for web interface and telemetry. Default is `:9646`. -- `web.telemetry-path` +- `--web.telemetry-path` Path under which to expose metrics. Default is `/metrics`. -- `log.level` +- `--locust.namespace` + Namespace for prometheus metrics. Default `locust`. + +- `--log.level` Set logging level: one of `debug`, `info`, `warn`, `error`, `fatal` -- `log.format` +- `--log.format` Set the log output target and format. e.g. `logger:syslog?appname=bob&local=7` or `logger:stdout?json=true` Defaults to `logger:stderr`. @@ -89,6 +92,9 @@ The following environment variables configure the exporter: - `LOCUST_EXPORTER_WEB_TELEMETRY_PATH` Path under which to expose metrics. Default is `/metrics`. +- `LOCUST_METRIC_NAMESPACE` + Namespace for prometheus metrics. Default `locust`. + ### Grafana The grafana dashboard has beed published with ID [11985](https://grafana.com/grafana/dashboards/11985) and was exported to [locust_dashboard.json](locust_dashboard.json). diff --git a/main.go b/main.go index 05e40aa..4aebbf5 100644 --- a/main.go +++ b/main.go @@ -19,8 +19,9 @@ import ( "gopkg.in/alecthomas/kingpin.v2" ) -const ( - namespace = "locust" +var ( + namespace string + NameSpace *string ) // Exporter structure @@ -419,11 +420,11 @@ func countWorkersByState(stats locustStats, state string) float64 { } func main() { - var ( listenAddress = kingpin.Flag("web.listen-address", "Address to listen on for web interface and telemetry.").Default(":9646").Envar("LOCUST_EXPORTER_WEB_LISTEN_ADDRESS").String() metricsPath = kingpin.Flag("web.telemetry-path", "Path under which to expose metrics.").Default("/metrics").Envar("LOCUST_EXPORTER_WEB_TELEMETRY_PATH").String() uri = kingpin.Flag("locust.uri", "URI of Locust.").Default("http://localhost:8089").Envar("LOCUST_EXPORTER_URI").String() + NameSpace = kingpin.Flag("locust.namespace", "Namespace for prometheus metrics.").Default("locust").Envar("LOCUST_METRIC_NAMESPACE").String() timeout = kingpin.Flag("locust.timeout", "Scrape timeout").Default("5s").Envar("LOCUST_EXPORTER_TIMEOUT").Duration() ) @@ -432,6 +433,7 @@ func main() { kingpin.HelpFlag.Short('h') kingpin.Parse() + namespace = *NameSpace log.Infoln("Starting locust_exporter", version.Info()) log.Infoln("Build context", version.BuildContext())