@@ -999,8 +999,8 @@ func oplogStatus(ctx context.Context, client *mongo.Client) ([]prometheus.Metric
999
999
return []prometheus.Metric {headMetric , tailMetric }, nil
1000
1000
}
1001
1001
1002
- func replSetMetrics (m bson.M ) []prometheus.Metric {
1003
- replSetGetStatus , ok := m ["replSetGetStatus" ].(bson.M )
1002
+ func replSetMetrics (d bson.M ) []prometheus.Metric {
1003
+ replSetGetStatus , ok := d ["replSetGetStatus" ].(bson.M )
1004
1004
if ! ok {
1005
1005
return nil
1006
1006
}
@@ -1021,7 +1021,7 @@ func replSetMetrics(m bson.M) []prometheus.Metric {
1021
1021
for _ , m := range repl .Members {
1022
1022
if m .StateStr == "PRIMARY" {
1023
1023
primaryOpTime = m .OptimeDate .Time ()
1024
- gotPrimary = ! primaryOpTime .IsZero ()
1024
+ gotPrimary = primaryOpTime .Unix () != 0
1025
1025
1026
1026
break
1027
1027
}
@@ -1044,20 +1044,19 @@ func replSetMetrics(m bson.M) []prometheus.Metric {
1044
1044
"name" : m .Name ,
1045
1045
"state" : m .StateStr ,
1046
1046
"set" : repl .Set ,
1047
+ "self" : "0" ,
1047
1048
}
1048
1049
if m .Self {
1049
- createMetric ("my_name" , "The replica state name of the current member." , 1 , map [string ]string {
1050
- "name" : m .Name ,
1051
- "set" : repl .Set ,
1052
- })
1050
+ labels ["self" ] = "1"
1051
+ createMetric ("my_name" , "The replica state name of the current member." , 1 , labels )
1053
1052
}
1054
1053
1055
1054
if ! m .ElectionTime .IsZero () {
1056
1055
createMetric ("member_election_date" ,
1057
1056
"The timestamp the node was elected as replica leader" ,
1058
1057
float64 (m .ElectionTime .T ), labels )
1059
1058
}
1060
- if t := m .OptimeDate .Time (); gotPrimary && ! t . IsZero () && m .StateStr != "PRIMARY" {
1059
+ if t := m .OptimeDate .Time (); gotPrimary && t . Unix () != 0 && m .StateStr != "PRIMARY" {
1061
1060
val := math .Abs (float64 (t .Unix () - primaryOpTime .Unix ()))
1062
1061
createMetric ("member_replication_lag" ,
1063
1062
"The replication lag that this member has with the primary." ,
0 commit comments