count_logs
Count log events matching a query without fetching all data. Get a numeric answer for questions like 'how many errors happened?'
Instructions
Count logs matching a query WITHOUT fetching all data (fast & lightweight).
PREFERRED for counting events - much faster than search_logs, which should never be used just to count results.
Use this when:
"How many errors happened?"
"Count logs for a service"
Need a number, not log content
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"query": "<query>",
"from_time": "<from_time>",
"to_time": "<to_time>"
},
"name": "count_logs"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Search query using Datadog log search syntax (e.g. "status:error service:api") | |
| indexes | No | Optional list of index names to search (e.g. ["main", "retention"]) | |
| to_time | Yes | End time - same accepted formats as from_time | |
| from_time | Yes | Start time - ISO 8601, relative date math (e.g. "now-1h"), or a millisecond timestamp |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||