# Push Events to Statistics Server

There are several ways to push event information to a Statistics Server.

- Use a third-party front end that can generate and send events.
- Write a script to generate and send the events. The Statistics Server installation includes an example Perl script that monitors an IDOL log file (such as an IDOL Content component query log) and sends events to the Statistics Server. The script is named `stats-query.pl`. It runs independently of the component being monitored and of Statistics Server (neither component runs the script, you must start and stop it yourself). For information about how to use this script, see Use the Example Perl Scripts.

There are several types of event that you might want to monitor that are specific to QMS. For example, you might want to gather statistics about the promotion or synonym rules that have been used to manipulate queries. You can push this type of event information to a Statistics Server in the following ways:

- (Recommended method) Use the document tracking feature, with the Lua library and a Lua script, to send the events. The QMS installation includes an example Lua script named `qms-rules-statsserver.lua`, in the `scripts` directory. For information about how to send events through document tracking, see Use Document Tracking (QMS events only).
- Write a script to generate and send the events. The Statistics Server installation includes an example Perl script that monitors a QMS log file and sends information about promotion, synonym, and other events. This script should be used to monitor the log file that receives messages from the `events` log stream (`LogTypeCSVs=events`). The script is named `stats-qms-rules.pl`. However, Micro Focus recommends that you use the document tracking feature instead because document tracking runs as part of QMS. If you use the Perl script you must start or stop the script yourself, because it runs as a separate process.
- Configure the host and port of the Statistics Server in the `[StatisticsServer]` section of the QMS configuration file. Micro Focus recommends that you use the document tracking feature instead because it captures additional event types that are not supported using this method.

The following XML is an example event that might be pushed to the Statistics Server event port.

    <?xml version='1.0' encoding='ISO-8859-1' ?>
    <events>
      <queryinfo>
        <ver>0.1</ver>
        <id>10385792</id>
        <url>
         <![CDATA[http://content:19352/action=query&text=dog&numhits=6]]>
        </url>
        <action>query</action>
        <terms>
          <term>dog1</term>
        </terms>
        <duration>10</duration>
        <numhits>5</numhits>
        <type>16</type>
        <user>user_name</user>
        <ip>127.0.0.1</ip>
      </queryinfo>
    </events>

In this example, any of the fields in the `<queryinfo>` tag can be used for computing statistics.

_FT_HTML5_bannerTitle.htm