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.
Configuration
The im_testgen module accepts the following directives in addition to the common module directives.
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 2023
This configuration generates ten events defined in the MaxCount
directive and pares 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>
MaxCount is 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 reached
This 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>