Web scraping
How do I monitor a scraper in production?
Measure both the requests and the data: status codes and latency tell you if fetching works, while record counts and field coverage tell you if the output is still right.
The answer
A scraper can fail loudly (errors, timeouts) or silently (valid pages with missing data, challenge pages with status 200, a layout change that blanks one field). Monitoring has to catch both. Track request level metrics per target site, data level metrics per run, and cost per site, then alert when any of them moves sharply compared with its recent normal. Fixed thresholds miss gradual decay; comparisons with the previous runs catch it.
What to measure
| Metric | Why it matters |
|---|---|
| Responses by status code, per site | rising 403, 429 or 5xx shows blocking or site trouble |
| Challenge pages detected | a growing share signals that your traffic looks more automated |
| Latency (median and slow tail) | slower pages often come before timeouts and blocks |
| Records produced per run | a sudden drop often means a redesign or a soft block |
| Field coverage | the share of records with each key field filled |
| Validation failures | parsers still run but produce wrong values |
| Cost per site | proxy traffic, browser time and solved CAPTCHAs |
| Queue depth and age | work piling up means workers cannot keep pace |
Detect soft failures explicitly
Status 200 is not success. Add a classifier in the fetcher that labels each response: "content", "challenge", "login wall", "empty" or "error page". Cheap checks go a long way: look for a reCAPTCHA or Turnstile container, a cf-chl marker, a DataDome frame, the login form, or a page far smaller than usual. Count each label per site. The classifier also tells the pipeline when to solve a challenge instead of passing a useless page to the parser.
Track the CAPTCHA layer
If you solve challenges through GateSolver, log for each task the type, the time to ready, the final status and the cost field from the result. Also log whether the site accepted the answer, which only your own code can see. A healthy pattern is stable solve times and high acceptance. Watch these signals:
- More tasks per page than before: the site is challenging you more often, so look at IP quality and request rate.
- Tokens returned but rejected by the site: usually parameters (site key, action, enterprise payload) or a mismatch between user agent and proxy; see why tokens get rejected.
- Errors like
ERROR_ZERO_BALANCEorERROR_RATE_LIMIT: operational issues you can alert on directly.
Check your balance on a schedule with getBalance and alert well before it runs out, since a pipeline that stops overnight loses data you cannot fetch later. Unsolved and failed tasks are free, so failures show up in your acceptance logs rather than your bill.
Alerting that people will not ignore
- Alert on change: record count below 70 percent of the 7-day median, challenge share doubling, a key field's coverage dropping by a large step.
- Group alerts per site and per run, so one broken site does not send fifty messages.
- Include context in the alert: the site, the metric, the previous value, and a link to a sample raw page.
- Separate "data is wrong" alerts from "infrastructure is down" alerts; they go to different fixes.
Canary checks
Keep a small set of known pages per site with known expected values, such as a product whose name and brand rarely change. Fetch and parse them on a schedule. If the canary fails, the parser or access path is broken, independent of whatever the full run is doing. Canaries also make a good first step after every deploy.
Logs worth keeping
For every failed fetch, keep the URL, status, headers, proxy used, response size and the first part of the body. Save full raw pages for a sample of failures. When something breaks at 3 a.m., these are what let you diagnose it from your desk the next morning instead of trying to reproduce a block that has already lifted.
Tools
You do not need anything special. Counters and histograms in Prometheus with Grafana dashboards, or a metrics table in your database queried by a small dashboard, both work. What matters is that metrics are broken down per target site and per run. Pair this with the stage layout from pipeline architecture, and use error handling for CAPTCHA APIs to map solver errors to clear alerts.
Common questions
What is the single most useful scraper metric?
Records per run per site, compared with recent runs. It catches redesigns, blocks and parser bugs at once.
How do I spot a soft block?
Classify responses by content, not status. Challenge pages, login walls and unusually small pages count as failures.
Should I alert on every failed request?
No. Some failure is normal. Alert on rates and sudden changes, grouped by site.
How do I know if solved CAPTCHA tokens work?
Log whether the site accepted the request that carried the token. The solver cannot see that outcome.
How often should I check my balance?
On a schedule matched to your spend, with an alert well before it would run out.
Keep reading
- What does a solid scraping pipeline look like?Discovery, fetching, parsing, validation and delivery as separate stages, joined by queues and storage so each can fail safely.
- Error handling for CAPTCHA APIsSort every CAPTCHA API error into retry, fix or stop, follow those rules in code, and know which outcomes cost nothing.
- HTTP status codeThe three digit codes servers answer with, and what 200, 301, 403, 429 and 503 usually mean for a scraper.
- Solve rateHow to measure success on your own side, from tasks returned to answers the target site actually accepted.