@@ -37,6 +37,13 @@ import (
37
37
"github.com/spf13/cobra"
38
38
)
39
39
40
+ type ExporterMode string
41
+
42
+ const (
43
+ ModeInternal ExporterMode = "internal"
44
+ ModePassthru ExporterMode = "passthru"
45
+ )
46
+
40
47
var (
41
48
projectVersion = "dev"
42
49
projectBuild = "dev"
50
57
serverOptions ServerConfig
51
58
arangodbOptions struct {
52
59
endpoint string
60
+ mode string
53
61
jwtSecret string
54
62
jwtFile string
55
63
timeout time.Duration
@@ -67,6 +75,8 @@ func init() {
67
75
f .StringVar (& arangodbOptions .jwtFile , "arangodb.jwt-file" , "" , "File containing the JWT for authentication with ArangoDB server" )
68
76
f .DurationVar (& arangodbOptions .timeout , "arangodb.timeout" , time .Second * 15 , "Timeout of statistics requests for ArangoDB" )
69
77
78
+ f .StringVar (& arangodbOptions .mode , "mode" , "internal" , "Mode for ArangoDB exporter. Internal - use internal, old mode of metrics calculation (default). Passthru - expose ArangoD metrics directly, using proper authentication." )
79
+
70
80
f .MarkDeprecated ("arangodb.jwtsecret" , "please use --arangodb.jwt-file instead" )
71
81
}
72
82
@@ -91,20 +101,28 @@ func cmdMainRun(cmd *cobra.Command, args []string) {
91
101
log .Fatal (err )
92
102
}
93
103
}
94
-
95
- exporter , err := NewExporter (arangodbOptions .endpoint , token , false , arangodbOptions .timeout )
96
- if err != nil {
97
- log .Fatal (err )
104
+ mux := http .NewServeMux ()
105
+ switch ExporterMode (arangodbOptions .mode ) {
106
+ case ModePassthru :
107
+ passthru , err := NewPassthru (arangodbOptions .endpoint , token , false , arangodbOptions .timeout )
108
+ if err != nil {
109
+ log .Fatal (err )
110
+ }
111
+ mux .Handle ("/metrics" , passthru )
112
+ default :
113
+ exporter , err := NewExporter (arangodbOptions .endpoint , token , false , arangodbOptions .timeout )
114
+ if err != nil {
115
+ log .Fatal (err )
116
+ }
117
+ prometheus .MustRegister (exporter )
118
+ version .Version = projectVersion
119
+ version .Revision = projectBuild
120
+ prometheus .MustRegister (version .NewCollector ("arangodb_exporter" ))
121
+ mux .Handle ("/metrics" , prometheus .Handler ())
98
122
}
99
- prometheus .MustRegister (exporter )
100
- version .Version = projectVersion
101
- version .Revision = projectBuild
102
- prometheus .MustRegister (version .NewCollector ("arangodb_exporter" ))
103
123
104
124
log .Infoln ("Listening on" , serverOptions .Address )
105
125
106
- mux := http .NewServeMux ()
107
- mux .Handle ("/metrics" , prometheus .Handler ())
108
126
mux .HandleFunc ("/" , func (w http.ResponseWriter , r * http.Request ) {
109
127
w .Write ([]byte (`<html>
110
128
<head><title>ArangoDB Exporter</title></head>
0 commit comments