SPONSORS:






View RSS Feed

Ronak

Understanding JMeter Element- Access Log Sampler

Rate this Entry
by , 06-21-2015 at 02:13 AM (318 Views)
Understanding JMeter Element- Access Log Sampler

AccessLogSampler was designed to read access logs and generate http requests. For those not familiar with the access log, it is the log the webserver maintains of every request it accepted. This means every image, css file, javascript file, html file.... The current implementation is complete, but some features have not been enabled. There is a filter for the access log parser, but I haven't figured out how to link to the pre-processor. Once I do, changes to the sampler will be made to enable that functionality.

Tomcat uses the common format for access logs. This means any webserver that uses the common log format can use the AccessLogSampler. Server that use common log format include:

Tomcat, Resin, Weblogic, and SunOne. Common log format looks like this:
127.0.0.1 - - [21/Oct/2015:05:47:22 -0500] "GET /index.jsp?%2Findex.jsp= HTTP/1.1" 200 8343
The current implementation of the parser only looks at the text within the quotes that contains one of the HTTP protocol methods (GET, PUT, POST, DELETE...). Everything else is stripped out and ignored. For example, the response code is completely ignored by the parser.

For the future, it might be nice to filter out entries that do not have a response code of 200.

Extending the sampler should be fairly simple. There are two interfaces you have to implement:
org.apache.jmeter.protocol.http.util.accesslog.Log Parser
org.apache.jmeter.protocol.http.util.accesslog.Gen erator

The current implementation of AccessLogSampler uses the generator to create a new HTTPSampler.
The servername, port and get images are set by AccessLogSampler. Next, the parser is called with integer 1, telling it to parse one entry. After that, HTTPSampler.sample() is called to make the request.
samp = (HTTPSampler) GENERATOR.generateRequest();
samp.setDomain(this.getDomain());
samp.setPort(this.getPort());
samp.setImageParser(this.isImageParser());
PARSER.parse(1);
res = samp.sample();
res.setSampleLabel(samp.toString());

The required methods in LogParser are:
setGenerator(Generator)
parse(int)
Classes implementing Generator interface should provide concrete implementation for all the methods. For an example of how to implement either interface, refer to StandardGenerator and TCLogParser.

Parameters
Name- Descriptive name for this sampler that is shown in the tree.
Server- Domain name or IP address of the web server.
Port- Port the web server is listening to.
Log parser class- The log parser class is responsible for parsing the logs.
Filter- The filter class is used to filter out certain lines.
Location of log file- The location of the access log file.



Disclaimer: The article/post is posted with the purpose of sharing knowledge and information.
The article may contain references, extract or content from other informative sources.
Researched/Authored/Compiled by -
Ronak Shah
Practice Head - Software Testing (QA), CIGNEX Datamatics

vBulletin Optimisation provided by vB Optimise v2.6.0 Beta 4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.0.9 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Questions / Answers Form provided by vBAnswers (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominatevBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 09:21 AM.

Copyright BetaSoft Inc.