VictoriaMetrics/VictoriaMetrics · error

cannot parse `max_scrape_size` value %q for `job_name` %q`:

Error message

cannot parse `max_scrape_size` value %q for `job_name` %q`: %w

What it means

The `max_scrape_size` field must be a valid byte-size string (e.g. 16MB, 1KB) parsed by flagutil.ParseBytes. When parsing fails, the error is wrapped with the raw value and the job's `job_name`, and config loading aborts.

Source

Thrown at lib/promscrape/config.go:940

	}
	scrapeTimeout := sc.ScrapeTimeout.Duration()
	if scrapeTimeout <= 0 {
		scrapeTimeout = globalCfg.ScrapeTimeout.Duration()
		if scrapeTimeout <= 0 {
			scrapeTimeout = defaultScrapeTimeout
		}
	}
	if scrapeTimeout > scrapeInterval {
		// Limit the `scrape_timeout` with `scrape_interval` like Prometheus does.
		// This guarantees that the scraper can miss only a single scrape if the target sometimes responds slowly.
		// See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1281#issuecomment-840538907
		scrapeTimeout = scrapeInterval
	}
	mss := maxScrapeSize.N
	if sc.MaxScrapeSize != "" {
		n, err := flagutil.ParseBytes(sc.MaxScrapeSize)
		if err != nil {
			return nil, fmt.Errorf("cannot parse `max_scrape_size` value %q for `job_name` %q`: %w", sc.MaxScrapeSize, jobName, err)
		}
		if n > 0 {
			mss = n
		}
	}
	honorLabels := sc.HonorLabels
	honorTimestamps := sc.HonorTimestamps
	denyRedirects := false
	if sc.HTTPClientConfig.FollowRedirects != nil {
		denyRedirects = !*sc.HTTPClientConfig.FollowRedirects
	}
	metricsPath := sc.MetricsPath
	if metricsPath == "" {
		metricsPath = "/metrics"
	}
	scheme := strings.ToLower(sc.Scheme)
	if scheme == "" {
		scheme = "http"

View on GitHub (pinned to 5079fb58f1)

Solutions

  1. Fix the value to a supported format like `16MB`, `1KB`, or `4MiB` without spaces
  2. Use plain integers (bytes) if unsure of suffix support
  3. Run the config through -dryRun to catch all parsing errors at once

Example fix

// before
scrape_configs:
  - job_name: app
    max_scrape_size: 16 MB
// after
scrape_configs:
  - job_name: app
    max_scrape_size: 16MB
Defensive patterns

Strategy: validation

Validate before calling

// Check max_scrape_size parses before load
if sc.MaxScrapeSize != "" {
	if _, err := flagutil.ParseBytes(sc.MaxScrapeSize); err != nil {
		return fmt.Errorf("job %q: bad max_scrape_size %q", sc.JobName, sc.MaxScrapeSize)
	}
}

Try / catch

if err := promscrape.CheckConfig(); err != nil {
	logger.Fatalf("error when checking -promscrape.config: %s", err)
}

Prevention

When it happens

Trigger: Setting `max_scrape_size` in a scrape_config to a value ParseBytes cannot handle, e.g. "16 MB" (space), "mb" (no number), "16Gb" with unsupported units, or a non-numeric string.

Common situations: Typos like '16MBs' or '16 mib' with spaces; copying Prometheus' body_size_limit syntax variants; leaving placeholder text from templates.

Related errors


AI-assisted analysis of VictoriaMetrics/VictoriaMetrics@5079fb58f1 (2026-09-03). Data as JSON: /api/errors/8f5ea3ab451572a4. Report an issue: GitHub.