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

# SQL execution

> GermainUX can execute SQL queries against a configured database or the GermainUX Datamart.

Components
[`Engine`](/main/germain-ux-engine)

Availability
2020.2 or later

> **[Execution Modes](#execution-modes)**
>
> Choose when SQL runs

> **[Configure the SQL Action](#1-step-1-configure-the-sql-action)**
>
> Build a reporting SQL action

> **[Add the SQL Query](#3-step-3-add-the-sql-query)**
>
> Write the login activity query

> **[Security and Performance Recommendations](#security-and-performance-recommendations)**
>
> Safe, efficient SQL execution

GermainUX can execute SQL queries against a configured database or the GermainUX Datamart. Query results can be included in an email, attached as a file, or used as part of an automated workflow.

## Execution Modes

SQL Actions can run:

* Manually
* On a configurable schedule
* When an SLA condition is met

## Configure a SQL Action

### Using the Wizard

Go to **GermainUX Workspace > Wizards > SQL Action**.

![SQL Action Config Wizard](https://mintcdn.com/germain-ux/uY3MrHiwPZBkcqjb/images/main/sql-execution/image-20260825-155230.png?fit=max\&auto=format\&n=uY3MrHiwPZBkcqjb\&q=85\&s=48549e376e4949ad5f12cb62f0208980)

SQL Action Config Wizard - GermainUX

### Using the Configuration Screen

Go to **GermainUX Workspace > Automation > SQL**.

Select an existing SQL Action to edit it, or click **+** to open the **SQL Action** wizard.

## SQL Action Reference

| Workspace field | Configuration key | Description | Possible values |
| - | - | - | - |
| **Name** | `name` | Unique name for the action. | String |
| **Execute via Engine** | `remote` | Executes the action through a GermainUX Engine. When enabled, a target server can be specified. | Boolean |
| **Target Server** | `targetExpression` | MVEL expression used to identify the target server for remote execution. | String |
| **Logging Enabled** | `loggingEnabled` | Records each execution of the action. | Boolean |
| **Notify on Success** | `notifyOnSuccess` | Creates a notification when the action succeeds. | Boolean |
| **Notify on Failure** | `notifyOnFailure` | Creates a notification when the action fails. | Boolean |
| **Execution Count** | `limitCount` | Maximum number of executions allowed during the configured interval. | Integer |
| **Execution Interval** | `limitInterval` | Period during which the execution-count limit applies. | `YEAR`, `MONTH`, `WEEK`, `DAY`, `HOUR`, or `MINUTE` |
| **Distribution List** | `alertGroupName` | Distribution list that receives the report. | Existing distribution-list name |
| **Alert Template** | `templateName` | Template used to generate the report message. | Existing template name |
| **Suppress Email if Result Is Empty** | `suppressIfEmptyResult` | Prevents report delivery when the query returns no results. | Boolean |
| **Monitored Database** | `monitoredDatabase` | Configured database against which the query runs. | Existing database configuration |
| **Credentials** | `credentials` | Configured credentials used to connect to the database. | Existing credential configuration |
| **Attach Result** | `attachResult` | Attaches the query results to the report. | Boolean |
| **Datamart Query** | `datamartQuery` | Runs the query against the GermainUX Datamart. | Boolean |
| **Run on Schedule** | `schedule` | Enables scheduled execution and allows a CRON expression to be defined. | Boolean |
| **References** | `references` | Advanced references to credentials, configuration entries, or custom values used by the action or template. | Reference collection |
| **SQL Queries** | `sqlQueries` | Queries included in the SQL report. | List of `SqlReportQueryConfig` objects |
| **Triggered by SLAs** | — | SLAs configured to trigger this action. | Collection of SLAs |

### SQL Query Configuration

Each entry in `sqlQueries` can contain:

| Property | Description |
| - | - |
| `name` | Unique name for the query. |
| `sqlText` | SQL statement to execute. |
| `intervalType` | Time interval applied to the query. |
| `attachmentNameTemplate` | Template used to name the result attachment. |

### References

References allow the action or report template to access other GermainUX configuration objects securely.

| Property | Description | Example |
| - | - | - |
| `name` | Unique name used to reference the configuration item. | `Credentials` |
| `key` | GermainUX configuration collection key. | `germain.apm.monitoringConfig.credentials` |
| `itemName` | Name of the item within the collection. | `ReportingCredentials` |
| `value` | Direct custom value when no configuration item is referenced. | A non-sensitive report parameter |

A referenced property can be accessed with an expression such as:

```text theme={null}
${Credentials.username}
```

Use configured credentials for usernames, passwords, tokens, and other secrets. Do not store sensitive values directly in SQL statements, templates, or custom references.

## Example: Scheduled GermainUX Login Report

This example creates a daily email report containing an attachment with the GermainUX login activity recorded during the previous day.

## 1 Step 1: Configure the SQL Action

1. Go to **GermainUX Workspace > Automation > SQL**.
2. Click **+** to open the **SQL Action** wizard.
3. Enter a unique action name.
4. Select or create the distribution list that will receive the report.
5. Select or create the email template.
6. Enable **Attach Result**.
7. Click **Next**.

   ![Configure the SQL Action](https://mintcdn.com/germain-ux/uY3MrHiwPZBkcqjb/images/main/sql-execution/image-20201109-123909.png?fit=max\&auto=format\&n=uY3MrHiwPZBkcqjb\&q=85\&s=f3f28d56da91cea2942fd7214ba7a5dd)

   Configure the SQL Action - GermainUX

## 2 Step 2: Configure the Connection

To query the GermainUX Datamart, enable **Run against GermainUX Datamart**.

To query another database:

1. Select a configured database.
2. Select the credentials used to access it.
3. Test the connection, if that option is available.
4. Click **Next**.

   ![Configure the Connection](https://mintcdn.com/germain-ux/uY3MrHiwPZBkcqjb/images/main/sql-execution/image-20201109-124036.png?fit=max\&auto=format\&n=uY3MrHiwPZBkcqjb\&q=85\&s=b6fc3fd0df73419b25c1fdfa30c55d49)

   Configure the Connection - GermainUX

## 3 Step 3: Add the SQL Query

Add the query that returns GermainUX login activity from the previous day.

A SQL Action can contain one or more queries. The selected database and credentials from the previous step determine where those queries execute.

Preview or validate the query results before continuing.

![Add the SQL Query](https://mintcdn.com/germain-ux/uY3MrHiwPZBkcqjb/images/main/sql-execution/image-20201113-130947.png?fit=max\&auto=format\&n=uY3MrHiwPZBkcqjb\&q=85\&s=369628a3fdd8a85230700acee5220096)

Add the SQL Query - GermainUX

## 4 Step 4: Configure the Schedule

1. Enable **Run on Schedule**.
2. Configure the desired execution frequency or enter a CRON expression.
3. Set the report to run once per day at the required time.
4. Click **Next**.

   ![Configure the Schedule](https://mintcdn.com/germain-ux/uY3MrHiwPZBkcqjb/images/main/sql-execution/image-20201113-131053.png?fit=max\&auto=format\&n=uY3MrHiwPZBkcqjb\&q=85\&s=acd31ee60fd47658a58129a0888d1ba9)

   Configure the Schedule - GermainUX

## 5 Step 5: Configure an SLA Trigger

SQL Actions can run on a schedule or when an SLA is breached.

Because this example uses a daily schedule, leave the SLA selection empty and click **Finish**.

GermainUX will now execute the query each day and send the resulting login report to the selected distribution list.

![Configure an SLA Trigger](https://mintcdn.com/germain-ux/uY3MrHiwPZBkcqjb/images/main/sql-execution/image-20201113-131121.png?fit=max\&auto=format\&n=uY3MrHiwPZBkcqjb\&q=85\&s=2f6769e15ffa6e6e7adcd569f5448721)

Configure an SLA Trigger - GermainUX

![Attachment in a report example](https://mintcdn.com/germain-ux/uY3MrHiwPZBkcqjb/images/main/sql-execution/image-20260825-155647.png?fit=max\&auto=format\&n=uY3MrHiwPZBkcqjb\&q=85\&s=9c2327b6e55a715bac62db3b6c193fcd)

Attachment in a report example - GermainUX

## Security and Performance Recommendations

* Use a dedicated database account with the minimum required permissions.
* Prefer read-only credentials for reporting queries.
* Store credentials in GermainUX credential configurations.
* Use parameterized values where supported.
* Avoid unrestricted or destructive SQL statements.
* Validate queries against a non-production database before enabling them.

> **Show all 9**
>
> * Apply execution limits and query timeouts.
> * Schedule resource-intensive queries outside peak operating periods.
> * Suppress delivery when an empty result provides no useful information.

## Get Help

> **[Contact GermainUX Support](/main/support.md)**
>
> The Germain Team can help you set this up.

> **Can't find what you need?**
>
> Search all GermainUX docs with **Ctrl + K**, or use the feedback buttons at the bottom of this page to tell us what is missing.

The content of this document is proprietary to GERMAIN SOFTWARE.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.