Debugging
Monitoring commands
$ redis-cli -h myservice.redis.mycompany.com monitor
1515185542.880199 [0 1.1.1.1:34578] "hget" "somekey" "-1566720763"
1515185548.931294 [0 1.1.1.1:47306] "exists" "anotherkey"$ redis-cli -h myservice.redis.mycompany.com monitor > redis-logs.txtimport java.text.DateFormat
import java.text.SimpleDateFormat
import java.time.Duration
println "Starting..."
File file = new File("/Users/ondrej/Documents/redis-logs.txt")
println "File exits: ${file.exists()}"
boolean firstLineRead = true
String firstLine
String lastLine
int lineCount = 0
Map<String, Integer> aggregator = [:]
file.eachLine { String it ->
if (it.contains(']')) {
if (firstLineRead) {
String[] split = it.split('\\[')
firstLine = split[0]
firstLineRead = false
}
String[] split = it.split(']')
String raw = split[1].trim().replaceAll('"', '')
String[] commands = raw.split(' ')
String command = commands[0]
if (aggregator.containsKey(command)) {
Integer value = aggregator.get(command)
aggregator.put(command, value + 1)
} else {
aggregator.put(command, 1)
}
lineCount++
}
}
DateFormat df = new SimpleDateFormat("ss.SSSSSSS")
int lastLineCounter = 0
file.eachLine { String it ->
if (it.contains('[')) {
if (it.contains('keys')) { // there are too many keys called, lets debug and see more about those
String[] split = it.split('\\[')
String date = split[0]
println df.parse(date).toString() + ' ' + it
}
if (lineCount - 1 == lastLineCounter) {
String[] split = it.split('\\[')
lastLine = split[0]
}
lastLineCounter++
}
}
println 'Line Count: ' + lineCount
println 'Duration: ' + Duration.between(df.parse(firstLine).toInstant(), df.parse(lastLine).toInstant())
println 'From: ' + df.parse(firstLine).toInstant()
println 'To: ' + df.parse(lastLine).toInstant()
println 'Aggregated: ' + aggregatorStatus of Redis
How many keys is there
Find slow commands
Latency
Last updated