--- description: Configuration reference for the parameters used to configure Grafana Loki. title: Grafana Loki configuration parameters --- ## 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. ## 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: ```bash ${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: ```bash ${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 - `` : a boolean that can take the values `true` or `false` - `` : A plain integer (for example, `0`, `1024`, `5000`) or a size in bytes with optional unit suffix (for example, `1024`, `256KB`, `64MB`, `4GB`). Supported units: `B`, `KB`, `MB`, `GB`, `TB`, `PB`, `EB`. - `` : a duration with required unit suffix. Supported units depend on the field type. Prometheus duration fields support: 'ms', 's', 'm', 'h', 'd', 'w', 'y' (for example, '30s', '1m', '1h', '1d', '1w'). Go native duration fields support: 'ns', 'us', 'µs', 'ms', 's', 'm', 'h' but not 'd', 'w', 'y'. Note: '0' is allowed without a unit. - `` : a string matching the regular expression `[a-zA-Z_][a-zA-Z0-9_]*` - `` : a string of unicode characters - `` : a valid path relative to current working directory or an absolute path. - `` : a valid string consisting of a hostname or IP followed by an optional port number - `` : a string - `` : a string that represents a secret, such as a password ### Supported contents and default values of `loki.yaml` ```yaml # A comma-separated list of components to run. The default value 'all' runs Loki # in single binary mode. The value 'read' is an alias to run only read-path # related components such as the querier and query-frontend, but all in the same # process. The value 'write' is an alias to run only write-path related # components such as the distributor and compactor, but all in the same process. # Supported values: all, compactor, distributor, ingester, querier, # query-scheduler, ingester-querier, query-frontend, index-gateway, ruler, # table-manager, read, write. A full list of available targets can be printed # when running Loki with the '-list-targets' command line flag. # CLI flag: -target [target: | default = "all"] # Enables authentication through the X-Scope-OrgID header, which must be present # if true. If false, the OrgID will always be set to 'fake'. # CLI flag: -auth.enabled [auth_enabled: | default = true] # The amount of virtual memory in bytes to reserve as ballast in order to # optimize garbage collection. Larger ballasts result in fewer garbage # collection passes, reducing CPU overhead at the cost of heap size. The ballast # will not consume physical memory, because it is never read from. It will, # however, distort metrics, because it is counted as live memory. # CLI flag: -config.ballast-bytes [ballast_bytes: | default = 0] # Configures the server of the launched module(s). [server: ] ui: # Enable the experimental Loki UI. # CLI flag: -ui.enabled [enabled: | default = false] # Enable debug logging for the UI. # CLI flag: -ui.debug [debug: | default = false] goldfish: # Enable the Goldfish query comparison feature. # CLI flag: -ui.goldfish.enable [enable: | default = false] storage: # Storage backend type (cloudsql, rds, or empty for no storage) # CLI flag: -ui.goldfish.storage.type [type: | default = ""] # CloudSQL host for Goldfish database. # CLI flag: -ui.goldfish.storage.cloudsql.host [cloudsql_host: | default = "127.0.0.1"] # CloudSQL port for Goldfish database. # CLI flag: -ui.goldfish.storage.cloudsql.port [cloudsql_port: | default = 3306] # CloudSQL database name for Goldfish. # CLI flag: -ui.goldfish.storage.cloudsql.database [cloudsql_database: | default = "goldfish"] # CloudSQL username for Goldfish database. # CLI flag: -ui.goldfish.storage.cloudsql.user [cloudsql_user: | default = ""] # RDS endpoint (host:port) # CLI flag: -ui.goldfish.storage.rds.endpoint [rds_endpoint: | default = ""] # RDS database name # CLI flag: -ui.goldfish.storage.rds.database [rds_database: | default = ""] # RDS database user # CLI flag: -ui.goldfish.storage.rds.user [rds_user: | default = ""] # Maximum number of database connections for Goldfish. # CLI flag: -ui.goldfish.max-connections [max_connections: | default = 10] # Maximum idle time for database connections in seconds. # CLI flag: -ui.goldfish.max-idle-time [max_idle_time_seconds: | default = 300] # Base URL of Grafana instance for explore links. # CLI flag: -ui.goldfish.grafana-url [grafana_url: | default = ""] # UID of the traces datasource in Grafana. # CLI flag: -ui.goldfish.traces-datasource-uid [traces_datasource_uid: | default = ""] # UID of the Loki datasource in Grafana. # CLI flag: -ui.goldfish.logs-datasource-uid [logs_datasource_uid: | default = ""] # Namespace for Cell A logs. # CLI flag: -ui.goldfish.cell-a-namespace [cell_a_namespace: | default = ""] # Namespace for Cell B logs. # CLI flag: -ui.goldfish.cell-b-namespace [cell_b_namespace: | default = ""] # Results storage backend (gcs, s3) for fetching stored query results. # CLI flag: -ui.goldfish.results-backend [results_backend: | default = ""] # The thanos_object_store_config block configures the connection to object # storage backend using thanos-io/objstore clients. This will become the # default way of configuring object store clients in future releases. # Currently this is opt-in and takes effect only when `-use-thanos-objstore` # is set to true. # The CLI flags prefix for this block configuration is: ui.goldfish.results [results_bucket: ] ring: kvstore: # Backend storage to use for the ring. Supported values are: consul, etcd, # inmemory, memberlist, multi. # CLI flag: -ui.ring.store [store: | default = "consul"] # The prefix for the keys in the store. Should end with a /. # CLI flag: -ui.ring.prefix [prefix: | default = "collectors/"] # Configuration for a Consul client. Only applies if the selected kvstore # is consul. # The CLI flags prefix for this block configuration is: ui.ring [consul: ] # Configuration for an ETCD v3 client. Only applies if the selected # kvstore is etcd. # The CLI flags prefix for this block configuration is: ui.ring [etcd: ] multi: # Primary backend storage used by multi-client. # CLI flag: -ui.ring.multi.primary [primary: | default = ""] # Secondary backend storage used by multi-client. # CLI flag: -ui.ring.multi.secondary [secondary: | default = ""] # Mirror writes to the secondary store. # CLI flag: -ui.ring.multi.mirror-enabled [mirror_enabled: | default = false] # Timeout for storing a value to the secondary store. # CLI flag: -ui.ring.multi.mirror-timeout [mirror_timeout: | default = 2s] # Period at which to heartbeat to the ring. # CLI flag: -ui.ring.heartbeat-period [heartbeat_period: | default = 15s] # The heartbeat timeout after which compactors are considered unhealthy # within the ring. 0 = never (timeout disabled). # CLI flag: -ui.ring.heartbeat-timeout [heartbeat_timeout: | default = 1m] # File path where tokens are stored. If empty, tokens are not stored at # shutdown and restored at startup. # CLI flag: -ui.ring.tokens-file-path [tokens_file_path: | default = ""] # True to enable zone-awareness and replicate blocks across different # availability zones. # CLI flag: -ui.ring.zone-awareness-enabled [zone_awareness_enabled: | default = false] # Number of tokens to own in the ring. # CLI flag: -ui.ring.num-tokens [num_tokens: | default = 128] # Factor for data replication. # CLI flag: -ui.ring.replication-factor [replication_factor: | default = 3] # Instance ID to register in the ring. # CLI flag: -ui.ring.instance-id [instance_id: | default = ""] # Name of network interface to read address from. # CLI flag: -ui.ring.instance-interface-names [instance_interface_names: | default = []] # Port to advertise in the ring (defaults to server.grpc-listen-port). # CLI flag: -ui.ring.instance-port [instance_port: | default = 0] # IP address to advertise in the ring. # CLI flag: -ui.ring.instance-addr [instance_addr: | default = ""] # The availability zone where this instance is running. Required if # zone-awareness is enabled. # CLI flag: -ui.ring.instance-availability-zone [instance_availability_zone: | default = ""] # Enable using a IPv6 instance address. # CLI flag: -ui.ring.instance-enable-ipv6 [instance_enable_ipv6: | default = false] # Configures the distributor. [distributor: ] # Configures the querier. Only appropriate when running all modules or just the # querier. [querier: ] query_engine: # Experimental: Enable next generation query engine for supported queries. # CLI flag: -query-engine.enable [enable: | default = false] # Experimental: Enable distributed query execution. # CLI flag: -query-engine.distributed [distributed: | default = false] # Experimental: Name of network interface to read an advertise address from # for accepting incoming traffic from query-engine-worker instances when # distributed execution is enabled. # CLI flag: -query-engine.instance-interface-names [instance_interface_names: | default = []] # Experimental: Batch size of the next generation query engine. # CLI flag: -query-engine.batch-size [batch_size: | default = 100] # Experimental: Number of bytes to prefetch when opening a data object for # decoding metadata and overlapping section reads. Clamps to at least 16KiB. # CLI flag: -query-engine.prefetch-bytes [prefetch_bytes: | default = 16KiB] # Experimental: The number of inputs that are prefetched simultaneously by any # Merge node. A value of 0 means that only the currently processed input is # prefetched, 1 means that only the next input is prefetched, and so on. A # negative value means that all inputs are be prefetched in parallel. # CLI flag: -query-engine.merge-prefetch-count [merge_prefetch_count: | default = 0] # Configures how to read byte ranges from object storage when using the V2 # engine. range_reads: # Experimental: maximum number of parallel reads # CLI flag: -query-engine.range-reads.max-parallelism [max_parallelism: | default = 10] # Experimental: maximum distance (in bytes) between ranges that causes them # to be coalesced into a single range # CLI flag: -query-engine.range-reads.coalesce-size [coalesce_size: | default = 1048576] # Experimental: maximum size of a byte range # CLI flag: -query-engine.range-reads.max-range-size [max_range_size: | default = 8388608] # Experimental: minimum size of a byte range # CLI flag: -query-engine.range-reads.min-range-size [min_range_size: | default = 1048576] # Experimental: Number of worker threads to spawn. Each worker thread runs one # task at a time. 0 means to use GOMAXPROCS value. # CLI flag: -query-engine.worker-threads [worker_threads: | default = 0] # Experimental: Address holding DNS SRV records of schedulers to connect to. # CLI flag: -query-engine.scheduler-lookup-address [scheduler_lookup_address: | default = ""] # Experimental: Interval at which to lookup new schedulers by DNS SRV records. # CLI flag: -query-engine.scheduler-lookup-interval [scheduler_lookup_interval: | default = 10s] # Amount of time until data objects are available. # CLI flag: -query-engine.storage-lag [storage_lag: | default = 1h] # Initial date when data objects became available. Format YYYY-MM-DD. If not # set, assume data objects are always available no matter how far back. # CLI flag: -query-engine.storage-start-date [storage_start_date: