Add commands stats to mongodb input plugin (#6905)
This commit is contained in:
committed by
GitHub
parent
ba138b8f5b
commit
3e1c7a8948
@@ -165,6 +165,35 @@ func TestAddLatencyStats(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestAddCommandsStats(t *testing.T) {
|
||||
d := NewMongodbData(
|
||||
&StatLine{
|
||||
DeleteCommandTotal: 73,
|
||||
DeleteCommandFailed: 364,
|
||||
FindCommandTotal: 113,
|
||||
FindCommandFailed: 201,
|
||||
FindAndModifyCommandTotal: 7,
|
||||
FindAndModifyCommandFailed: 55,
|
||||
GetMoreCommandTotal: 4,
|
||||
GetMoreCommandFailed: 55,
|
||||
InsertCommandTotal: 34,
|
||||
InsertCommandFailed: 65,
|
||||
UpdateCommandTotal: 23,
|
||||
UpdateCommandFailed: 6,
|
||||
},
|
||||
tags,
|
||||
)
|
||||
|
||||
var acc testutil.Accumulator
|
||||
|
||||
d.AddDefaultStats()
|
||||
d.flush(&acc)
|
||||
|
||||
for key := range DefaultCommandsStats {
|
||||
assert.True(t, acc.HasInt64Field("mongodb", key))
|
||||
}
|
||||
}
|
||||
|
||||
func TestAddShardHostStats(t *testing.T) {
|
||||
expectedHosts := []string{"hostA", "hostB"}
|
||||
hostStatLines := map[string]ShardHostStatLine{}
|
||||
@@ -225,72 +254,84 @@ func TestStateTag(t *testing.T) {
|
||||
d.AddDefaultStats()
|
||||
d.flush(&acc)
|
||||
fields := map[string]interface{}{
|
||||
"active_reads": int64(0),
|
||||
"active_writes": int64(0),
|
||||
"commands": int64(0),
|
||||
"commands_per_sec": int64(0),
|
||||
"deletes": int64(0),
|
||||
"deletes_per_sec": int64(0),
|
||||
"flushes": int64(0),
|
||||
"flushes_per_sec": int64(0),
|
||||
"flushes_total_time_ns": int64(0),
|
||||
"getmores": int64(0),
|
||||
"getmores_per_sec": int64(0),
|
||||
"inserts": int64(0),
|
||||
"inserts_per_sec": int64(0),
|
||||
"member_status": "PRI",
|
||||
"state": "PRIMARY",
|
||||
"net_in_bytes_count": int64(0),
|
||||
"net_in_bytes": int64(0),
|
||||
"net_out_bytes_count": int64(0),
|
||||
"net_out_bytes": int64(0),
|
||||
"open_connections": int64(0),
|
||||
"queries": int64(0),
|
||||
"queries_per_sec": int64(0),
|
||||
"queued_reads": int64(0),
|
||||
"queued_writes": int64(0),
|
||||
"repl_commands": int64(0),
|
||||
"repl_commands_per_sec": int64(0),
|
||||
"repl_deletes": int64(0),
|
||||
"repl_deletes_per_sec": int64(0),
|
||||
"repl_getmores": int64(0),
|
||||
"repl_getmores_per_sec": int64(0),
|
||||
"repl_inserts": int64(0),
|
||||
"repl_inserts_per_sec": int64(0),
|
||||
"repl_queries": int64(0),
|
||||
"repl_queries_per_sec": int64(0),
|
||||
"repl_updates": int64(0),
|
||||
"repl_updates_per_sec": int64(0),
|
||||
"repl_lag": int64(0),
|
||||
"resident_megabytes": int64(0),
|
||||
"updates": int64(0),
|
||||
"updates_per_sec": int64(0),
|
||||
"uptime_ns": int64(0),
|
||||
"vsize_megabytes": int64(0),
|
||||
"ttl_deletes": int64(0),
|
||||
"ttl_deletes_per_sec": int64(0),
|
||||
"ttl_passes": int64(0),
|
||||
"ttl_passes_per_sec": int64(0),
|
||||
"jumbo_chunks": int64(0),
|
||||
"total_in_use": int64(0),
|
||||
"total_available": int64(0),
|
||||
"total_created": int64(0),
|
||||
"total_refreshing": int64(0),
|
||||
"cursor_timed_out": int64(0),
|
||||
"cursor_timed_out_count": int64(0),
|
||||
"cursor_no_timeout": int64(0),
|
||||
"cursor_no_timeout_count": int64(0),
|
||||
"cursor_pinned": int64(0),
|
||||
"cursor_pinned_count": int64(0),
|
||||
"cursor_total": int64(0),
|
||||
"cursor_total_count": int64(0),
|
||||
"document_deleted": int64(0),
|
||||
"document_inserted": int64(0),
|
||||
"document_returned": int64(0),
|
||||
"document_updated": int64(0),
|
||||
"connections_current": int64(0),
|
||||
"connections_available": int64(0),
|
||||
"connections_total_created": int64(0),
|
||||
"active_reads": int64(0),
|
||||
"active_writes": int64(0),
|
||||
"commands": int64(0),
|
||||
"commands_per_sec": int64(0),
|
||||
"deletes": int64(0),
|
||||
"deletes_per_sec": int64(0),
|
||||
"flushes": int64(0),
|
||||
"flushes_per_sec": int64(0),
|
||||
"flushes_total_time_ns": int64(0),
|
||||
"getmores": int64(0),
|
||||
"getmores_per_sec": int64(0),
|
||||
"inserts": int64(0),
|
||||
"inserts_per_sec": int64(0),
|
||||
"member_status": "PRI",
|
||||
"state": "PRIMARY",
|
||||
"net_in_bytes_count": int64(0),
|
||||
"net_in_bytes": int64(0),
|
||||
"net_out_bytes_count": int64(0),
|
||||
"net_out_bytes": int64(0),
|
||||
"open_connections": int64(0),
|
||||
"queries": int64(0),
|
||||
"queries_per_sec": int64(0),
|
||||
"queued_reads": int64(0),
|
||||
"queued_writes": int64(0),
|
||||
"repl_commands": int64(0),
|
||||
"repl_commands_per_sec": int64(0),
|
||||
"repl_deletes": int64(0),
|
||||
"repl_deletes_per_sec": int64(0),
|
||||
"repl_getmores": int64(0),
|
||||
"repl_getmores_per_sec": int64(0),
|
||||
"repl_inserts": int64(0),
|
||||
"repl_inserts_per_sec": int64(0),
|
||||
"repl_queries": int64(0),
|
||||
"repl_queries_per_sec": int64(0),
|
||||
"repl_updates": int64(0),
|
||||
"repl_updates_per_sec": int64(0),
|
||||
"repl_lag": int64(0),
|
||||
"resident_megabytes": int64(0),
|
||||
"updates": int64(0),
|
||||
"updates_per_sec": int64(0),
|
||||
"uptime_ns": int64(0),
|
||||
"vsize_megabytes": int64(0),
|
||||
"ttl_deletes": int64(0),
|
||||
"ttl_deletes_per_sec": int64(0),
|
||||
"ttl_passes": int64(0),
|
||||
"ttl_passes_per_sec": int64(0),
|
||||
"jumbo_chunks": int64(0),
|
||||
"total_in_use": int64(0),
|
||||
"total_available": int64(0),
|
||||
"total_created": int64(0),
|
||||
"total_refreshing": int64(0),
|
||||
"cursor_timed_out": int64(0),
|
||||
"cursor_timed_out_count": int64(0),
|
||||
"cursor_no_timeout": int64(0),
|
||||
"cursor_no_timeout_count": int64(0),
|
||||
"cursor_pinned": int64(0),
|
||||
"cursor_pinned_count": int64(0),
|
||||
"cursor_total": int64(0),
|
||||
"cursor_total_count": int64(0),
|
||||
"document_deleted": int64(0),
|
||||
"document_inserted": int64(0),
|
||||
"document_returned": int64(0),
|
||||
"document_updated": int64(0),
|
||||
"connections_current": int64(0),
|
||||
"connections_available": int64(0),
|
||||
"connections_total_created": int64(0),
|
||||
"delete_command_total": int64(0),
|
||||
"delete_command_failed": int64(0),
|
||||
"find_command_total": int64(0),
|
||||
"find_command_failed": int64(0),
|
||||
"find_and_modify_command_total": int64(0),
|
||||
"find_and_modify_command_failed": int64(0),
|
||||
"get_more_command_total": int64(0),
|
||||
"get_more_command_failed": int64(0),
|
||||
"insert_command_total": int64(0),
|
||||
"insert_command_failed": int64(0),
|
||||
"update_command_total": int64(0),
|
||||
"update_command_failed": int64(0),
|
||||
}
|
||||
acc.AssertContainsTaggedFields(t, "mongodb", fields, stateTags)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user