Search Files (grep)
Searches files under a directory on the disk for lines matching a regular expression. Listing and matching are fanned out across ephemeral exec microVMs, so the request finishes within the user’s time budget regardless of the size of the directory.
The user controls search latency and scope with three knobs:
maxDurationSecondsis the wall-clock deadline (capped at 30s).concurrencyis the maximum number of parallel grep workers. Higher concurrency finishes larger datasets within the deadline, at proportionally more compute.maxResultscauses the search to short-circuit after the aggregator has collected this many matches.
With recursive: false only files directly under directory are
searched. With recursive: true subdirectories are walked
breadth-first and grep workers are dispatched as soon as each level
finishes listing — listing and matching overlap.
Matching runs on ripgrep. Narrow the files searched with globs,
types, and typesNot; change matching with ignoreCase and
multiline; and ask for surrounding lines with contextBefore and
contextAfter, which adds groups to the result.
The matches returned when stopping early on maxResults, or on the
32 MiB limit on match and context text, are a sample of whichever
workers reported first, not the lexicographically first N. The
response surfaces stoppedReason so callers can distinguish
completion from early termination.
curl --request POST \
--url https://control.green.us-east-1.aws.prod.archil.com/api/disks/{id}/grep \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"directory": "data/logs",
"pattern": "ERROR|FATAL",
"recursive": false,
"maxDurationSeconds": 30,
"concurrency": 50,
"maxResults": 1000,
"ignoreCase": true,
"multiline": true,
"globs": [
"*.log",
"!archive/**"
],
"types": [
"py"
],
"typesNot": [
"json"
],
"contextBefore": 0,
"contextAfter": 0
}
'import requests
url = "https://control.green.us-east-1.aws.prod.archil.com/api/disks/{id}/grep"
payload = {
"directory": "data/logs",
"pattern": "ERROR|FATAL",
"recursive": False,
"maxDurationSeconds": 30,
"concurrency": 50,
"maxResults": 1000,
"ignoreCase": True,
"multiline": True,
"globs": ["*.log", "!archive/**"],
"types": ["py"],
"typesNot": ["json"],
"contextBefore": 0,
"contextAfter": 0
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
directory: 'data/logs',
pattern: 'ERROR|FATAL',
recursive: false,
maxDurationSeconds: 30,
concurrency: 50,
maxResults: 1000,
ignoreCase: true,
multiline: true,
globs: ['*.log', '!archive/**'],
types: ['py'],
typesNot: ['json'],
contextBefore: 0,
contextAfter: 0
})
};
fetch('https://control.green.us-east-1.aws.prod.archil.com/api/disks/{id}/grep', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://control.green.us-east-1.aws.prod.archil.com/api/disks/{id}/grep",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'directory' => 'data/logs',
'pattern' => 'ERROR|FATAL',
'recursive' => false,
'maxDurationSeconds' => 30,
'concurrency' => 50,
'maxResults' => 1000,
'ignoreCase' => true,
'multiline' => true,
'globs' => [
'*.log',
'!archive/**'
],
'types' => [
'py'
],
'typesNot' => [
'json'
],
'contextBefore' => 0,
'contextAfter' => 0
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://control.green.us-east-1.aws.prod.archil.com/api/disks/{id}/grep"
payload := strings.NewReader("{\n \"directory\": \"data/logs\",\n \"pattern\": \"ERROR|FATAL\",\n \"recursive\": false,\n \"maxDurationSeconds\": 30,\n \"concurrency\": 50,\n \"maxResults\": 1000,\n \"ignoreCase\": true,\n \"multiline\": true,\n \"globs\": [\n \"*.log\",\n \"!archive/**\"\n ],\n \"types\": [\n \"py\"\n ],\n \"typesNot\": [\n \"json\"\n ],\n \"contextBefore\": 0,\n \"contextAfter\": 0\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://control.green.us-east-1.aws.prod.archil.com/api/disks/{id}/grep")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"directory\": \"data/logs\",\n \"pattern\": \"ERROR|FATAL\",\n \"recursive\": false,\n \"maxDurationSeconds\": 30,\n \"concurrency\": 50,\n \"maxResults\": 1000,\n \"ignoreCase\": true,\n \"multiline\": true,\n \"globs\": [\n \"*.log\",\n \"!archive/**\"\n ],\n \"types\": [\n \"py\"\n ],\n \"typesNot\": [\n \"json\"\n ],\n \"contextBefore\": 0,\n \"contextAfter\": 0\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://control.green.us-east-1.aws.prod.archil.com/api/disks/{id}/grep")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"directory\": \"data/logs\",\n \"pattern\": \"ERROR|FATAL\",\n \"recursive\": false,\n \"maxDurationSeconds\": 30,\n \"concurrency\": 50,\n \"maxResults\": 1000,\n \"ignoreCase\": true,\n \"multiline\": true,\n \"globs\": [\n \"*.log\",\n \"!archive/**\"\n ],\n \"types\": [\n \"py\"\n ],\n \"typesNot\": [\n \"json\"\n ],\n \"contextBefore\": 0,\n \"contextAfter\": 0\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"data": {
"matches": [
{
"file": "data/logs/2026-05-03.log",
"line": 142,
"text": "<string>",
"endLine": 123
}
],
"stoppedReason": "completed",
"filesScanned": 123,
"containersDispatched": 123,
"computeSecondsUsed": 123,
"durationMs": 123,
"listingMs": 123,
"grepMs": 123,
"groups": [
{
"file": "<string>",
"lines": [
{
"line": 123,
"text": "<string>",
"match": true
}
]
}
]
}
}{
"success": false,
"error": "Invalid request parameters",
"code": "<string>"
}{
"success": false,
"error": "Invalid request parameters",
"code": "<string>"
}{
"success": false,
"error": "Invalid request parameters",
"code": "<string>"
}{
"success": false,
"error": "Invalid request parameters",
"code": "<string>"
}Path Parameters
Body
Regular expression in ripgrep syntax.
A newline separates alternative patterns, except with multiline,
where it matches a line break.
"ERROR|FATAL"
Let a match span lines (rg -U): \n or a newline character in
the pattern matches a line break, and . matches one only after
(?s). Files with Windows line endings need \r?\n instead of
\n. Matches on adjacent lines come back as one match covering
all of them, with endLine set, and count once toward
maxResults. A file with at least maxResults matching lines
stops the request with max_results, even when merging leaves
fewer matches. Defaults to false.
Path globs with ripgrep's -g rules, matched against paths
relative to directory. A leading ! excludes. A glob without a
/ matches a file or directory name at any depth; a glob with a
/ matches the whole relative path, and a leading / anchors it
to directory. A trailing / matches only directories, so use
dir/** to search the files under dir. When several globs
match a path, the last one wins. A directory excluded this way is
skipped with everything under it. If any non-! glob is given,
files that match no glob are skipped. A file a glob matches is
searched or skipped regardless of types and typesNot.
321 - 1024["*.log", "!archive/**"]
Was this page helpful?
curl --request POST \
--url https://control.green.us-east-1.aws.prod.archil.com/api/disks/{id}/grep \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"directory": "data/logs",
"pattern": "ERROR|FATAL",
"recursive": false,
"maxDurationSeconds": 30,
"concurrency": 50,
"maxResults": 1000,
"ignoreCase": true,
"multiline": true,
"globs": [
"*.log",
"!archive/**"
],
"types": [
"py"
],
"typesNot": [
"json"
],
"contextBefore": 0,
"contextAfter": 0
}
'import requests
url = "https://control.green.us-east-1.aws.prod.archil.com/api/disks/{id}/grep"
payload = {
"directory": "data/logs",
"pattern": "ERROR|FATAL",
"recursive": False,
"maxDurationSeconds": 30,
"concurrency": 50,
"maxResults": 1000,
"ignoreCase": True,
"multiline": True,
"globs": ["*.log", "!archive/**"],
"types": ["py"],
"typesNot": ["json"],
"contextBefore": 0,
"contextAfter": 0
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
directory: 'data/logs',
pattern: 'ERROR|FATAL',
recursive: false,
maxDurationSeconds: 30,
concurrency: 50,
maxResults: 1000,
ignoreCase: true,
multiline: true,
globs: ['*.log', '!archive/**'],
types: ['py'],
typesNot: ['json'],
contextBefore: 0,
contextAfter: 0
})
};
fetch('https://control.green.us-east-1.aws.prod.archil.com/api/disks/{id}/grep', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://control.green.us-east-1.aws.prod.archil.com/api/disks/{id}/grep",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'directory' => 'data/logs',
'pattern' => 'ERROR|FATAL',
'recursive' => false,
'maxDurationSeconds' => 30,
'concurrency' => 50,
'maxResults' => 1000,
'ignoreCase' => true,
'multiline' => true,
'globs' => [
'*.log',
'!archive/**'
],
'types' => [
'py'
],
'typesNot' => [
'json'
],
'contextBefore' => 0,
'contextAfter' => 0
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://control.green.us-east-1.aws.prod.archil.com/api/disks/{id}/grep"
payload := strings.NewReader("{\n \"directory\": \"data/logs\",\n \"pattern\": \"ERROR|FATAL\",\n \"recursive\": false,\n \"maxDurationSeconds\": 30,\n \"concurrency\": 50,\n \"maxResults\": 1000,\n \"ignoreCase\": true,\n \"multiline\": true,\n \"globs\": [\n \"*.log\",\n \"!archive/**\"\n ],\n \"types\": [\n \"py\"\n ],\n \"typesNot\": [\n \"json\"\n ],\n \"contextBefore\": 0,\n \"contextAfter\": 0\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://control.green.us-east-1.aws.prod.archil.com/api/disks/{id}/grep")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"directory\": \"data/logs\",\n \"pattern\": \"ERROR|FATAL\",\n \"recursive\": false,\n \"maxDurationSeconds\": 30,\n \"concurrency\": 50,\n \"maxResults\": 1000,\n \"ignoreCase\": true,\n \"multiline\": true,\n \"globs\": [\n \"*.log\",\n \"!archive/**\"\n ],\n \"types\": [\n \"py\"\n ],\n \"typesNot\": [\n \"json\"\n ],\n \"contextBefore\": 0,\n \"contextAfter\": 0\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://control.green.us-east-1.aws.prod.archil.com/api/disks/{id}/grep")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"directory\": \"data/logs\",\n \"pattern\": \"ERROR|FATAL\",\n \"recursive\": false,\n \"maxDurationSeconds\": 30,\n \"concurrency\": 50,\n \"maxResults\": 1000,\n \"ignoreCase\": true,\n \"multiline\": true,\n \"globs\": [\n \"*.log\",\n \"!archive/**\"\n ],\n \"types\": [\n \"py\"\n ],\n \"typesNot\": [\n \"json\"\n ],\n \"contextBefore\": 0,\n \"contextAfter\": 0\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"data": {
"matches": [
{
"file": "data/logs/2026-05-03.log",
"line": 142,
"text": "<string>",
"endLine": 123
}
],
"stoppedReason": "completed",
"filesScanned": 123,
"containersDispatched": 123,
"computeSecondsUsed": 123,
"durationMs": 123,
"listingMs": 123,
"grepMs": 123,
"groups": [
{
"file": "<string>",
"lines": [
{
"line": 123,
"text": "<string>",
"match": true
}
]
}
]
}
}{
"success": false,
"error": "Invalid request parameters",
"code": "<string>"
}{
"success": false,
"error": "Invalid request parameters",
"code": "<string>"
}{
"success": false,
"error": "Invalid request parameters",
"code": "<string>"
}{
"success": false,
"error": "Invalid request parameters",
"code": "<string>"
}