Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MongoDB plugin always shows 0 replication lag #1449

Closed
lassizci opened this issue Jul 4, 2016 · 9 comments
Closed

MongoDB plugin always shows 0 replication lag #1449

lassizci opened this issue Jul 4, 2016 · 9 comments
Labels
bug unexpected problem or unintended behavior
Milestone

Comments

@lassizci
Copy link

lassizci commented Jul 4, 2016

Bug report

Relevant telegraf.conf:

[[inputs.mongodb]]
  servers = ["127.0.0.1:27017"]

System info:

telegraf 1.0.0-beta2
mongodb 3.2.7

repl_lag seems to always output 0i even though there's replication lag on the secondaries. I've been monitoring this through mongodb cloud. I do get all the other metrics pretty much as expected.

@apinyarr
Copy link

+1

@im-vincent
Copy link
Contributor

Use two configuration files

/usr/bin/telegraf -config-directory /etc/telegraf/telegraf.d

vi rs0-0.conf
[[inputs.mongodb]]
  servers = ["8.8.8.8:27017"]
#PRIMARY

vi rs0-1.conf
[[inputs.mongodb]]
  servers = ["8.8.8.8:27018"]
#SECONDARY

Modify the mongostat.go

-	"gopkg.in/mgo.v2/bson"

 type ReplSetMember struct {
-	Name       string               `bson:"name"`
-	State      int64                `bson:"state"`
-	OptimeDate *bson.MongoTimestamp `bson:"optimeDate"`
+	Name       string    `bson:"name"`
+	State      int64     `bson:"state"`
+	OptimeDate time.Time `bson:"optimeDate"`
 }

-		if me.OptimeDate != nil && master.OptimeDate != nil && me.State == 2 {
+		if me.State == 2 {
 			// MongoTimestamp type is int64 where the first 32bits are the unix timestamp
-			lag := int64(*master.OptimeDate>>32 - *me.OptimeDate>>32)
+			lag := master.OptimeDate.Unix() - me.OptimeDate.Unix()

From Source:

Telegraf manages dependencies via gdm, which gets installed via the Makefile if you don't have it already. You also must build with golang version 1.5+.

Install Go
Setup your GOPATH
Run go get github.com/influxdata/telegraf
Run cd $GOPATH/src/github.com/influxdata/telegraf
Run make

@sparrc
Copy link
Contributor

sparrc commented Dec 1, 2016

@im-vincent could you submit a PR?

@sparrc sparrc added the bug unexpected problem or unintended behavior label Dec 1, 2016
@im-vincent
Copy link
Contributor

I have already submit a PR as https://github.com/im-vincent/telegraf/

@sparrc
Copy link
Contributor

sparrc commented Dec 2, 2016

@im-vincent I haven't received a PR

@im-vincent
Copy link
Contributor

PR #2125

Is that right?

@sparrc
Copy link
Contributor

sparrc commented Dec 16, 2016

closed by #2125

@1medusa1
Copy link

1medusa1 commented Sep 19, 2018

Downloaded the rpm straight from influxdb and this is not working: version 1.7.4

@umit1ekinoglu
Copy link

Also having issue this is my configuration one configuration file telegraf.conf input plugin content part below:

[[inputs.mongodb]] # PRIMARY
servers = ["mongodb://telegraf:telegraf@localhost:27017/?replicaSet=s0&authSource=admin"]

[[inputs.mongodb]] # SECONDARY
servers = ["mongodb://telegraf:[email protected]:27017/?replicaSet=s0&authSource=admin"]

[[inputs.mongodb]] # SECONDARY
servers = ["mongodb://telegraf:[email protected]:27017/?replicaSet=s0&authSource=admin"]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

6 participants