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

# Data Analysis Agent

> Monitor database queries to uncover insights and errors in your app

## Overview

The Data Analysis Agent is a powerful tool designed to monitor and analyze database queries, providing valuable insights and helping to uncover potential errors in your application. This agent is part of the Alerty AI suite, offering comprehensive monitoring and analysis solutions for developers and businesses.

## Features

* Customizable database query monitoring
* Flexible run frequency options
* Detailed analysis reports
* Error detection and insights

## Setting Up an Agent

1. Navigate to the Data Analysis Agent section in your Alerty dashboard
2. Click "Add Agent"
3. Fill in the following details:

### DSN (Data Source Name)

Enter the connection string for your database. For example:

```
postgres-monitor-alerty.cbwvk2qcrgef.us-west-1.rds.amazonaws.com
```

### Agent Run Frequency

Choose how often the agent should run:

* Manual
* Hourly
* Daily
* Weekly

### Agent Report Frequency

Specify when you want to receive reports:

* After each job run
* Daily summary
* Weekly summary

### Query

Enter the SQL query you want to monitor. For example:

```sql theme={null}
SELECT COUNT(*) FROM users
```

### Analysis Goal

Describe what you want to achieve with this analysis. For example:
"Analyze how the user count grows"

### Agent Name

Give your agent a descriptive name, such as "My User Counter Agent"

4. Click "Create & Run Agent" to start the analysis

## Viewing Results

After the agent runs, you can view the results in the Alerty dashboard. The report will include:

* Summary of the query results
* Analysis based on the specified goal
* Detected anomalies or potential errors
* Insights and recommendations

## Example Use Case

### Total Orders per Customer

**Query:**

```sql theme={null}
SELECT c.Name, SUM(o.TotalAmount) AS TotalSpent
FROM Customers c
JOIN Orders o ON c.CustomerID = o.CustomerID
GROUP BY c.Name;
```

**Goal:** Monitor total spending per customer to identify top customers and spending patterns.

**Benefits:**

* Identify your most valuable customers
* Detect unusual spending patterns that might indicate errors or fraud
* Track customer spending trends over time

## Best Practices

1. Start with simple queries and gradually increase complexity
2. Ensure your queries are optimized for performance
3. Use clear and descriptive agent names
4. Regularly review and adjust your analysis goals

## Troubleshooting

* If your agent fails to run, check your database connection string (DSN)
* Ensure your query syntax is correct for your specific database type
* For performance issues, consider optimizing your query or adjusting the run frequency

## Support

For any questions or issues, please join our community on [Discord](https://discord.gg/zKVwU4UJgz) or refer to our [documentation](https://docs.alerty.ai).

## About Alerty

Alerty is an AI-powered monitoring tool designed specifically for developers. It offers features like auto-detection of cloud resources, intelligent monitoring, comprehensive analytics, and real-time alerts. To learn more about Alerty and its other features, visit [https://alerty.ai](https://alerty.ai).
