diff --git a/metricbeat/mb/testing/data_generator.go b/metricbeat/mb/testing/data_generator.go index 0619a3a54e3..4fc76dd1fda 100644 --- a/metricbeat/mb/testing/data_generator.go +++ b/metricbeat/mb/testing/data_generator.go @@ -170,7 +170,7 @@ func WriteEventToDataJSON(t testing.TB, fullEvent beat.Event, postfixPath string t.Fatal(err) } - if stat, err := os.Stat(postfixPath); err == nil && stat.IsDir() { + if stat, err := os.Stat(postfixPath); postfixPath == "" || (err == nil && stat.IsDir()) { p = path.Join(p, postfixPath, "_meta", "data.json") } else { p = postfixPath