vitessio/vitess · error
failed to create file-based writer for --opentsdb-uri %s: %v
Error message
failed to create file-based writer for --opentsdb-uri %s: %v
What it means
When --opentsdb-uri uses the file:// scheme, newBackend creates a file-based writer via newFileWriter(u.Path); this error wraps any failure from that creation (e.g. the target path cannot be used) together with the original URI. It signals the file writer could not be set up for the requested path.
Source
Thrown at go/stats/opentsdb/init.go:91
return b, nil
}
func newBackend(prefix string) (*backend, error) {
if openTSDBURI == "" {
return nil, errors.New("cannot create opentsdb PushBackend with empty --opentsdb-uri")
}
var w writer
// Use the file API when the uri is in format file://...
u, err := url.Parse(openTSDBURI)
if err != nil {
return nil, fmt.Errorf("failed to parse --opentsdb-uri %s: %v", openTSDBURI, err)
} else if u.Scheme == "file" {
fw, err := newFileWriter(u.Path)
if err != nil {
return nil, fmt.Errorf("failed to create file-based writer for --opentsdb-uri %s: %v", openTSDBURI, err)
} else {
w = fw
}
} else {
w = newHTTPWriter(&http.Client{}, openTSDBURI)
}
return &backend{
prefix: prefix,
commonTags: stats.ParseCommonTags(stats.CommonTags),
writer: w,
}, nil
}
View on GitHub (pinned to 01a25a7d17)
Solutions
- Create the target directory (mkdir -p) and ensure the process user can write to it
- Point --opentsdb-uri at a writable path, e.g. file:///var/tmp/vitess-metrics.jsonl
- Check the wrapped error for the exact OS failure (ENOENT, EACCES) and fix accordingly
Example fix
// before --opentsdb-uri 'file:///nonexistent/dir/metrics' // after mkdir -p /var/lib/vitess/metrics && --opentsdb-uri 'file:///var/lib/vitess/metrics/opentsdb.jsonl'
Defensive patterns
Strategy: validation
Validate before calling
u, _ := url.Parse(opentsdbURI)
if u.Scheme == "file" {
if st, err := os.Stat(filepath.Dir(u.Path)); err != nil || !st.IsDir() {
return fmt.Errorf("directory for --opentsdb-uri does not exist: %s", filepath.Dir(u.Path))
}
} Try / catch
fw, err := newFileWriter(u.Path)
if err != nil {
if errors.Is(err, os.ErrPermission) || errors.Is(err, os.ErrNotExist) {
return fmt.Errorf("cannot write metrics file %s: %w", u.Path, err)
}
} Prevention
- Pre-create the metrics output directory in deployment scripts
- Ensure the container/filesystem path is writable by the process user
- Prefer a path under /var/tmp or a mounted volume over read-only rootfs
When it happens
Trigger: --opentsdb-uri file:///some/path where newFileWriter fails, typically because the path's directory does not exist or the file cannot be opened/created with the required permissions.
Common situations: Writing metrics to a read-only container filesystem; typo'd or missing output directory; running as a user without write permission to the path.
Related errors
- failed to parse --opentsdb-uri %s: %v
- --batch-size requires 'direct' ddl_strategy
- --batch-size conflicts with --uuid-list. Batching does not s
- --batch-size only allowed when all queries are CREATE TABLE|
- failed to load static auth plugin. Plugin configured but grp
AI-assisted analysis of vitessio/vitess@01a25a7d17 (2026-09-01).
Data as JSON: /api/errors/353fb296d3bbf73c.
Report an issue: GitHub.