Test Generator (im_testgen)
This module generates simple events for testing, with an incremented integer up to the number of events specified by the MaxCount directive.
| To examine the supported platforms, see the list of installation packages. | 
Configuration
The im_testgen module accepts the following directives in addition to the common module directives.
Optional directives
| The module will generate the defined number of events and then stop generating events. If you don’t specify this directive, or set it with a non-integer value, im_testgen will continue generating events until you stop NXLog Agent. MaxCount is a 64-bit unsigned integer and negative values are interpreted as such, therefore setting MaxCount to 18446744073709551615 or -1 is equivalent. | |
| When set to  | 
Examples
This configuration generates ten unstructured events defined in the MaxCount directive and then stops generating events.
<Input testgen>
   Module      im_testgen
   MaxCount    10
</Input>0@Mon Nov 13 16:14:53 2023
1@Mon Nov 13 16:14:53 2023
2@Mon Nov 13 16:14:53 2023
3@Mon Nov 13 16:14:53 2023
4@Mon Nov 13 16:14:53 2023
5@Mon Nov 13 16:14:53 2023
6@Mon Nov 13 16:14:53 2023
7@Mon Nov 13 16:14:53 2023
8@Mon Nov 13 16:14:53 2023
9@Mon Nov 13 16:14:53 2023This configuration generates ten events defined in the MaxCount directive and parses them into a JSON format as a structured output.
<Extension json>
   Module      xm_json
</Extension>
<Input testgen>
   Module      im_testgen
   MaxCount    10
   Exec        $Message=$raw_event; json->to_json();
</Input>{
  "SeverityValue":2,
  "EventTime":"2023-11-13T16:18:44.854580+00:00",
  "SourceName":"nxlog",
  "ProcessID":1,
  "EventReceivedTime":"2023-11-13T16:18:44.854580+00:00",
  "SourceModuleName":"testgen",
  "SourceModuleType":"im_testgen",
  "Hostname":"f691d53f3ad0",
  "Message":"1@Mon Nov 13 16:18:44 2023"
}This configuration generates ten events defined in the MaxCount directive. Then, the Schedule block restarts the module to start generating events again, going into a cycle of generating ten events every 5 seconds.
<Extension json>
    Module      xm_json
</Extension>
<Input testgen>
    Module      im_testgen
    MaxCount    10
    Exec        $Message=$raw_event; json->to_json();
    <Schedule>
        Every    5 sec
        Exec     module_restart();
    </Schedule>
</Input>| MaxCountis only reset on module restart starting from NXLog Agent version 6.2. | 
2023-11-13 16:26:08 INFO [im_testgen|testgen] maxcount 10 reached
2023-11-13 16:26:13 INFO [im_testgen|testgen] maxcount 10 reached
2023-11-13 16:26:18 INFO [im_testgen|testgen] maxcount 10 reached
2023-11-13 16:26:23 INFO [im_testgen|testgen] maxcount 10 reachedThis configuration generates a continuous event stream where the module waits for 100000 microseconds between generating events. It roughly equals to around ten events generated per second.
<Input testgen>
    Module    im_testgen
    Exec      sleep (100000);
</Input>This configuration generates a continuous event stream where the module waits randomly between 0 to 2000 microseconds within generating events.
<Input testgen>
    Module    im_testgen
    Exec      sleep (get_rand(2000));
</Input>MoreFields directiveThis configuration enables the MoreFields directive and adds 16 more fields to the payload, which are parsed into JSON.
<Extension json>
    Module        xm_json
</Extension>
<Input testgen>
    Module        im_testgen
    MoreFields    TRUE
    MaxCount      1
    Exec          to_json();
</Input>{
  "SeverityValue": 2,
  "EventTime": "2025-03-07 12:55:53",
  "EventReceivedTime": "2025-03-07 12:55:53",
  "EventID": 214074,
  "SourceModuleName": "i1",
  "Severity": "INFO",
  "MessageSourceAddress": "127.0.0.1",
  "AccountName": "NXLog",
  "TargetUserName": "NXLog",
  "TraceID": "AaaA-Bbbb-CccC",
  "SpanID": "DddD-EeeE-FffF",
  "TraceFlags": 214074,
  "Hostname": "maindeb12",
  "Message": "0@Fri Mar 07 14:55:53 2025",
  "CountField": 0,
  "ErrorCode": 0,
  "OtherMessage": "some other message",
  "SourceName": "nxlog",
  "ProcessID": 214074,
  "SourceModuleType": "im_testgen"
}