diff --git a/Godeps b/Godeps index 7d00bb78c..a9199e3ef 100644 --- a/Godeps +++ b/Godeps @@ -59,8 +59,8 @@ github.com/zensqlmonitor/go-mssqldb ffe5510c6fa5e15e6d983210ab501c815b56b363 golang.org/x/crypto dc137beb6cce2043eb6b5f223ab8bf51c32459f4 golang.org/x/net f2499483f923065a842d38eb4c7f1927e6fc6e6d golang.org/x/text 506f9d5c962f284575e88337e7d9296d27e729d3 -gopkg.in/dancannon/gorethink.v1 edc7a6a68e2d8015f5ffe1b2560eed989f8a45be gopkg.in/fatih/pool.v2 6e328e67893eb46323ad06f0e92cb9536babbabc +gopkg.in/gorethink/gorethink.v3 7ab832f7b65573104a555d84a27992ae9ea1f659 gopkg.in/mgo.v2 3f83fa5005286a7fe593b055f0d7771a7dce4655 gopkg.in/olivere/elastic.v5 ee3ebceab960cf68ab9a89ee6d78c031ef5b4a4e gopkg.in/yaml.v2 4c78c975fe7c825c6d1466c42be594d1d6f3aba6 diff --git a/etc/telegraf.conf b/etc/telegraf.conf index c7691666d..a02c6a12f 100644 --- a/etc/telegraf.conf +++ b/etc/telegraf.conf @@ -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:password@127.0.0.1:28015"] +# ## +# ## If you use older versions of rethinkdb (<2.2) with auth_key, protocol +# ## have to be named "rethinkdb". +# servers = ["rethinkdb://username:auth_key@127.0.0.1:28015"] + + + # # Read metrics one or many Riak servers diff --git a/plugins/inputs/rethinkdb/rethinkdb.go b/plugins/inputs/rethinkdb/rethinkdb.go index e32f79731..dc6b03620 100644 --- a/plugins/inputs/rethinkdb/rethinkdb.go +++ b/plugins/inputs/rethinkdb/rethinkdb.go @@ -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:password@127.0.0.1:28015"] + ## + ## If you use older versions of rethinkdb (<2.2) with auth_key, protocol + ## have to be named "rethinkdb". + # servers = ["rethinkdb://username:auth_key@127.0.0.1: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()) diff --git a/plugins/inputs/rethinkdb/rethinkdb_server.go b/plugins/inputs/rethinkdb/rethinkdb_server.go index f172717d1..a04206d32 100644 --- a/plugins/inputs/rethinkdb/rethinkdb_server.go +++ b/plugins/inputs/rethinkdb/rethinkdb_server.go @@ -11,7 +11,7 @@ import ( "github.com/influxdata/telegraf" - "gopkg.in/dancannon/gorethink.v1" + "gopkg.in/gorethink/gorethink.v3" ) type Server struct { diff --git a/plugins/inputs/rethinkdb/rethinkdb_test.go b/plugins/inputs/rethinkdb/rethinkdb_test.go index 85c747f42..fa2cc92f2 100644 --- a/plugins/inputs/rethinkdb/rethinkdb_test.go +++ b/plugins/inputs/rethinkdb/rethinkdb_test.go @@ -10,10 +10,10 @@ import ( "testing" "time" - "gopkg.in/dancannon/gorethink.v1" + "gopkg.in/gorethink/gorethink.v3" ) -var connect_url, authKey string +var connect_url, authKey, username, password string var server *Server func init() { @@ -22,17 +22,31 @@ func init() { connect_url = "127.0.0.1:28015" } authKey = os.Getenv("RETHINKDB_AUTHKEY") - + username = os.Getenv("RETHINKDB_USERNAME") + password = os.Getenv("RETHINKDB_PASSWORD") } func testSetup(m *testing.M) { var err error server = &Server{Url: &url.URL{Host: connect_url}} - server.session, _ = gorethink.Connect(gorethink.ConnectOpts{ - Address: server.Url.Host, - AuthKey: authKey, - DiscoverHosts: false, - }) + + if authKey { + server.session, _ = gorethink.Connect(gorethink.ConnectOpts{ + Address: server.Url.Host, + AuthKey: authKey, + HandshakeVersion: gorethink.HandshakeV0_4, + DiscoverHosts: false, + }) + } else { + server.session, _ = gorethink.Connect(gorethink.ConnectOpts{ + Address: server.Url.Host, + Username: username, + Password: password, + HandshakeVersion: gorethink.HandshakeV1_0, + DiscoverHosts: false, + }) + } + if err != nil { log.Fatalln(err.Error()) }