Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion collector/plugins/mongodb/mongodb.go
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ func (m *MongoDB) collectReplSetGetStatus(session Session, tags *[]string, agg m
replSet := bson.M{}
var primary, current ReplSetMember

// find nodes: master and current node (ourself)
// find nodes: main and current node (ourself)
for _, member := range replStatus.Members {
if member.Self {
current = member
Expand Down
4 changes: 2 additions & 2 deletions collector/plugins/mysql/mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,8 @@ var (
}

replicaVars = map[string]metric.Field{
"Seconds_Behind_Master": {"mysql.replication.seconds_behind_master", gauge},
"Slaves_connected": {"mysql.replication.slaves_connected", count},
"Seconds_Behind_Main": {"mysql.replication.seconds_behind_main", gauge},
"Subordinates_connected": {"mysql.replication.subordinates_connected", count},
}

syntheticVars = map[string]metric.Field{
Expand Down
10 changes: 5 additions & 5 deletions collector/plugins/mysql/mysql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ Per second averages calculated from the last 11 seconds
-----------------
BACKGROUND THREAD
-----------------
srv_master_thread loops: 1 1_second, 1 sleeps, 0 10_second, 1 background, 1 flush
srv_master_thread log flush and writes: 1
srv_main_thread loops: 1 1_second, 1 sleeps, 0 10_second, 1 background, 1 flush
srv_main_thread log flush and writes: 1
----------
SEMAPHORES
----------
Expand Down Expand Up @@ -240,8 +240,8 @@ Per second averages calculated from the last 25 seconds
-----------------
BACKGROUND THREAD
-----------------
srv_master_thread loops: 552 srv_active, 0 srv_shutdown, 376657 srv_idle
srv_master_thread log flush and writes: 377209
srv_main_thread loops: 552 srv_active, 0 srv_shutdown, 376657 srv_idle
srv_main_thread log flush and writes: 377209
----------
SEMAPHORES
----------
Expand Down Expand Up @@ -438,7 +438,7 @@ func TestCollectMetrics(t *testing.T) {
"mysql.performance.threads_cached": float64(1),
"mysql.performance.threads_connected": float64(1),
"mysql.performance.threads_running": float64(1),
// "mysql.replication.slave_running": float64(0),
// "mysql.replication.subordinate_running": float64(0),
}
tags := []string{"env:production"}
for name, value := range fields {
Expand Down
52 changes: 26 additions & 26 deletions collector/plugins/redis/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ var (

// Network
"connected_clients": "redis.net.clients",
"connected_slaves": "redis.net.slaves",
"connected_subordinates": "redis.net.subordinates",
"rejected_connections": "redis.net.rejected",

// clients
Expand Down Expand Up @@ -85,12 +85,12 @@ var (
"used_memory_rss": "redis.mem.rss",

// replication
"master_last_io_seconds_ago": "redis.replication.last_io_seconds_ago",
"master_sync_in_progress": "redis.replication.sync",
"master_sync_left_bytes": "redis.replication.sync_left_bytes",
"main_last_io_seconds_ago": "redis.replication.last_io_seconds_ago",
"main_sync_in_progress": "redis.replication.sync",
"main_sync_left_bytes": "redis.replication.sync_left_bytes",
"repl_backlog_histlen": "redis.replication.backlog_histlen",
"master_repl_offset": "redis.replication.master_repl_offset",
"slave_repl_offset": "redis.replication.slave_repl_offset",
"main_repl_offset": "redis.replication.main_repl_offset",
"subordinate_repl_offset": "redis.replication.subordinate_repl_offset",
}

// RATES XXX
Expand Down Expand Up @@ -242,8 +242,8 @@ func (r *Redis) collectDBMetrics(key, value string, tags []string, agg metric.Ag
}

func (r *Redis) collectReplicaMetrics(lines, tags []string, agg metric.Aggregator) {
var masterDownSeconds, masterOffset, slaveOffset float64
var masterStatus, slaveID, ip, port string
var mainDownSeconds, mainOffset, subordinateOffset float64
var mainStatus, subordinateID, ip, port string
var err error
for _, line := range lines {
record := strings.SplitN(line, ":", 2)
Expand All @@ -252,62 +252,62 @@ func (r *Redis) collectReplicaMetrics(lines, tags []string, agg metric.Aggregato
}
key, value := record[0], record[1]

if key == "master_repl_offset" {
masterOffset, _ = strconv.ParseFloat(value, 64)
if key == "main_repl_offset" {
mainOffset, _ = strconv.ParseFloat(value, 64)
}

if key == "master_link_down_since_seconds" {
masterDownSeconds, _ = strconv.ParseFloat(value, 64)
if key == "main_link_down_since_seconds" {
mainDownSeconds, _ = strconv.ParseFloat(value, 64)
}

if key == "master_link_status" {
masterStatus = value
if key == "main_link_status" {
mainStatus = value
}

if re, _ := regexp.MatchString(`^slave\d+`, key); re {
slaveID = strings.TrimPrefix(key, "slave")
if re, _ := regexp.MatchString(`^subordinate\d+`, key); re {
subordinateID = strings.TrimPrefix(key, "subordinate")
kv := strings.SplitN(value, ",", 5)
if len(kv) != 5 {
continue
}

split := strings.Split(kv[0], "=")
if len(split) != 2 {
log.Warnf("Failed to parse slave ip. %s", err)
log.Warnf("Failed to parse subordinate ip. %s", err)
continue
}
ip = split[1]

split = strings.Split(kv[1], "=")
if err != nil {
log.Warnf("Failed to parse slave port. %s", err)
log.Warnf("Failed to parse subordinate port. %s", err)
continue
}
port = split[1]

split = strings.Split(kv[3], "=")
if err != nil {
log.Warnf("Failed to parse slave offset. %s", err)
log.Warnf("Failed to parse subordinate offset. %s", err)
continue
}
slaveOffset, _ = strconv.ParseFloat(split[1], 64)
subordinateOffset, _ = strconv.ParseFloat(split[1], 64)
}
}

delay := masterOffset - slaveOffset
slaveTags := append(tags, "slave_ip:"+ip, "slave_port:"+port, "slave_id:"+slaveID)
delay := mainOffset - subordinateOffset
subordinateTags := append(tags, "subordinate_ip:"+ip, "subordinate_port:"+port, "subordinate_id:"+subordinateID)
if delay >= 0 {
agg.Add("gauge", metric.Metric{
Name: "redis.replication.delay",
Value: delay,
Tags: slaveTags,
Tags: subordinateTags,
})
}

if masterStatus != "" {
if mainStatus != "" {
agg.Add("gauge", metric.Metric{
Name: "redis.replication.master_link_down_since_seconds",
Value: masterDownSeconds,
Name: "redis.replication.main_link_down_since_seconds",
Value: mainDownSeconds,
Tags: tags,
})
}
Expand Down
18 changes: 9 additions & 9 deletions collector/plugins/redis/redis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,10 @@ latest_fork_usec:903
migrate_cached_sockets:0

# Replication
role:master
connected_slaves:1
slave0:ip=172.17.0.3,port=6379,state=online,offset=53445,lag=1
master_repl_offset:53445
role:main
connected_subordinates:1
subordinate0:ip=172.17.0.3,port=6379,state=online,offset=53445,lag=1
main_repl_offset:53445
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:2
Expand Down Expand Up @@ -223,7 +223,7 @@ func TestCollectMetrics(t *testing.T) {

// Network
"redis.net.clients": 3,
"redis.net.slaves": 1,
"redis.net.subordinates": 1,
"redis.net.rejected": 0,

// clients
Expand Down Expand Up @@ -259,9 +259,9 @@ func TestCollectMetrics(t *testing.T) {
// "redis.replication.sync": 0,
// "redis.replication.sync_left_bytes": 0,
"redis.replication.backlog_histlen": 53444,
"redis.replication.master_repl_offset": 53445,
// "redis.replication.slave_repl_offset": 0,
// "redis.replication.master_link_down_since_seconds": 0,
"redis.replication.main_repl_offset": 53445,
// "redis.replication.subordinate_repl_offset": 0,
// "redis.replication.main_link_down_since_seconds": 0,
}
tags := []string{"service:redis"}
for name, value := range fields {
Expand All @@ -280,7 +280,7 @@ func TestCollectMetrics(t *testing.T) {
}

// replication
tags = []string{"service:redis", "slave_ip:172.17.0.3", "slave_port:6379", "slave_id:0"}
tags = []string{"service:redis", "subordinate_ip:172.17.0.3", "subordinate_port:6379", "subordinate_id:0"}
testutil.AssertContainsMetricWithTags(t, metrics, "redis.replication.delay", 0, tags)

// keys
Expand Down
12 changes: 6 additions & 6 deletions vendor/github.com/docker/docker/api/types/mount/mount.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/github.com/rafaeljusto/redigomock/redigomock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading