From e7f0b15aefa77ab0c4f15cf184d55d79ee97ea7b Mon Sep 17 00:00:00 2001 From: Ayman Shorman Date: Sun, 15 Dec 2019 19:36:01 +0200 Subject: [PATCH 1/3] replace --arangodb.endpoint with env variable Replace --arangodb.endpoint as it wasn't hiding the password of Arangodb server when running the exporter process. instead of passing the conn string to the process just export this env variable DB_URL for example: export DB_URL="http://arango_user:mypassword@192.168.6.7:8529" then run the exporter : ./arangodb-exporter & --- main.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 4ceae7d..629b315 100644 --- a/main.go +++ b/main.go @@ -29,6 +29,7 @@ import ( _ "net/http/pprof" "strings" "time" + "os" "github.com/pkg/errors" "github.com/prometheus/client_golang/prometheus" @@ -62,7 +63,6 @@ func init() { f.StringVar(&serverOptions.Address, "server.address", ":9101", "Address the exporter will listen on (IP:port)") f.StringVar(&serverOptions.TLSKeyfile, "ssl.keyfile", "", "File containing TLS certificate used for the metrics server. Format equal to ArangoDB keyfiles") - f.StringVar(&arangodbOptions.endpoint, "arangodb.endpoint", "http://127.0.0.1:8529", "Endpoint used to reach the ArangoDB server") f.StringVar(&arangodbOptions.jwtSecret, "arangodb.jwtsecret", "", "JWT Secret used for authentication with ArangoDB server") f.StringVar(&arangodbOptions.jwtFile, "arangodb.jwt-file", "", "File containing the JWT for authentication with ArangoDB server") f.DurationVar(&arangodbOptions.timeout, "arangodb.timeout", time.Second*15, "Timeout of statistics requests for ArangoDB") @@ -78,6 +78,9 @@ func cmdMainRun(cmd *cobra.Command, args []string) { log.Infoln(fmt.Sprintf("Starting arangodb-exporter %s, build %s", projectVersion, projectBuild)) var token string + var conn string + conn = os.Getenv("DB_URL") + if arangodbOptions.jwtFile != "" { data, err := ioutil.ReadFile(arangodbOptions.jwtFile) if err != nil { @@ -92,7 +95,7 @@ func cmdMainRun(cmd *cobra.Command, args []string) { } } - exporter, err := NewExporter(arangodbOptions.endpoint, token, false, arangodbOptions.timeout) + exporter, err := NewExporter(conn, token, false, arangodbOptions.timeout) if err != nil { log.Fatal(err) } From ded31917ce3f4258bc39cabae517b78f060e6e8c Mon Sep 17 00:00:00 2001 From: Ayman Shorman Date: Sun, 15 Dec 2019 19:40:30 +0200 Subject: [PATCH 2/3] update the usage --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1b9f8c0..09d8265 100644 --- a/README.md +++ b/README.md @@ -6,10 +6,13 @@ in a format compatible with prometheus. ## Usage To use the ArangoDB Exporter, run the following: +``` + +export DB_URL="http://arangodb_username:arangodb_pass@0.0.0.0:8529" +``` ```bash arangodb-exporter \ - --arangodb.endpoint=http://:8529 \ --arangodb.jwtsecret= \ --ssl.keyfile= ``` From 8735c006a7209cc2f331d687bad3714f285c3c62 Mon Sep 17 00:00:00 2001 From: Ayman Al-Shorman Date: Mon, 27 Jul 2020 00:50:34 +0000 Subject: [PATCH 3/3] add edit by --- main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.go b/main.go index 629b315..5d994c1 100644 --- a/main.go +++ b/main.go @@ -18,7 +18,7 @@ // Copyright holder is ArangoDB GmbH, Cologne, Germany // // Author Ewout Prangsma -// +// Edited by Ayman Shorman package main