Apache JMeter – threadGroupName Function

threadGroupName is an in-build function of Apache JMeter and its type is ‘Information’. This function simply returns the name of the thread group. By the way, JMeter in-build functions are divided into eight categories which are:

  1. Information
  2. Input
  3. Calculation
  4. Formatting
  5. Scripting
  6. Properties
  7. Variables
  8. Strings

Let’s discuss about threadGroupName function:

Syntax: ${__threadGroupName}

Type: Information

Purpose: To get the name of the thread group used in the JMeter script. If there are multiple thread groups under the same test plan with different names and the threadGroupName function is called by a thread then the function returns the name of the Thread Group to whom the thread belongs. Example: If there are 2 thread groups named TG01 and TG02 under the same test plan then ${__threadGroupName} will return the values for each thread like below:

Thread GroupNumber of ThreadsReturn Value
TG012${__threadGroupName} = TG01 // called by thread 1
${__threadGroupName} = TG01 // called by thread 2
TG024${__threadGroupName} = TG02 // called by thread 1
${__threadGroupName} = TG02 // called by thread 2
${__threadGroupName} = TG02 // called by thread 3
${__threadGroupName} = TG02 // called by thread 4

Input Argument: No input value can pass in the threadGroupName function.

Return Value: A string i.e. the name of the thread group.

Use: The threadGroupName function has a specific use. If you added a listener at the test plan level and have a similar transactions/requests name then you can append the threadGroupName function in the transaction/request name to differentiate the results.


  1. The threadGroupName function does not work in any Configuration elements (e.g. User Defined Variables) as these are run from a separate thread.
  2. It works only under the Thread Group level; not at the Test Plan level.

Related Functions:

  • getThreadGroup().getName(): You can use the below code in the JSR223 Sampler to get the name of the thread group.
  • Note: ctx is a variable to call JMeterContextClass.
log.info("Thread Name is: "+ctx.getThreadGroup().getName());

You may be interested:

Leave a Comment