Track results of a regular expression extractor in JMeter - regex

Our server returns a custom 'X-Execution-Time' HTTP response header that returns in miliseconds the time between the server getting a request and our code returning a page, ie how long our code takes to run. I'm using JMeter to do some testing & I'd like to be able to report on this number of over time. I've setup this regular expression extractor: X-Execution-Time:\s(\d+) but I don't know how to get JMeter to report on this number per request so i can get a trend over time

This isn't elegant by any means, but it certainly works:
Add a debug sampler into your test plan, and give it the same name as your regex reference. This will write out the time value into the results file.
Example if you have different pages:
regex reference = X-Execution-Time
Debug Sampler Name = PageName - Execution: ${X-Execution-Time}

Related

Parse Days in Status field from Jira Cloud for Google Sheets

I am using Jira Cloud for Sheets Adds on in order to get Days in Status field from Jira, it seems to have the following syntax, from this post
<STATUS_ID>_*:*_<NUMBER_OF_TIMES_ISSUE_WAS_IN_THIS_STATUS>_*:*_<SECONDS>_*|
Here is an example:
10060_*:*_1_*:*_1121033406_*|*_3_*:*_1_*:*_7409_*|*_10000_*:*_1_*:*_270003163_*|*_10088_*:*_1_*:*_2595005_*|*_10087_*:*_1_*:*_1126144_*|*_10001_*:*_1_*:*_0
I am trying to extract for example how many times the issue was In QA status and the duration on a given status. I am dealing with parsing this pattern for obtaining this information and return it using an ARRAYFORMULA. Days in Status field information will be provided only when the issue was completed (is in Done status), otherwise, no information will be provided. if the issue is in Done status, but it didn't transition for a given status, this information will not be provided in the Days in Status string.
I am trying to use REGEXEXTRACT function to match a pattern for example:
=REGEXEXTRACT(C2, "(10060)_\*:\*_\d+_\*:\*_\d+_\*|")
and it returns an empty value, where I expect 10068. I brought my attention that when I use REGEXMATCH function it returns TRUE:
=REGEXMATCH(C2, "(10060)_\*:\*_\d+_\*:\*_\d+_\*|")
so the syntax is not clear. Google refers as a reference for Regular Expression to the following documentation. It seems to be an issue with the vertical bar |, per this documentation it is a special character that should be represented like this \v, but this doesn't work. The REGEXMATCH returns FALSE. I am trying to use some online RegEx tester, that implements Google Sheets syntax (RE2), I found ReGo, that I don't know if it is a valid one.
I was trying to use SPLITfunction like this:
=query(SPLIT(C2, "_*:*_"), "SELECT Col1")
but it seems to be a more complicated approach for getting all the values I need from Days in Status field string, but it separates well all the values from the previous pattern. In this case, I am getting the first Status ID. The number of columns returned by SPLITwill varies because it depends on the number of statuses the issues transitioned in order to get to DONE status.
It seems to be a complex task given all the issues I have encounter, but maybe some of you were dealing with this before and may advise about some ideas. It requires properly parsing the information and then extracting the information on specific columns using ARRAYFORMULA function when it applies for a given status from Status column.
Here is a google spreadsheet sample with the input information. I would like to populate the information for the following columns for Times In QA (C column) and Duration in QA (D column, the information is provided in seconds I would need in days but this is a minor task) for In QA status, then the same would apply for the rest of the other statuses. I added the tab Settings for mapping the Status ID to my Status, I would need to use a lookup function for matching the Status column in the Jira Issues tab. I would like to have a solution, without adding helper columns maybe it will require some script.
https://docs.google.com/spreadsheets/d/1ys6oiel1aJkQR9nfxWJsmEyd7XiNkVB-omcNL0ohckY/edit?usp=sharing
try:
=INDEX(IFERROR(1/(1/QUERY(1*IFNA(REGEXEXTRACT(C2:C, "10087.{5}(\d+).{5}(\d+)")),
"select Col1,Col2/86400 label Col2/86400''"))))
...so after we do REGEXEXTRACT some rows (which cannot be extracted from) will output as #N/A error so we wrap it into IFNA to remove those errors. then we multiply it by *1 to convert everything into numeric numbers (regex works & outputs always only plain text format). then we use QUERY to convert 2nd column into proper seconds in one go. at this point every row has some value so to get rid of zeros for rows we don't need (like row 2,3,5,8,9,etc) and keep the output numeric, we use IFERROR(1/(1/ wrapping. and finally, we use INDEX or ARRAYFORMULA to process our array.

How to know when elasticsearch is ready for query after adding new data?

I am trying to do some unit tests using elasticsearch. I first start by using the index API about 100 times to add new data to my index. Then I use the search API with aggs. The problem is if I don't pause for 1 second after adding data 100 times, I get random results. If I wait 1 second I always get the same result.
I'd rather not have to wait x amount of time in my tests, that seems like bad practice. Is there a way to know when the data is ready?
I am waiting until I get a success response from elasticsearch /index api already, but that is not enough it seems.
First I'd suggest you to index your documents with a single bulk query : it would save some time because of less http/tcp overhead.
To answer your question, you should consider using the refresh=true parameter (or wait_for) while indexing your 100 documents.
As stated in documentation, it would :
Refresh the relevant primary and replica shards (not the whole index)
immediately after the operation occurs, so that the updated document
appears in search results immediately
More about it here :
https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-refresh.html

Kibana search with regular expression not working

I am trying to find some logs in Kibana by using Regular Expressions. I am aware that Kibana doesn't support the "classical" RegEx, but rather Lucene Query Syntax. I have read through the documentation of it (https://www.elastic.co/guide/en/elasticsearch/reference/6.7/query-dsl-regexp-query.html#regexp-syntax) and imo my queries should work, but they don't.
Here is an example log entry that I want to target with my query:
Timings are: sync started at 2019-02-12 19:15:09.402; accounts
downloaded:+760ms/760ms; accounts data downloaded:+1221ms/1981ms;
categorization pushed:+0ms/1981ms; categorization
started:+131ms/2112ms; categorization completed:+123ms/2235ms; in
total:2235ms.
What I want to find in the end is all such log entries where the time of "categorization started" exceeds a certain threshold. However my queries fail already while just trying to approach the final query.
I get results when I query:
message:"/categorization started/"
But already when i modify it to:
message:/categorization started/
i get nothing. Any of the following attemps also give nothing:
message:/categorization\sstarted/
message:/.*categorization\sstarted.*/
message:/.*categorization.*started.*/
At this point I'm already lost - why do all these queries not match anything?
In my mind, the final query that should get what I want should be as follows (finding all entries where categorization started time was 10,000ms or more):
message:/.*categorization started:\+<10000-99999>ms.*/
It goes without saying that this of course also returns nothing, which doesn't surprise me when the above queries already fail.
Can anyone explain to me what I am doing wrong?
Thank you
I suggest you to use
message:*categorization started*

JMeter repeat Regular Expression extractor for all requests

