> ## Documentation Index
> Fetch the complete documentation index at: https://docs.abbyy.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Configuring the Reporting Service

> Create the reporting database, set up the data access component, switch databases, and enable the ABBYY FlexiCapture 12 Reporting Service for tenants.

## Configuring the ABBYY FlexiCapture 12 Reporting Service

The service will store all information in a separate database. Therefore, once the installation process is completed, you need to create a database where data about document processing will be stored. To do this, follow these steps:

1. On the computer where the ABBYY FlexiCapture 12 Reporting Service is installed, launch PowerShell with administrator privileges.
2. Navigate to the **CreateDb** folder located in the directory where the service has been installed. You can also use this command if the service has been installed to the default path:

   ```powershell theme={null}
   cd C:\inetpub\wwwroot\FlexiCapture12Reporting\CreateDb
   ```
3. Launch the **CreateEventLogDb.ps1** script with the required parameters. For example:

   ```powershell theme={null}
   CreateEventLogDb.ps1 HostName\SQLInstanceName DATABASENAME user password
   ```

   The parameters in this script should be replaced with the name for the database you are creating and your own credentials.

   <Info>
     User and Password are optional parameters to be used only in the case of Microsoft SQL authentication. If no User or Password is specified when launching the script, the program will use the Windows account under which the Reporting Service is running. Make sure that this Windows account has access permissions for the Reporting Service database.
   </Info>
4. Add the following key to the **AppSettings** section of the Administration and Monitoring Console **web.config** file, and then save your changes:

   ```xml theme={null}
   <add key="ExternalLogServiceSettingEnabled" value="true" />
   ```
5. Open the Administration and Monitoring Console and navigate to **Settings → Event Logging Mode**. In the **ABBYY FlexiCapture 12 Reporting Service** field, specify the address of the Reporting Service in the following format: `http://<ServiceAddress>:8001`. Make sure that port 8001 is not used by any other application
6. In Internet Information Services (IIS), recycle the “FlexiCapture 12 Reporting” Application Server pool

After you complete these steps, the program will record document processing data for the default tenant into the **DocumentEditingStatistic** and **EventLog** tables in the database.

## Configuring Reporting Service data access

Once the Reporting Service is ready, configure the data access component if you chose to install and use this component:

1. Go to the directory where the data access component was installed. The default directory is **C:\inetpub\wwwroot\FlexiCapture12ReportingDataAccess.**
2. Open the **appsettings.json** file and specify the following settings:
   * **DecryptionKey** from the application server **web.config**. Its settings are found at **C:\inetpub\wwwroot\FlexiCapture12\Server** by default.
   * **ValidationKey** from the application server **web.config**.
   * **ConnectionString** to connect to the reporting database. It can be found in **appsettings.json** for the Reporting Service (the default path is **C:\inetpub\wwwroot\FlexiCapture12Reporting**).
   * **ReportingDataPath** — the path to the folder where the data should be exported. If there are multiple tenants, each tenant's data will be stored in a separate subfolder.
   * **RunTenantsDataGenerationPeriodSec** — the time that should elapse between automatic exports of new reporting data, in seconds. The default value is 14400, which equals 4 hours.

<Note>
  The **ValidationKey**, **ConnectionString**, **RunTenantsDataGenerationPeriodSec**, and **ReportingDataPath** parameters are not included in the **appsettings.json** file that is installed together with the data access component. You will need to add these parameters manually after the **DecryptionKey** parameter, separating them with a comma.
</Note>

1. Restart the ABBYY FlexiCapture ReportingResults web service in IIS.
2. Restart the ABBYY FlexiCapture ReportingResults Service in Services.

After you complete the steps above, the program will automatically export reporting data into the folder specified in **appsettings.json.** Please note that in the case of automatic data export, the Reporting Service will export reporting data accumulated in the previous day. This means that the first export of reporting data will occur one day after you install and configure the Reporting Service. You can also export reporting data manually at any time using the API (see [REST API data access](/flexi-capture/reporting-service/reporting-data-access-rest-api) for detailed instructions).

## Changing the database used by the ABBYY FlexiCapture 12 Reporting Service

To change the database used by the Reporting Service, you need to modify the **appsettings.json** file. This can be done manually, or, in ABBYY FlexiCapture 12 Release 4 Update 2 and later, using the **EventLogApiCreateDb.exe** utility combined with the **ConnectEventlogDb.ps1** script.

You can switch either to an existing database that already contains some data or to a new empty database. If you switch to a new empty database, the **EventLogApiCreateDb.exe** utility will initialize the database first.

Step-by-step instructions are provided below.

* To change the database manually:
  1. On the computer where the ABBYY FlexiCapture 12 Reporting Service is installed, launch PowerShell with administrator privileges.
  2. Open the **appsettings.json** file, which can be found at C:\inetpub\wwwroot\FlexiCapture12Reporting, and make the necessary modifications.

* To change the database using the **EventLogApiCreateDb.exe** utility:
  1. Run the appropriate utility command:
     * To initialize a new empty database:\
       EventLogApiCreateDb.exe \[ServerName] \[NewDatabaseName] \[User Password] init
     * To connect to an existing database already containing data:\
       EventLogApiCreateDb.exe \[ServerName] \[NewDatabaseName] \[User Password] connect

The utility will open the connection string from the **appsettings.json** file.

1. Run the **ConnectEventlogDb.ps1** script to modify the connection string in the **appsettings.json** file. The general mask for the script is as follows:

```
ConnectEventlogDb.ps1 ServerName OtherDatabaseName [User Password]
```

As a security precaution, the password in **appsettings.json** will be encrypted. The **ConnectEventlogDb.ps1** script will then restart the Reporting Service.

## Enabling the Reporting Service for a non-default tenant

By default, the Reporting Service will only run on the default tenant. To enable the Reporting Service for a non-default tenant set the first bit to the appropriate tenant in the **Flags** field in the **dbo.Tenant** table.\
Now the program will record document processing data for the specifed non-default tenant into the **DocumentEditingStatistic** and **EventLog** tables in the database.
