-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Add configuration documentation generation tool #7916
Changes from all commits
754d6f8
9de067b
cc52fa4
94677a5
3e3461a
c32e5d0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
--- | ||
description: Describes parameters used to configure Grafana Loki. | ||
menuTitle: Configuration parameters | ||
title: Grafana Loki configuration parameters | ||
weight: 500 | ||
--- | ||
|
||
# Grafana Loki configuration parameters | ||
|
||
{{ .GeneratedFileWarning }} | ||
|
||
Grafana Loki is configured in a YAML file (usually referred to as `loki.yaml` ) | ||
which contains information on the Loki server and its individual components, | ||
depending on which mode Loki is launched in. | ||
|
||
Configuration examples can be found in the [Configuration Examples](examples/) document. | ||
|
||
## Printing Loki Config At Runtime | ||
|
||
If you pass Loki the flag `-print-config-stderr` or `-log-config-reverse-order`, (or `-print-config-stderr=true`) | ||
Loki will dump the entire config object it has created from the built-in defaults combined first with | ||
overrides from config file, and second by overrides from flags. | ||
|
||
The result is the value for every config object in the Loki config struct, which is very large... | ||
|
||
Many values will not be relevant to your install such as storage configs which you are not using and which you did not define, | ||
this is expected as every option has a default value if it is being used or not. | ||
|
||
This config is what Loki will use to run, it can be invaluable for debugging issues related to configuration and | ||
is especially useful in making sure your config files and flags are being read and loaded properly. | ||
|
||
`-print-config-stderr` is nice when running Loki directly e.g. `./loki ` as you can get a quick output of the entire Loki config. | ||
|
||
`-log-config-reverse-order` is the flag we run Loki with in all our environments, the config entries are reversed so | ||
that the order of configs reads correctly top to bottom when viewed in Grafana's Explore. | ||
|
||
## Reload At Runtime | ||
|
||
Promtail can reload its configuration at runtime. If the new configuration | ||
is not well-formed, the changes will not be applied. | ||
A configuration reload is triggered by sending a `SIGHUP` to the Promtail process or | ||
sending a HTTP POST request to the `/reload` endpoint (when the `--server.enable-runtime-reload` flag is enabled). | ||
|
||
## Configuration File Reference | ||
|
||
To specify which configuration file to load, pass the `-config.file` flag at the | ||
command line. The value can be a list of comma separated paths, then the first | ||
file that exists will be used. | ||
If no `-config.file` argument is specified, Loki will look up the `config.yaml` in the | ||
current working directory and the `config/` subdirectory and try to use that. | ||
|
||
The file is written in [YAML | ||
format](https://en.wikipedia.org/wiki/YAML), defined by the scheme below. | ||
Brackets indicate that a parameter is optional. For non-list parameters the | ||
value is set to the specified default. | ||
|
||
### Use environment variables in the configuration | ||
|
||
> **Note:** This feature is only available in Loki 2.1+. | ||
|
||
You can use environment variable references in the configuration file to set values that need to be configurable during deployment. | ||
To do this, pass `-config.expand-env=true` and use: | ||
|
||
``` | ||
${VAR} | ||
``` | ||
|
||
Where VAR is the name of the environment variable. | ||
|
||
Each variable reference is replaced at startup by the value of the environment variable. | ||
The replacement is case-sensitive and occurs before the YAML file is parsed. | ||
References to undefined variables are replaced by empty strings unless you specify a default value or custom error text. | ||
|
||
To specify a default value, use: | ||
|
||
``` | ||
${VAR:-default_value} | ||
``` | ||
|
||
Where default_value is the value to use if the environment variable is undefined. | ||
|
||
Pass the `-config.expand-env` flag at the command line to enable this way of setting configs. | ||
|
||
### Generic placeholders | ||
|
||
- `<boolean>` : a boolean that can take the values `true` or `false` | ||
- `<int>` : any integer matching the regular expression `[1-9]+[0-9]*` | ||
- `<duration>` : a duration matching the regular expression `[0-9]+(ns|us|µs|ms|[smh])` | ||
- `<labelname>` : a string matching the regular expression `[a-zA-Z_][a-zA-Z0-9_]*` | ||
- `<labelvalue>` : a string of unicode characters | ||
- `<filename>` : a valid path relative to current working directory or an absolute path. | ||
- `<host>` : a valid string consisting of a hostname or IP followed by an optional port number | ||
- `<string>` : a string | ||
- `<secret>` : a string that represents a secret, such as a password | ||
|
||
### Supported contents and default values of `loki.yaml` | ||
|
||
{{ .ConfigFile }} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -40,14 +40,14 @@ func (cfg *WALConfig) Validate() error { | |||||
|
||||||
// RegisterFlags adds the flags required to config this to the given FlagSet | ||||||
func (cfg *WALConfig) RegisterFlags(f *flag.FlagSet) { | ||||||
f.StringVar(&cfg.Dir, "ingester.wal-dir", "wal", "Directory to store the WAL and/or recover from WAL.") | ||||||
f.StringVar(&cfg.Dir, "ingester.wal-dir", "wal", "Directory where the WAL data should be stored and/or recovered from.") | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not a suggestion (should) but a fact (is).
Suggested change
|
||||||
f.BoolVar(&cfg.Enabled, "ingester.wal-enabled", true, "Enable writing of ingested data into WAL.") | ||||||
f.DurationVar(&cfg.CheckpointDuration, "ingester.checkpoint-duration", 5*time.Minute, "Interval at which checkpoints should be created.") | ||||||
f.BoolVar(&cfg.FlushOnShutdown, "ingester.flush-on-shutdown", false, "When WAL is enabled, should chunks be flushed to long-term storage on shutdown.") | ||||||
|
||||||
// Need to set default here | ||||||
cfg.ReplayMemoryCeiling = flagext.ByteSize(defaultCeiling) | ||||||
f.Var(&cfg.ReplayMemoryCeiling, "ingester.wal-replay-memory-ceiling", "How much memory the WAL may use during replay before it needs to flush chunks to storage, i.e. 10GB. We suggest setting this to a high percentage (~75%) of available memory.") | ||||||
f.Var(&cfg.ReplayMemoryCeiling, "ingester.wal-replay-memory-ceiling", "Maximum memory size the WAL may use during replay. After hitting this, it will flush data to storage before continuing. A unit suffix (KB, MB, GB) may be applied.") | ||||||
} | ||||||
|
||||||
// WAL interface allows us to have a no-op WAL when the WAL is disabled. | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -113,7 +113,7 @@ type Querier interface { | |
type EngineOpts struct { | ||
// TODO: remove this after next release. | ||
// Timeout for queries execution | ||
Timeout time.Duration `yaml:"timeout"` | ||
Timeout time.Duration `yaml:"timeout" doc:"deprecated"` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Possible enhancement for later: add a |
||
|
||
// MaxLookBackPeriod is the maximum amount of time to look back for log lines. | ||
// only used for instant log queries. | ||
|
@@ -122,7 +122,7 @@ type EngineOpts struct { | |
|
||
func (opts *EngineOpts) RegisterFlagsWithPrefix(prefix string, f *flag.FlagSet) { | ||
// TODO: remove this configuration after next release. | ||
f.DurationVar(&opts.Timeout, prefix+".engine.timeout", DefaultEngineTimeout, "Timeout for query execution. Instead, rely only on querier.query-timeout. (deprecated)") | ||
f.DurationVar(&opts.Timeout, prefix+".engine.timeout", DefaultEngineTimeout, "Use querier.query-timeout instead. Timeout for query execution.") | ||
f.DurationVar(&opts.MaxLookBackPeriod, prefix+".engine.max-lookback-period", 30*time.Second, "The maximum amount of time to look back for log lines. Used only for instant log queries.") | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,8 +51,10 @@ type Config struct { | |
func (c *Config) RegisterFlags(f *flag.FlagSet) { | ||
throwaway := flag.NewFlagSet("throwaway", flag.PanicOnError) | ||
throwaway.IntVar(&c.ReplicationFactor, "common.replication-factor", 3, "How many ingesters incoming data should be replicated to.") | ||
c.Storage.RegisterFlagsWithPrefix("common.storage", throwaway) | ||
c.Ring.RegisterFlagsWithPrefix("", "collectors/", throwaway) | ||
c.Storage.RegisterFlagsWithPrefix("common.storage.", f) | ||
c.Storage.RegisterFlagsWithPrefix("common.storage.", throwaway) | ||
c.Ring.RegisterFlagsWithPrefix("common.storage.", "collectors/", f) | ||
c.Ring.RegisterFlagsWithPrefix("common.storage.", "collectors/", throwaway) | ||
|
||
// instance related flags. | ||
c.InstanceInterfaceNames = netutil.PrivateNetworkInterfacesWithFallback([]string{"eth0", "en0"}, util_log.Logger) | ||
|
@@ -74,12 +76,12 @@ type Storage struct { | |
} | ||
|
||
func (s *Storage) RegisterFlagsWithPrefix(prefix string, f *flag.FlagSet) { | ||
s.S3.RegisterFlagsWithPrefix(prefix+".s3", f) | ||
s.GCS.RegisterFlagsWithPrefix(prefix+".gcs", f) | ||
s.Azure.RegisterFlagsWithPrefix(prefix+".azure", f) | ||
s.Swift.RegisterFlagsWithPrefix(prefix+".swift", f) | ||
s.BOS.RegisterFlagsWithPrefix(prefix+".bos", f) | ||
s.FSConfig.RegisterFlagsWithPrefix(prefix+".filesystem", f) | ||
s.S3.RegisterFlagsWithPrefix(prefix, f) | ||
s.GCS.RegisterFlagsWithPrefix(prefix, f) | ||
s.Azure.RegisterFlagsWithPrefix(prefix, f) | ||
s.Swift.RegisterFlagsWithPrefix(prefix, f) | ||
s.BOS.RegisterFlagsWithPrefix(prefix, f) | ||
Comment on lines
+79
to
+83
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks like a breaking change that needs extra mention in the backlog, right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, this is a breaking change to the CLI flags, because these were registered incorrectly. Not sure what the best course of action is here 😕 See comment: #7916 (comment) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think for the sake of BC, we should keep the old flags and put a deprecation notice in the upgrade guide, and create an issue for v3.0 to remove these deprecated flags. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As discussed internally via slack, this is not a breaking change because the CLI flags with the prefix However, in order to be able to generate the documentation for these flags, they need to be set on the default flag system: https://github.com/grafana/loki/pull/7916/files#diff-5789ed7c47e1cf4394cef6ad3bc4aaea1af3552e930b0420703708e6bd7d2c89R54-R57 |
||
s.FSConfig.RegisterFlagsWithPrefix(prefix, f) | ||
s.Hedging.RegisterFlagsWithPrefix(prefix, f) | ||
} | ||
|
||
|
@@ -89,6 +91,6 @@ type FilesystemConfig struct { | |
} | ||
|
||
func (cfg *FilesystemConfig) RegisterFlagsWithPrefix(prefix string, f *flag.FlagSet) { | ||
f.StringVar(&cfg.ChunksDirectory, prefix+".chunk-directory", "", "Directory to store chunks in.") | ||
f.StringVar(&cfg.RulesDirectory, prefix+".rules-directory", "", "Directory to store rules in.") | ||
f.StringVar(&cfg.ChunksDirectory, prefix+"filesystem.chunk-directory", "", "Directory to store chunks in.") | ||
f.StringVar(&cfg.RulesDirectory, prefix+"filesystem.rules-directory", "", "Directory to store rules in.") | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we use sentence case for titles
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See also other headlines in this document
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 sounds good. Will address these comments in a separate PR