What the agent does
This is for the customer-success team of a business software company whose product is used through a web app and an API. Engineering watches Datadog for outages, but an outage that touched a small share of all requests can hit a few customers far harder than the rest, and the account manager for a customer whose nightly sync failed all week hears about it from the customer first. The team wants a list every Friday of the accounts with the most failed requests, which endpoints failed, and whether a known incident explains it, split by account manager so each one can call before the customer does.
Someone on the team connects Datadog once with POST /me/connections {"type": "mcp", "name": "datadog", "url": "https://mcp.datadoghq.com/api/unstable/mcp-server/mcp", "auth": {"mode": "oauth"}} and opens the authorize_url. Datadog's docs say the server acts with the signed-in user's own permissions and cannot reach anything that user cannot see, that the tools this job uses are in the default core toolset, and that log analysis needs the Logs Read Data, Logs Read Index Data and Timeseries permissions. A customer-success user with read-only access to the API service's logs is enough.
The company's API logs every request with the account id as an attribute, @account_id, and the status code as @http.status_code. On a run the agent calls analyze_datadog_logs, which Datadog's docs describe as SQL over logs for counting and aggregation, to count requests and failed requests (status 500 and above) per account for service:public-api over the last seven days and the seven before. It keeps the 20 accounts with the most failures, and works out each one's failure rate and the change on the previous week. For each of those it calls search_datadog_logs with the account id and status filter to read a sample of failures: the endpoint, the error message and the times they clustered.
It calls search_datadog_incidents for incidents declared in the same week and notes, for each account, whether its failures fall inside an incident's window. It matches accounts to customer names and account managers from the list in the prompt, and writes customer-errors.md with one section per account manager, worst account first: failures, failure rate, change on last week, the endpoints and messages, and the incident if one explains it. It writes nothing to Datadog. The prompt forbids every notebook, monitor and agent tool that creates or edits, and Datadog checks a write permission on each such call anyway.
Start it with one API call
POST https://api.phoenix.so/o/{org}/sessions with this body:
{
"agent": "claude",
"input": "Weekly customer error report for 2026-11-13T00:00Z to 2026-11-20T00:00Z, compared with 2026-11-06 to 2026-11-13. Use the datadog connection. With analyze_datadog_logs, for service:public-api, count all requests and requests with @http.status_code >= 500 per @account_id for each week. Keep the 20 accounts with the most failures this week; compute failure rate and the change in failures on last week. For each, call search_datadog_logs with service:public-api @account_id:<id> @http.status_code:>=500 for this week and summarise the top endpoints (@http.url_details.path), the top error messages, and the hours they clustered in. Call search_datadog_incidents for incidents in this week and note which accounts' failures fall inside an incident window. Account owners (account_id: customer, manager): 4411: Northwind Clinics, Ana; 5172: Brightside Freight, Ana; 6230: Larkfield Schools, Joe; 7019: Cedar & Pine Retail, Joe. Accounts not listed go under Unassigned. Write customer-errors.md with one section per manager, worst account first. Do not create or edit notebooks, monitors, dashboards or agents, and call no tool that writes.",
"connections": [
"datadog"
]
}- Get an API key. In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
- Send the request. POST the body in request.json to https://api.phoenix.so/o/{org}/sessions. The run starts in its own cloud sandbox.
- Read what came back. Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.
What comes back
The session returns customer-errors.md as an artifact and a summary in result. Each account manager reads their section on Friday afternoon and decides who to contact: the customer whose sync failed all week gets a call with the endpoint and the times already in hand, and the customer hit only during a declared incident gets the incident's status update. Engineering reads the Unassigned section and the endpoints that appear for many accounts.
What the account manager checks before calling: that the failures are the company's and not the customer's own bad requests, which usually show as 4xx and are left out here, but sometimes surface as 5xx from a validation bug; that an account's spike is not a load test the customer told the team about; and the incident note, which is about timing overlap and not a confirmed cause. The report says what the logs show and leaves the conversation to the person who owns the account.
Run it on every Friday afternoon
In the console, a Project automation with a schedule trigger at 0 14 * * 5 in the team's timezone runs a saved agent whose connections name datadog. The saved prompt says "the last seven days and the seven before", and the agent writes the exact window it used at the top of the report. The account-owner list sits in the saved prompt, and the team lead updates it when accounts change hands.
During a bad week, anyone on the team can start the same saved agent from the console with a shorter window, such as the last 24 hours, and send the result to engineering's incident channel by hand.
The use case this job follows, with its automation and trigger: Produce a report or file, no repo.
Why run it on Rush?
The report needs to read production logs, and that access should be a person's own Datadog sign-in with the permissions Datadog already gives them, not an application key in a shared script. On Rush the sign-in stays in the team's connection, and Datadog's own role controls, log restriction queries and per-client limits still apply to every call the agent makes.
Each run has its own computer and a record of every query and what its model calls cost. A Datadog dashboard can chart errors by account, but it cannot read the error messages for the worst twenty accounts, set them beside the week's incidents, and write one page per account manager in the words they use with customers.
Frequently asked questions
Our logs do not carry an account id. Can we still do this?
The report depends on an attribute that ties a request to a customer. If logs carry an API key id or a tenant id instead, use that in the prompt with a mapping to customers. If they carry none, adding one to the API's request log is the first step, and engineering owns it.
Does this use Datadog's AI features?
Datadog's docs say most MCP tools query its backends directly and a few that build queries from natural language use Datadog-hosted models. The prompt gives exact filters and SQL-style counts, and the transcript shows each query sent.
Can the agent open an incident or page engineering?
Not with this prompt, which forbids every tool that writes. Datadog also checks the write permission on each call, so a read-only Datadog user cannot create anything even if asked. Escalation stays with the account manager and engineering's own process.
How many tool calls does a run make?
As written, two counting queries, one log search for each of the 20 accounts and one incident search: about two dozen. Datadog's docs set a fair-use limit of 50 tool calls per 10 seconds, which this stays well under.