diff --git a/controller/metrics/fileSource.go b/controller/metrics/fileSource.go index d9e4432f..3112a106 100644 --- a/controller/metrics/fileSource.go +++ b/controller/metrics/fileSource.go @@ -11,8 +11,8 @@ import ( ) type FileSourceConfig struct { - Path string - DataPath string + Path string + IndexPath string } func loadFileSourceConfig(v interface{}, opts *cf.Options) (interface{}, error) { @@ -38,10 +38,9 @@ func (s *fileSource) Start(events chan map[string]interface{}) (join chan struct } _ = f.Close() - idxPath := s.cfg.Path + ".idx" - idxF, err := os.OpenFile(idxPath, os.O_CREATE|os.O_RDWR, os.ModePerm) + idxF, err := os.OpenFile(s.indexPath(), os.O_CREATE|os.O_RDWR, os.ModePerm) if err != nil { - return nil, errors.Wrapf(err, "error opening '%v'", idxPath) + return nil, errors.Wrapf(err, "error opening '%v'", s.indexPath()) } pos := int64(0) @@ -98,3 +97,11 @@ func (s *fileSource) tail(pos int64, events chan map[string]interface{}, idxF *o } } } + +func (s *fileSource) indexPath() string { + if s.cfg.IndexPath == "" { + return s.cfg.Path + ".idx" + } else { + return s.cfg.IndexPath + } +}