-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding a sync() function to filetarget (#293)
* Adding a sync() function to filetarget which runs on a timer to catch any events missed by fsnotify * moving where we mark the final position to avoid a race condition exposed in testing, we want to stop the tailer before shutting down our tailer loop * Fix changes from PR and refactor to remove circular imports and make config consistent * Adding an "integration" type unit test which tests promtail as a whole * fixing a bunch of imports I munged moved tailer to its own file refactoring filetarget to make synclogic easier to follow and reused as much as possible
- Loading branch information
Showing
12 changed files
with
897 additions
and
370 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ cmd/loki/loki | |
cmd/promtail/promtail | ||
/loki | ||
/promtail | ||
.idea/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package config | ||
|
||
import ( | ||
"flag" | ||
"io/ioutil" | ||
"path/filepath" | ||
|
||
"github.com/weaveworks/common/server" | ||
"gopkg.in/yaml.v2" | ||
|
||
"github.com/grafana/loki/pkg/promtail/client" | ||
"github.com/grafana/loki/pkg/promtail/positions" | ||
"github.com/grafana/loki/pkg/promtail/scrape" | ||
"github.com/grafana/loki/pkg/promtail/targets" | ||
) | ||
|
||
// Config for promtail, describing what files to watch. | ||
type Config struct { | ||
ServerConfig server.Config `yaml:"server,omitempty"` | ||
ClientConfig client.Config `yaml:"client,omitempty"` | ||
PositionsConfig positions.Config `yaml:"positions,omitempty"` | ||
ScrapeConfig []scrape.Config `yaml:"scrape_configs,omitempty"` | ||
TargetConfig targets.Config `yaml:"target_config,omitempty"` | ||
} | ||
|
||
// RegisterFlags registers flags. | ||
func (c *Config) RegisterFlags(f *flag.FlagSet) { | ||
c.ServerConfig.RegisterFlags(f) | ||
c.ClientConfig.RegisterFlags(f) | ||
c.PositionsConfig.RegisterFlags(f) | ||
c.TargetConfig.RegisterFlags(f) | ||
} | ||
|
||
// LoadConfig loads config from a file. | ||
func LoadConfig(filename string) (*Config, error) { | ||
buf, err := ioutil.ReadFile(filepath.Clean(filename)) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
var cfg Config | ||
if err := yaml.UnmarshalStrict(buf, &cfg); err != nil { | ||
return nil, err | ||
} | ||
|
||
return &cfg, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.