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

# Monitoring

> Monitor your CodeNull AI Backend deployment

# Monitoring Your Deployment

Effective monitoring is essential for maintaining a healthy and responsive application. This guide covers how to monitor your CodeNull AI Backend deployment on Azure Container Apps.

## Accessing Logs

Azure Container Apps provides built-in logging capabilities that allow you to monitor your application in real-time.

### Streaming Logs

To stream logs from your running container app:

```bash theme={null}
az containerapp logs show -n web-codenull-app -g web-fastapi-codenull-rg
```

This command displays the most recent logs from your application, which is helpful for troubleshooting issues or monitoring application behavior.

### Filtering Logs

You can filter the logs to focus on specific information:

```bash theme={null}
az containerapp logs show -n web-codenull-app -g web-fastapi-codenull-rg --follow
```

The `--follow` flag allows you to stream logs in real-time, which is useful during debugging sessions.

## Monitoring Application Health

### Health Check Endpoint

CodeNull AI Backend provides a built-in health check endpoint that you can use to verify that the application is running correctly:

```
GET /health
```

Example request:

```bash theme={null}
curl -X GET https://<your-app-name>.<region>.azurecontainerapps.io/health
```

This endpoint returns a status code 200 if the application is healthy. You can also include the `mongo_db_check` parameter (default: 1) to verify MongoDB connectivity.

## Viewing Deployment Information

To view detailed information about your deployed container app:

```bash theme={null}
az containerapp show -n web-codenull-app -g web-fastapi-codenull-rg
```

This command returns configuration details, including:

* Application URL
* Resource allocation
* Scaling rules
* Environment variables
* Network configuration

## Setting Up Azure Monitor (Optional)

For more comprehensive monitoring:

1. Navigate to your Container App in the Azure Portal
2. Select "Monitoring" from the left navigation
3. Configure alerts for metrics like:
   * Request count
   * Response time
   * Error rate
   * CPU and memory usage

## Recommended Monitoring Practices

1. **Regular Health Checks**: Set up automated health checks to periodically verify your application's status
2. **Log Analysis**: Review logs regularly to identify potential issues before they affect users
3. **Performance Monitoring**: Track response times and resource usage to optimize your application
4. **Alert Configuration**: Set up alerts for critical metrics to be notified of issues promptly

By following these monitoring practices, you can ensure your CodeNull AI Backend remains reliable and performant.
