-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for RethinkDB 1.0 handshake protocol (#2963)
Allow rethinkdb input plugin to work with RethinkDB 2.3.5+ databases that requires username,password authorization and Handshake protocol v1.0 * remove top level header not required in sample config * remove top level header not required in sample config
- Loading branch information
1 parent
f070f14
commit ab876bb
Showing
5 changed files
with
54 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1851,6 +1851,17 @@ | |
# ## rethinkdb://10.10.3.33:18832, | ||
# ## 10.0.0.1:10000, etc. | ||
# servers = ["127.0.0.1:28015"] | ||
# ## | ||
# ## If you use actual rethinkdb of > 2.3.0 with username/password authorization, | ||
# ## protocol have to be named "rethinkdb2" - it will use 1_0 H. | ||
# servers = ["rethinkdb2://username:[email protected]:28015"] | ||
# ## | ||
# ## If you use older versions of rethinkdb (<2.2) with auth_key, protocol | ||
# ## have to be named "rethinkdb". | ||
# servers = ["rethinkdb://username:[email protected]:28015"] | ||
|
||
|
||
|
||
|
||
|
||
# # Read metrics one or many Riak servers | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ import ( | |
"github.com/influxdata/telegraf" | ||
"github.com/influxdata/telegraf/plugins/inputs" | ||
|
||
"gopkg.in/dancannon/gorethink.v1" | ||
"gopkg.in/gorethink/gorethink.v3" | ||
) | ||
|
||
type RethinkDB struct { | ||
|
@@ -22,6 +22,14 @@ var sampleConfig = ` | |
## rethinkdb://10.10.3.33:18832, | ||
## 10.0.0.1:10000, etc. | ||
servers = ["127.0.0.1:28015"] | ||
## | ||
## If you use actual rethinkdb of > 2.3.0 with username/password authorization, | ||
## protocol have to be named "rethinkdb2" - it will use 1_0 H. | ||
# servers = ["rethinkdb2://username:[email protected]:28015"] | ||
## | ||
## If you use older versions of rethinkdb (<2.2) with auth_key, protocol | ||
## have to be named "rethinkdb". | ||
# servers = ["rethinkdb://username:[email protected]:28015"] | ||
` | ||
|
||
func (r *RethinkDB) SampleConfig() string { | ||
|
@@ -75,8 +83,18 @@ func (r *RethinkDB) gatherServer(server *Server, acc telegraf.Accumulator) error | |
pwd, set := server.Url.User.Password() | ||
if set && pwd != "" { | ||
connectOpts.AuthKey = pwd | ||
connectOpts.HandshakeVersion = gorethink.HandshakeV0_4 | ||
} | ||
} | ||
if server.Url.Scheme == "rethinkdb2" && server.Url.User != nil { | ||
pwd, set := server.Url.User.Password() | ||
if set && pwd != "" { | ||
connectOpts.Username = server.Url.User.Username() | ||
connectOpts.Password = pwd | ||
connectOpts.HandshakeVersion = gorethink.HandshakeV1_0 | ||
} | ||
} | ||
|
||
server.session, err = gorethink.Connect(connectOpts) | ||
if err != nil { | ||
return fmt.Errorf("Unable to connect to RethinkDB, %s\n", err.Error()) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters