Skip to content

Instantly share code, notes, and snippets.

@namuan
Last active December 21, 2015 15:49
Show Gist options
  • Save namuan/6329179 to your computer and use it in GitHub Desktop.
Save namuan/6329179 to your computer and use it in GitHub Desktop.
Push JMeter reports to elastic search
Start elastic search
./bin/elasticsearch -f
Start logstash
Logstash configuration to process JMeter data
$ cat dlogs.conf
input {
stdin {
type => "stdin-type"
}
tcp {
format => "json"
port => 6379
type=>"capi"
}
}
filter {
date {
type => "capi"
match => [ "timeStamp", "ISO8601" ]
}
}
output {
stdout {
debug => true
}
elasticsearch {
host => '127.0.0.1'
}
}
- Generate CSV -> Pipe through csv2json
$ cat pipe2es.sh
#!/bin/bash
F=$1
test -e $F || exit 1
echo "Processing $F"
cat $F | c2j.groovy | nc localhost 6379
cat c2j.groovy
#!/usr/bin/env groovy
import groovy.json.JsonBuilder
// Read data from input stream
def headers
System.in.eachLine() { line ->
if (!headers) headers = line.split(',')
else println toJson(headers, line)
}
private def toJson(headers, line) {
def builder = new JsonBuilder()
def jsonObject = [:]
line.split(',').eachWithIndex { obj, i ->
jsonObject[headers[i]] = obj
}
builder(jsonObject)
return builder.toString()
}
- Run Jmeter
java -server -jar ./bin/ApacheJMeter.jar -p cmp.properties -n -t test.jmx -l logs/out-$(date "+%Y%m%d_%H%M%S").jtl
$ cat cmp.properties
jmeter.save.saveservice.output_format=csv
jmeter.save.saveservice.assertion_results_failure_message=true
jmeter.save.saveservice.timestamp_format=ms
jmeter.save.saveservice.timestamp_format=yyyy-MM-dd'T'HH:mm:ss.SSS'Z'
jmeter.save.saveservice.print_field_names=true
@ankur20us
Copy link

WARNING: Module [groovy-nio] - Unable to load extension class [org.codehaus.groovy.runtime.NioGroovyMethods]
I am getting this..
:(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment