Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

promtail can not parse cmd flag override configfile #638

Closed
daixiang0 opened this issue May 31, 2019 · 4 comments
Closed

promtail can not parse cmd flag override configfile #638

daixiang0 opened this issue May 31, 2019 · 4 comments
Assignees

Comments

@daixiang0
Copy link
Contributor

daixiang0 commented May 31, 2019

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. add config
# cat cmd/promtail/promtail-docker-config.yaml
server:
  http_listen_port: 9080
  grpc_listen_port: 0

positions:
  filename: /tmp/positions.yaml

clients:
  - url: http://loki:3100/api/prom/push
    batchwait: 3s <===
scrape_configs:
- job_name: system
  entry_parser: raw
  static_configs:
  - targets:
      - localhost
    labels:
      job: varlogs
      __path__: /var/log/*log
  1. add value print in pkg/promtail/client/config.go and build
// UnmarshalYAML implement Yaml Unmarshaler
func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error {
    type raw Config
    var cfg raw 
    if c.URL.URL != nil {
        // we used flags to set that value, which already has sane default.
        cfg = raw(*c)
    } else {
        // force sane defaults.
        cfg = raw{
            BackoffConfig: util.BackoffConfig{
                MaxBackoff: 5 * time.Second,
                MaxRetries: 5,
                MinBackoff: 100 * time.Millisecond,
            },
            BatchSize: 100 * 1024,
            BatchWait: 1 * time.Second,
            Timeout:   10 * time.Second,
        }
    }   

    if err := unmarshal(&cfg); err != nil {
        return err 
    }   

    *c = Config(cfg)
    fmt.Println("config yaml", c.BatchWait)
    return nil 
}

3.set config in cmd line and run

./promtail --config.file=cmd/promtail/promtail-docker-config.yaml --client.batch-wait=1s
config yaml 3s
level=warn ts=2019-05-31T09:39:25.628290877Z caller=filetargetmanager.go:101 msg="WARNING!!! entry_parser config is deprecated, please change to pipeline_stages"
level=info ts=2019-05-31T09:39:25.629777023Z caller=server.go:120 http=[::]:9080 grpc=[::]:46530 msg="server listening on addresses"

Expected behavior
cmd line config should override configfile.

Additional context:
#520
#636

@cyriltovena
Copy link
Contributor

This is the expected behaviour. You need to provide the --client.url and it will work.

@daixiang0
Copy link
Contributor Author

get it, add a comment to ensure users with no confuse about this.

@stale
Copy link

stale bot commented Sep 3, 2019

This issue has been automatically marked as stale because it has not had any activity in the past 30 days. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added stale A stale issue or PR that will automatically be closed. and removed stale A stale issue or PR that will automatically be closed. labels Sep 3, 2019
@sh0rez
Copy link
Member

sh0rez commented Sep 26, 2019

Resolved this in #980

@sh0rez sh0rez closed this as completed Sep 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants