# Write a SOQL query on AsyncApexJob to monitor the status and number of errors of currently running Batch Apex jobs.

**Topic:** Development · **Difficulty:** Medium · **Asked at:** Salesforce, Cognizant, Capgemini · **Tags:** soql, scenario, async-apex, monitoring

Read it on the site: https://www.forcechallenges.com/interview-questions/write-a-soql-query-on-asyncapexjob-to-monitor-the-status-and-number-of-errors-of-currently-running-batch-apex

## Answer

Query `AsyncApexJob` for batch jobs that haven't finished and read progress and error counts.

```soql
SELECT Id, ApexClass.Name, Status, JobItemsProcessed, TotalJobItems, NumberOfErrors, CreatedDate
FROM AsyncApexJob
WHERE JobType = 'BatchApex' AND Status IN ('Queued', 'Preparing', 'Processing')
```
Remove the status filter and add `ExtendedStatus` to investigate failed jobs.

---
Source: ForceChallenges · last updated 2026-10-19