I have a JMeter script that goes through a bunch of requests, each being different, GETs, POSTs and so on...
Each request returns a custom header from the server that has some numeric values in it. This header returns the actual processing time it took on the server side (without latency/http overhead)
I was able to add a Regular Expression Extractor to get that value from the header without any problems, however I would like this to be repeated for all the requests.
By using Debug Sampler I can see that the extractor only runs once, seems to be the last instance.
How can I have an extractor that runs all all requests and collects all the values from the header.
Bonus question. Finally I would love to be able to aggregate these values and get one average value.
Disclaimer: This other question is similar to mine but it doesn't explain how to actually do it in terms of the locations of the extractor and the debug sampler.
Track results of a regular expression extractor in JMeter
Thank you.
Just put Regular Expression Extractor at the same level as your HTTP Request samplers and it will be applied to all of them
See Scoping Rules User Manual entry for more detailed explanation.
With regards to value collection the best option is using Sample Variables property. Given you store your header value into a variable called ${foo} you can get it appended to jtl results file by adding the next line to the user.properties file:
sample_variables=foo
JMeter restart will be required to pick the property up. The other way (which doesn't require restart) is passing the property via -J command-line argument as
jmeter -Jsample_variables=foo -n -t test.jmx -l result.jtl
As the result you will get an extra column called foo in the .jtl results file and it will hold the ${foo} variable value for each Sampler. Upon test completion you will be able to open .jtl results file with MS Excel or equivalent and use AVERAGE function to get the value you're looking for.
See Apache JMeter Properties Customization Guide for more information on setting and amending various JMeter properties for Configuring JMeter according to your needs.
While Dmitri's answer is one way of doing it. But I wanted something different than each time exporting it into a file and post processing it...
I ended up doing this "manually"
By manually I mean I added a BSF Assertion with language = JavaScript and then wrote some JavaScript to do this:
Pull the value out of the header (if found)
Keep a record of total/count using variables
Updating a variable that shows the aggregate always
Add Debug Sampler to get easy access to the values after the test.
The following is the code that I used in the BSF Assertion:
var responseHeaders = prev.getResponseHeaders();
var xNodetasticRt = /x-nodetastic-rt: (\d+\.?\d*)/.exec(responseHeaders);
if (xNodetasticRt) {
var value = parseFloat(xNodetasticRt[1]);
vars.put("xNodetasticRt", value);
var total = parseFloat(vars.get("xNodetasticRt-Total"));
if (!total) {
total = 0.0;
}
total += value;
vars.put("xNodetasticRt-Total", total);
var count = parseFloat(vars.get("xNodetasticRt-Count"));
if (!count) {
count = 0;
}
count++;
vars.put("xNodetasticRt-Count", count);
vars.put("xNodetasticRt-Average", total / count);
}

Using VBScript to access C++ COM module

First time question asker - I have searched through the site for questions related to VBSCRIPT, C++, and COM. I have found a couple of threads that I do believe speak to my core question but I was not able to walk away with an absolute.
I have been tasked with writing an automation script for a trucking company that uses PCMIler (which is arguably the most pervasive commercial trip routing tool in the market). The product comes with a tool called PCMiler Connect. PCmiler connect offers various API's to query the database. One of those is COM.
PCMiler is written in C++. I'm trying to accomplish this with VBScript.
The problem I'm having is trying to execute a method that requires 1 argument to be passed by reference. The method takes 4 arguments. It uses 3 of them to calculate the distance in miles from 2 points. The 4th argument is the one passed by reference and the retval is the 'time' in minutes.
Set server = CreateObject("PCMServer.PCMServer")
region = Server.DefaultRegion
Dim dist 'dist is short for Distance
Dim minutes
Dim time
'First Example use standard CalcDistance //THIS FUNCTION WORKS JUST FINE.
dist = server.CalcDistance("63139","62025") 'the passed parameters are Zip Codes
Wscript.Echo "CalcDistance: " & (dist / 10) 'Echo the distance in miles
//THIS EXAMPLE DOES NOT WORK!!!!
'Third Example use CalcDistance3 with a Route Type of 'Practical' (which is the 3rd argument). Pass variable 'minutes' as the return variable.
'Third Example - version 1. Passing the variable 'minutes' by itself - no character to indicate it is being passed by reference.
dist = server.CalcDistance3("63139","37217",1,cLng(time))
I have read in some threads that C++ must return the retval as Variant. This function returns a Long Integer. I can't change this. When I read the log file for PCMiler connect I can see where the retval is being calculated and logged - but VBScript is not picking it up, or it is not being returned correctly?
Ultimately - I'd like to ask someone to tell me If I'm out of look for using VBScript due to the fact I can't alter the C++ method - or if I can find a way to get the value - please help. If not - can someone tell me a better option for what I need to do?
While I have successfully used VBA in Access - this needs to be an automated script running every 30 minutes. I understand Access is not something that can be run reliably as an automated service.
C#?
VB?
Thank you.