Configuring Loki

    Configuration examples can be found in the Configuration Examples document.

    To specify which configuration file to load, pass the -config.file flag at thecommand line. The file is written in YAML format,defined by the scheme below. Brackets indicate that a parameter is optional. Fornon-list parameters the value is set to the specified default.

    Generic placeholders are defined as follows:

    • <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]+(ms|[smhdwy])
    • <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 regular string
    • <secret>: a regular string that is a secret, such as a password

    Supported contents and default values of loki.yaml:

    server_config

    The server_config block configures Promtail’s behavior as an HTTP server:

    1. # HTTP server listen host
    2. [http_listen_host: <string>]
    3. # HTTP server listen port
    4. [http_listen_port: <int> | default = 80]
    5. # gRPC server listen host
    6. [grpc_listen_host: <string>]
    7. # gRPC server listen port
    8. [grpc_listen_port: <int> | default = 9095]
    9. # Register instrumentation handlers (/metrics, etc.)
    10. [register_instrumentation: <boolean> | default = true]
    11. # Timeout for graceful shutdowns
    12. [graceful_shutdown_timeout: <duration> | default = 30s]
    13. # Read timeout for HTTP server
    14. [http_server_read_timeout: <duration> | default = 30s]
    15. # Write timeout for HTTP server
    16. [http_server_write_timeout: <duration> | default = 30s]
    17. # Idle timeout for HTTP server
    18. [http_server_idle_timeout: <duration> | default = 120s]
    19. # Max gRPC message size that can be received
    20. [grpc_server_max_recv_msg_size: <int> | default = 4194304]
    21. # Max gRPC message size that can be sent
    22. [grpc_server_max_send_msg_size: <int> | default = 4194304]
    23. # Limit on the number of concurrent streams for gRPC calls (0 = unlimited)
    24. [grpc_server_max_concurrent_streams: <int> | default = 100]
    25. # Log only messages with the given severity or above. Supported values [debug,
    26. # info, warn, error]
    27. [log_level: <string> | default = "info"]
    28. # Base path to server all API routes from (e.g., /v1/).
    29. [http_path_prefix: <string>]

    querier_config

    The querier_config block configures the Loki Querier.

    1. # Timeout when querying ingesters or storage during the execution of a
    2. # query request.
    3. [query_timeout: <duration> | default = 1m]
    4. # Limit of the duration for which live tailing requests should be
    5. # served.
    6. [tail_max_duration: <duration> | default = 1h]
    7. # Configuration options for the LogQL engine.
    8. engine:
    9. # Timeout for query execution
    10. [timeout: <duration> | default = 3m]
    11. # The maximum amount of time to look back for log lines. Only
    12. # applicable for instant log queries.
    13. [max_look_back_period: <duration> | default = 30s]
    1. # Configures how connections are pooled
    2. pool_config:
    3. # Whether or not to do health checks.
    4. [health_check_ingesters: <boolean> | default = false]
    5. # How frequently to clean up clients for servers that have gone away after
    6. # a health check.
    7. [client_cleanup_period: <duration> | default = 15s]
    8. # How quickly a dead client will be removed after it has been detected
    9. # to disappear. Set this to a value to allow time for a secondary
    10. # health check to recover the missing client.
    11. [remotetimeout: <duration>]
    12. # The remote request timeout on the client side.
    13. [remote_timeout: <duration> | default = 5s]
    14. # Configures how the gRPC connection to ingesters work as a
    15. # client.
    16. [grpc_client_config: <grpc_client_config>]

    The grpc_client_config block configures a client connection to a gRPC service.

    1. # The maximum size in bytes the client can recieve
    2. [max_recv_msg_size: <int> | default = 104857600]
    3. # The maximum size in bytes the client can send
    4. [max_send_msg_size: <int> | default = 16777216]
    5. # Whether or not messages should be compressed
    6. [use_gzip_compression: <bool> | default = false]
    7. # Rate limit for gRPC client. 0 is disabled
    8. [rate_limit: <float> | default = 0]
    9. # Rate limit burst for gRPC client.
    10. [rate_limit_burst: <int> | default = 0]
    11. # Enable backoff and retry when a rate limit is hit.
    12. [backoff_on_ratelimits: <bool> | default = false]
    13. # Configures backoff when enbaled.
    14. backoff_config:
    15. # Minimum delay when backing off.
    16. [minbackoff: <duration> | default = 100ms]
    17. # The maximum delay when backing off.
    18. [maxbackoff: <duration> | default = 10s]
    19. # Number of times to backoff and retry before failing.
    20. [maxretries: <int> | default = 10]

    ingester_config

    The ingester_config block configures Ingesters.

    lifecycler_config

    The lifecycler_config is used by the Ingester to control how that ingesterregisters itself into the ring and manages its lifecycle during its stay in thering.

    1. # Configures the ring the lifecycler connects to
    2. [ring: <ring_config>]
    3. # The number of tokens the lifecycler will generate and put into the ring if
    4. # it joined without transfering tokens from another lifecycler.
    5. [num_tokens: <int> | default = 128]
    6. # Period at which to heartbeat to the underlying ring.
    7. [heartbeat_period: <duration> | default = 5s]
    8. # How long to wait to claim tokens and chunks from another member when
    9. # that member is leaving. Will join automatically after the duration expires.
    10. [join_after: <duration> | default = 0s]
    11. # Minimum duration to wait before becoming ready. This is to work around race
    12. # conditions with ingesters exiting and updating the ring.
    13. [min_ready_duration: <duration> | default = 1m]
    14. # Store tokens in a normalised fashion to reduce the number of allocations.
    15. [normalise_tokens: <boolean> | default = false]
    16. # Name of network interfaces to read addresses from.
    17. interface_names:
    18. - [<string> ... | default = ["eth0", "en0"]]
    19. # Duration to sleep before exiting to ensure metrics are scraped.
    20. [final_sleep: <duration> | default = 30s]

    The ring_config is used to discover and connect to Ingesters.

    1. kvstore:
    2. # The backend storage to use for the ring. Supported values are
    3. # consul, etcd, inmemory
    4. store: <string>
    5. # The prefix for the keys in the store. Should end with a /.
    6. [prefix: <string> | default = "collectors/"]
    7. # Configuration for a Consul client. Only applies if store
    8. # is "consul"
    9. consul:
    10. # The hostname and port of Consul.
    11. [host: <string> | duration = "localhost:8500"]
    12. # The ACL Token used to interact with Consul.
    13. [acltoken: <string>]
    14. [httpclienttimeout: <duration> | default = 20s]
    15. # Whether or not consistent reads to Consul are enabled.
    16. [consistentreads: <boolean> | default = true]
    17. # Configuration for an ETCD v3 client. Only applies if
    18. # store is "etcd"
    19. etcd:
    20. # The ETCD endpoints to connect to.
    21. endpoints:
    22. - <string>
    23. # The Dial timeout for the ETCD connection.
    24. [dial_tmeout: <duration> | default = 10s]
    25. # The maximum number of retries to do for failed ops to ETCD.
    26. [max_retries: <int> | default = 10]
    27. # The heartbeart timeout after which ingesters are skipped for
    28. # reading and writing.
    29. [heartbeart_timeout: <duration> | default = 1m]
    30. # The number of ingesters to write to and read from. Must be at least
    31. # 1.
    32. [replication_factor: <int> | default = 3]

    storage_config

    The storage_config block configures one of many possible stores for both theindex and chunks. Which configuration is read from depends on the schema_configblock and what is set for the store value.

    1. # Configures storing chunks in AWS. Required options only required when aws is
    2. # present.
    3. aws:
    4. # S3 or S3-compatible URL to connect to. If only region is specified as a
    5. # host, the proper endpoint will be deduced. Use inmemory:///<bucket-name> to
    6. # use a mock in-memory implementation.
    7. s3: <string>
    8. # Set to true to force the request to use path-style addressing
    9. [s3forcepathstyle: <boolean> | default = false]
    10. # Configure the DynamoDB conection
    11. dynamodbconfig:
    12. # URL for DynamoDB with escaped Key and Secret encoded. If only region is specified as a
    13. # host, the proper endpoint will be deduced. Use inmemory:///<bucket-name> to
    14. # use a mock in-memory implementation.
    15. dynamodb: <string>
    16. # DynamoDB table management requests per-second limit.
    17. [apilimit: <float> | default = 2.0]
    18. # DynamoDB rate cap to back off when throttled.
    19. [throttlelimit: <float> | default = 10.0]
    20. # Application Autoscaling endpoint URL with escaped Key and Secret
    21. # encoded.
    22. [applicationautoscaling: <string>]
    23. # Metics-based autoscaling configuration.
    24. metrics:
    25. # Use metrics-based autoscaling via this Prometheus query URL.
    26. [url: <string>]
    27. # Queue length above which we will scale up capacity.
    28. [targetqueuelen: <int> | default = 100000]
    29. # Scale up capacity by this multiple
    30. [scaleupfactor: <float64> | default = 1.3]
    31. # Ignore throttling below this level (rate per second)
    32. [minthrottling: <float64> | default = 1]
    33. # Query to fetch ingester queue length
    34. [queuelengthquery: <string> | default = "sum(avg_over_time(cortex_ingester_flush_queue_length{job="cortex/ingester"}[2m]))"]
    35. # Query to fetch throttle rates per table
    36. [throttlequery: <string> | default = "sum(rate(cortex_dynamo_throttled_total{operation="DynamoDB.BatchWriteItem"}[1m])) by (table) > 0"]
    37. # Quer to fetch write capacity usage per table
    38. [usagequery: <string> | default = "sum(rate(cortex_dynamo_consumed_capacity_total{operation="DynamoDB.BatchWriteItem"}[15m])) by (table) > 0"]
    39. # Query to fetch read capacity usage per table
    40. [readusagequery: <string> | default = "sum(rate(cortex_dynamo_consumed_capacity_total{operation="DynamoDB.QueryPages"}[1h])) by (table) > 0"]
    41. # Query to fetch read errors per table
    42. [readerrorquery: <string> | default = "sum(increase(cortex_dynamo_failures_total{operation="DynamoDB.QueryPages",error="ProvisionedThroughputExceededException"}[1m])) by (table) > 0"]
    43. # Number of chunks to group together to parallelise fetches (0 to disable)
    44. [chunkgangsize: <int> | default = 10]
    45. # Max number of chunk get operations to start in parallel.
    46. [chunkgetmaxparallelism: <int> | default = 32]
    47. # Configures storing chunks in Bigtable. Required fields only required
    48. # when bigtable is defined in config.
    49. bigtable:
    50. # BigTable project ID
    51. project: <string>
    52. # BigTable instance ID
    53. instance: <string>
    54. # Configures the gRPC client used to connect to Bigtable.
    55. [grpc_client_config: <grpc_client_config>]
    56. # Configures storing index in GCS. Required fields only required
    57. # when gcs is defined in config.
    58. gcs:
    59. # Name of GCS bucket to put chunks in.
    60. bucket_name: <string>
    61. # The size of the buffer that the GCS client uses for each PUT request. 0
    62. # to disable buffering.
    63. [chunk_buffer_size: <int> | default = 0]
    64. # The duration after which the requests to GCS should be timed out.
    65. [request_timeout: <duration> | default = 0s]
    66. # Configures storing chunks in Cassandra
    67. cassandra:
    68. # Comma-separated hostnames or IPs of Cassandra instances
    69. addresses: <string>
    70. # Port that cassandra is running on
    71. [port: <int> | default = 9042]
    72. # Keyspace to use in Cassandra
    73. keyspace: <string>
    74. # Consistency level for Cassandra
    75. [consistency: <string> | default = "QUORUM"]
    76. # Replication factor to use in Cassandra.
    77. [replication_factor: <int> | default = 1]
    78. # Instruct the Cassandra driver to not attempt to get host
    79. # info from the system.peers table.
    80. [disable_initial_host_lookup: <bool> | default = false]
    81. # Use SSL when connecting to Cassandra instances.
    82. [SSL: <boolean> | default = false]
    83. # Require SSL certificate validation when SSL is enabled.
    84. [host_verification: <bool> | default = true]
    85. # Path to certificate file to verify the peer when SSL is
    86. # enabled.
    87. [CA_path: <string>]
    88. # Enable password authentication when connecting to Cassandra.
    89. [auth: <bool> | default = false]
    90. # Username for password authentication when auth is true.
    91. [username: <string>]
    92. # Password for password authentication when auth is true.
    93. [password: <string>]
    94. # Timeout when connecting to Cassandra.
    95. [timeout: <duration> | default = 600ms]
    96. # Initial connection timeout during initial dial to server.
    97. [connect_timeout: <duration> | default = 600ms]
    98. # Configures storing index in BoltDB. Required fields only
    99. # required when boltdb is present in config.
    100. boltdb:
    101. # Location of BoltDB index files.
    102. directory: <string>
    103. # Configures storing the chunks on the local filesystem. Required
    104. # fields only required when filesystem is present in config.
    105. filesystem:
    106. # Directory to store chunks in.
    107. directory: <string>
    108. # Cache validity for active index entries. Should be no higher than
    109. # the chunk_idle_period in the ingester settings.
    110. [indexcachevalidity: <duration> | default = 5m]
    111. # The maximum number of chunks to fetch per batch.
    112. [max_chunk_batch_size: <int> | default = 50]
    113. # Config for how the cache for index queries should
    114. # be built.
    115. index_queries_cache_config: <cache_config>

    cache_config

    The cache_config block configures how Loki will cache requests, chunks, andthe index to a backing cache store.

    1. # Enable in-memory cache.
    2. [enable_fifocache: <boolean>]
    3. # The default validity of entries for caches unless overriden.
    4. # "defaul" is correct.
    5. [defaul_validity: <duration>]
    6. # Configures the background cache when memcached is used.
    7. background:
    8. # How many goroutines to use to write back to memcached.
    9. [writeback_goroutines: <int> | default = 10]
    10. [writeback_buffer: <int> = 10000]
    11. # Configures memcached settings.
    12. memcached:
    13. # Configures how long keys stay in memcached.
    14. expiration: <duration>
    15. # Configures how many keys to fetch in each batch request.
    16. batch_size: <int>
    17. # Maximum active requests to memcached.
    18. [parallelism: <int> | default = 100]
    19. memcached_client:
    20. # The hostname to use for memcached services when caching chunks. If
    21. # empty, no memcached will be used. A SRV lookup will be used.
    22. [host: <string>]
    23. # SRV service used to discover memcached servers.
    24. [service: <string> | default = "memcached"]
    25. # Maximum time to wait before giving up on memcached requests.
    26. [timeout: <duration> | default = 100ms]
    27. # The maximum number of idle connections in the memcached client
    28. # pool.
    29. [max_idle_conns: <int> | default = 100]
    30. # The period with which to poll the DNS for memcached servers.
    31. [update_interval: <duration> | default = 1m]
    32. # Whether or not to use a consistent hash to discover multiple memcached
    33. # servers.
    34. [consistent_hash: <bool>]
    35. fifocache:
    36. # Number of entries to cache in-memory.
    37. [size: <int> | default = 0]
    38. # The expiry duration for the in-memory cache.
    39. [validity: <duration> | default = 0s]

    schema_config

    The schema_config block configures schemas from given dates.

    1. # The configuration for chunk index schemas.
    2. configs:
    3. - [<period_config>]

    The period_config block configures what index schemas should be usedfor from specific time periods.

    1. # The date of the first day that index buckets should be created. Use
    2. # a date in the past if this is your only period_config, otherwise
    3. # use a date when you want the schema to switch over.
    4. [from: <daytime>]
    5. # store and object_store below affect which <storage_config> key is
    6. # used.
    7. # Which store to use for the index. Either cassandra, bigtable, dynamodb, or
    8. # boltdb
    9. store: <string>
    10. # Which store to use for the chunks. Either gcs, s3, inmemory, filesystem,
    11. # cassandra. If omitted, defaults to same value as store.
    12. [object_store: <string>]
    13. # The schema to use. Set to v9 or v10.
    14. schema: <string>
    15. # Configures how the index is updated and stored.
    16. index:
    17. # Table prefix for all period tables.
    18. prefix: <string>
    19. # Table period.
    20. [period: <duration> | default = 168h]
    21. # A map to be added to all managed tables.
    22. tags:
    23. [<string>: <string> ...]
    24. # Configured how the chunks are updated and stored.
    25. chunks:
    26. # Table prefix for all period tables.
    27. prefix: <string>
    28. # Table period.
    29. [period: <duration> | default = 168h]
    30. # A map to be added to all managed tables.
    31. tags:
    32. [<string>: <string> ...]
    33. # How many shards will be created. Only used if schema is v10.
    34. [row_shards: <int> | default = 16]

    Where daytime is a value in the format of yyyy-mm-dd like 2006-01-02.

    limits_config

    The limits_config block configures global and per-tenant limits for ingestinglogs in Loki.

    1. # Per-user ingestion rate limit in samples per second.
    2. [ingestion_rate: <float> | default = 25000]
    3. # Per-user allowed ingestion burst size (in number of samples).
    4. [ingestion_burst_size: <int> | default = 50000]
    5. # Whether or not, for all users, samples with external labels
    6. # identifying replicas in an HA Prometheus setup will be handled.
    7. [accept_ha_samples: <boolean> | default = false]
    8. # Prometheus label to look for in samples to identify a
    9. # Prometheus HA cluster.
    10. [ha_cluster_label: <string> | default = "cluster"]
    11. # Prometheus label to look for in samples to identify a Prometheus HA
    12. # replica.
    13. [ha_replica_label: <string> | default = "__replica__"]
    14. # Maximum length of a label name.
    15. [max_label_name_length: <int> | default = 1024]
    16. # Maximum length of a label value.
    17. [max_label_value_length: <int> | default = 2048]
    18. # Maximum number of label names per series.
    19. [max_label_names_per_series: <int> | default = 30]
    20. # Whether or not old samples will be rejected.
    21. [reject_old_samples: <bool> | default = false]
    22. # Maximum accepted sample age before rejecting.
    23. [reject_old_samples_max_age: <duration> | default = 336h]
    24. # Duration for a table to be created/deleted before/after it's
    25. # needed. Samples won't be accepted before this time.
    26. [creation_grace_period: <duration> | default = 10m]
    27. # Enforce every sample has a metric name.
    28. [enforce_metric_name: <boolean> | default = true]
    29. # Maximum number of samples that a query can return.
    30. [max_samples_per_query: <int> | default = 1000000]
    31. # Maximum number of active series per user.
    32. [max_series_per_user: <int> | default = 5000000]
    33. # Maximum number of active series per metric name.
    34. [max_series_per_metric: <int> | default = 50000]
    35. # Maximum number of chunks that can be fetched by a single query.
    36. [max_chunks_per_query: <int> | default = 2000000]
    37. # The limit to length of chunk store queries. 0 to disable.
    38. [max_query_length: <duration> | default = 0]
    39. # Maximum number of queries that will be scheduled in parallel by the
    40. # frontend.
    41. [max_query_parallelism: <int> | default = 14]
    42. # Cardinality limit for index queries
    43. [cardinality_limit: <int> | default = 100000]
    44. # Filename of per-user overrides file
    45. [per_tenant_override_config: <string>]
    46. # Period with which to reload the overrides file if configured.
    47. [per_tenant_override_period: <duration> | default = 10s]

    The table_manager_config block configures how the table manager operatesand how to provision tables when DynamoDB is used as the backing store.

    1. # Master 'off-switch' for table capacity updates, e.g. when troubleshooting
    2. [throughput_updates_disabled: <boolean> | default = false]
    3. # Master 'on-switch' for table retention deletions
    4. [retention_deletes_enabled: <boolean> | default = false]
    5. # How far back tables will be kept before they are deleted. 0s disables
    6. # deletion. The retention period must be a multiple of the index / chunks
    7. # table "period" (see period_config).
    8. [retention_period: <duration> | default = 0s]
    9. # Period with which the table manager will poll for tables.
    10. [dynamodb_poll_interval: <duration> | default = 2m]
    11. # duration a table will be created before it is needed.
    12. [creation_grace_period: <duration> | default = 10m]
    13. # Configures management of the index tables for DynamoDB.
    14. index_tables_provisioning: <provision_config>
    15. # Configures management of the chunk tables for DynamoDB.
    16. chunk_tables_provisioning: <provision_config>

    provision_config

    The provision_config block configures provisioning capacity for DynamoDB.

    auto_scaling_config

    1. # Whether or not autoscaling should be enabled.
    2. [enabled: <boolean>: default = false]
    3. # AWS AutoScaling role ARN
    4. [role_arn: <string>]
    5. # DynamoDB minimum provision capacity.
    6. [min_capacity: <int> | default = 3000]
    7. # DynamoDB maximum provision capacity.
    8. [max_capacity: <int> | default = 6000]
    9. # DynamoDB minimum seconds between each autoscale up.
    10. [out_cooldown: <int> | default = 1800]
    11. # DynamoDB minimum seconds between each autoscale down.
    12. [in_cooldown: <int> | default = 1800]
    13. [target: <float> | default = 80]