Skip to content

Commit 622170a

Browse files
Fixed merge
2 parents b7513c9 + 17baadf commit 622170a

File tree

2 files changed

+18
-129
lines changed

2 files changed

+18
-129
lines changed

README.md

Lines changed: 5 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ JMeter ElasticSearch Backend Listener is a JMeter plugin enabling you to send te
2222
<dependency>
2323
<groupId>io.github.delirius325</groupId>
2424
<artifactId>jmeter.backendlistener.elasticsearch</artifactId>
25-
<version>2.2.4</version>
25+
<version>2.2.5</version>
2626
</dependency>
2727
```
2828

@@ -31,119 +31,10 @@ Feel free to contribute by branching and making pull requests, or simply by sugg
3131

3232
## Screenshots
3333
### Configuration
34-
![screnshot1](https://image.ibb.co/kPMn2x/Screen_Shot_2018_03_21_at_9_58_25_AM.png "Screenshot of configuration")
34+
![screnshot1](https://cdn-images-1.medium.com/max/2000/1*iVb7mIp2dPg7zE4Ph3PrGQ.png "Screenshot of configuration")
35+
3536
### Sample Grafana dashboard
3637
![screnshot1](https://image.ibb.co/jW6LNx/Screen_Shot_2018_03_21_at_10_21_18_AM.png "Sample Grafana Dashboard")
3738

38-
## Sample ElasticSearch Index
39-
40-
```javascript
41-
{
42-
"template": "jmeter",
43-
"mappings": {
44-
"SampleResult": {
45-
"properties": {
46-
"AllThreads": {
47-
"type": "long"
48-
},
49-
"Assertions": {
50-
"properties": {
51-
"Failure": {
52-
"type": "boolean"
53-
},
54-
"FailureMessage": {
55-
"type": "text",
56-
"index": false
57-
},
58-
"Name": {
59-
"type": "text",
60-
"index": false
61-
}
62-
}
63-
},
64-
"BodySize": {
65-
"type": "long"
66-
},
67-
"Bytes": {
68-
"type": "long"
69-
},
70-
"ConnectTime": {
71-
"type": "long",
72-
"index": false
73-
},
74-
"ContentType": {
75-
"type": "text",
76-
"index": false
77-
},
78-
"DataType": {
79-
"type": "text",
80-
"index": false
81-
},
82-
"EndTime": {
83-
"type": "date",
84-
"format": "dateOptionalTime"
85-
},
86-
"ErrorCount": {
87-
"type": "long"
88-
},
89-
"GrpThreads": {
90-
"type": "long",
91-
"index": false
92-
},
93-
"IdleTime": {
94-
"type": "long"
95-
},
96-
"Latency": {
97-
"type": "long"
98-
},
99-
"ResponseCode": {
100-
"type": "text"
101-
},
102-
"ResponseMessage": {
103-
"type": "text",
104-
"index": false
105-
},
106-
"ResponseTime": {
107-
"type": "long"
108-
},
109-
"SampleCount": {
110-
"type": "long"
111-
},
112-
"SampleLabel": {
113-
"type": "keyword"
114-
},
115-
"StartTime": {
116-
"type": "date",
117-
"format": "dateOptionalTime"
118-
},
119-
"Success": {
120-
"type": "text",
121-
"index": false
122-
},
123-
"ThreadName": {
124-
"type": "keyword",
125-
"index": false
126-
},
127-
"URL": {
128-
"type": "keyword"
129-
},
130-
"Timestamp": {
131-
"type": "date",
132-
"format": "dateOptionalTime"
133-
},
134-
"NormalizedTimestamp": {
135-
"type": "date",
136-
"format": "dateOptionalTime",
137-
"index": false
138-
},
139-
"BuildNumber": {
140-
"type": "long"
141-
},
142-
"ElapsedTime": {
143-
"type": "date"
144-
}
145-
}
146-
}
147-
}
148-
}
149-
```
39+
### For more info
40+
For more information, here's a little [documentation](https://github.com/delirius325/jmeter-elasticsearch-backend-listener/wiki).

src/main/java/io/github/delirius325/jmeter/backendlistener/elasticsearch/ElasticsearchBackend.java

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -67,17 +67,18 @@ public Arguments getDefaultParameters() {
6767
@Override
6868
public void setupTest(BackendListenerContext context) throws Exception {
6969
try {
70-
String host = context.getParameter(ES_HOST);
71-
this.filters = new LinkedList<String>();
72-
int port = Integer.parseInt(context.getParameter(ES_PORT));
73-
this.index = context.getParameter(ES_INDEX).toLowerCase();
74-
this.bulkSize = Integer.parseInt(context.getParameter(ES_BULK_SIZE));
75-
this.timeoutMs = JMeterUtils.getPropDefault(ES_TIMEOUT_MS, DEFAULT_TIMEOUT_MS);
76-
this.buildNumber = (JMeterUtils.getProperty(ElasticsearchBackend.BUILD_NUMBER) != null && JMeterUtils.getProperty(ElasticsearchBackend.BUILD_NUMBER).trim() != "")
77-
? Integer.parseInt(JMeterUtils.getProperty(ElasticsearchBackend.BUILD_NUMBER)) : 0;
70+
String host = context.getParameter(ES_HOST);
71+
int port = Integer.parseInt(context.getParameter(ES_PORT));
72+
73+
this.filters = new LinkedList<String>();
74+
this.bulkRequestList = new LinkedList<String>();
75+
this.index = context.getParameter(ES_INDEX).toLowerCase();
76+
this.bulkSize = Integer.parseInt(context.getParameter(ES_BULK_SIZE));
77+
this.timeoutMs = JMeterUtils.getPropDefault(ES_TIMEOUT_MS, DEFAULT_TIMEOUT_MS);
78+
this.buildNumber = (JMeterUtils.getProperty(ElasticsearchBackend.BUILD_NUMBER) != null && JMeterUtils.getProperty(ElasticsearchBackend.BUILD_NUMBER).trim() != "") ? Integer.parseInt(JMeterUtils.getProperty(ElasticsearchBackend.BUILD_NUMBER)) : 0;
7879
this.client = RestClient.builder(new HttpHost(context.getParameter(ES_HOST), port, context.getParameter(ES_SCHEME)))
7980
.setRequestConfigCallback(requestConfigBuilder -> requestConfigBuilder.setConnectTimeout(5000)
80-
.setSocketTimeout((int) timeoutMs))
81+
.setSocketTimeout((int) timeoutMs))
8182
.setFailureListener(new RestClient.FailureListener() {
8283
@Override
8384
public void onFailure(HttpHost host) {
@@ -86,7 +87,7 @@ public void onFailure(HttpHost host) {
8687
})
8788
.setMaxRetryTimeoutMillis(60000)
8889
.build();
89-
this.bulkRequestList = new LinkedList<String>();
90+
9091
String[] filterArray = (context.getParameter(ES_SAMPLE_FILTER).contains(";")) ? context.getParameter(ES_SAMPLE_FILTER).split(";") : new String[] {context.getParameter(ES_SAMPLE_FILTER)};
9192
if(filterArray.length >= 1 && filterArray[0].trim() != "") {
9293
for (String filter : filterArray) {
@@ -125,11 +126,8 @@ public void handleSampleResults(List<SampleResult> results, BackendListenerConte
125126

126127
validSample = (context.getParameter(ES_TEST_MODE).trim().equals("error") && sr.isSuccessful()) ? false : true;
127128

128-
if(validSample) {
129-
Gson gson = new Gson();
130-
String json = gson.toJson(this.getElasticData(sr, context));
131-
this.bulkRequestList.add(json);
132-
}
129+
if(validSample)
130+
this.bulkRequestList.add(new Gson().toJson(this.getElasticData(sr, context)));
133131
}
134132

135133
if(this.bulkRequestList.size() >= this.bulkSize) {

0 commit comments

Comments
 (0)