Configure Loki settings
Loki offers many settings (also known as limits) that can be adjusted for different use cases. In Grafana Cloud Logs, we manage them all for you, and set defaults that work for most of our users. Still there may be some settings you may need to adjust such as retention, the OTLP label mappings, or enabling truncation of long log lines that would otherwise be dropped.
You can configure these settings using the Grafana Cloud UI.
Caution
Our engineering team manually reviews all requested limits to ensure system stability and performance.
We aim to approve the requests as soon as possible, but the review and approval process may take up to 2 business days.
In the UI, the current configuration shows a
pendingstatus while we review the request andappliedonce the request is approved and applied.
Before you begin
To configure Loki settings using the UI, you need access to a Grafana Cloud stack with permissions to manage database configuration.
Use the Grafana Cloud UI
To access the Loki configuration UI:
- In your Grafana Cloud stack, in the main menu, expand More apps.
- Select Databases Configuration.
- Select Logs.
The configuration page has three tabs: Retention, OTLP config, and Line truncation. Each tab lets you view your current configuration, submit change requests, and track request status.
When you submit a change request, the request goes through a review process before it takes effect. You can optionally provide a message for reviewers to explain the context of your change. The current configuration panel shows the status of your request:
- applied: The requested changes have been reviewed and applied.
- pending: The request is awaiting review.
- rejected: The request was rejected. Expand the Reviewer Comments section to see the reason.
You can also expand the Submitter’s Note section to review the message you included with your request.
Supported settings and restrictions
Here is a list of the limits that can be configured using the UI, along with the restrictions that apply to each.
Note
If you need to set any of these settings but the restrictions prevent you from doing it, open a support ticket.
Note
Our engineering team may need to override your configured settings. In case your settings are not applied within 2 business days, contact support for assistance.
Configure retention
By default, Grafana Cloud Logs has a retention of 30 days. You can increase it via the retention_period or retention_stream limits. If you need to set a retention of something less than 30 days, contact Grafana Support.
- When using the API, you cannot decrease the retention below the currently configured or applied value (or 30 days by default). The UI allows retention reduction with an explicit confirmation step.
- The maximum configurable retention period is 1 year.
- The period must be a multiple of 30 days (for example 60d, 90d, etc.).
Note
Note that the minimum charge is for 30 day retention, lowering it below 30 days will not further reduce your costs. Increasing the retention period beyond the minimum 30 days will increase your costs. For more information, refer to Logs, traces, and profiles invoice.
You can learn more about retention in the Log retention documentation.
Configure retention using the UI
- In your Grafana Cloud stack, in the main menu, expand More apps.
- Select Databases Configuration.
- Select Logs.
- Click the Retention tab on the Database Configuration page.
- Use the Global Retention Period menu to select the default retention period. Available values range from 1 month to 1 year.
- Click the Stream Retentions button to configure retention periods for specific log streams using label selectors. For each stream retention, set the following fields:
- Period: Select a retention period from the dropdown.
- Selector: Enter a label selector to match specific log streams, for example
{env="prod"}. - Priority: Set the priority for the retention rule.
- Click the Add Stream Retention button to add additional stream retention rules. Click the trash icon to remove a stream retention rule.
- Enter your name in the Author field and optionally provide a Message to explain the context of your change for reviewers.
- Click Submit change request to submit your changes.
Caution
The UI allows you to reduce retention below the currently applied value, which is not permitted through the API. When you reduce retention, a confirmation dialog box opens warning that the change may result in data loss. You must type
reduce retentionto confirm the change.
OTLP label mappings
Grafana Cloud Logs configures a default set of OpenTelemetry resource labels mapping to stream labels. If you need to modify the labels mapping, you can configure them using the UI.
Restrictions:
- You can promote up to 30 resource attributes to stream labels (that is the attributes with
action: index_label). - The
severity_text_as_labelfield cannot be set totrue.
Warning
Promoting high cardinality labels may negatively affect the performance of Loki and slow down queries. Refer to the documentation for how to estimate cardinality and design an effective labeling strategy.
Use the UI to map labels
- In your Grafana Cloud stack, in the main menu, expand More apps.
- Select Databases Configuration.
- Select Logs.
- Click the OTLP config tab on the Database Configuration page.
- If you previously configured OTLP settings through the API, the page displays a Legacy configuration found banner showing your existing API configuration. Select Import into form to migrate these settings into the form so you can manage them through the UI.
- Switch the Ignore Defaults on to ignore default resource attribute mappings.
- Click Add Resource Attributes to configure a new rule for how OpenTelemetry resource attributes are processed. For each rule, configure:
- Action: Select Index Label, Structured Metadata, or Drop.
- Regex: Match attributes by a regular expression pattern, or
- Attributes: List specific attribute names. You must specify either a regular expression pattern or a list of attributes, but not both.
- Click Scope Attributes to configure a new rule for how OpenTelemetry scope attributes are processed. For each rule, configure:
- Action: Select Index Label, Structured Metadata, or Drop.
- Regex: Match attributes by a regular expression pattern, or
- Attributes: List specific attribute names. You must specify either a regular expression pattern or a list of attributes, but not both.
- Click Log Attributes to configure a new rule for how OpenTelemetry log attributes are processed. For each rule, configure:
- Action: Select Index Label, Structured Metadata, or Drop.
- Regex: Match attributes by a regular expression pattern, or
- Attributes: List specific attribute names. You must specify either a regular expression pattern or a list of attributes, but not both.
- Enter your name in the Author field and optionally provide a Message for reviewers.
- Click Submit change request to submit your changes.
Move mapped resource attributes from indexed labels to structured metadata
In cases where resource attributes that are part of the default mapping have high cardinality and should not be stored as indexed labels, but as structured metadata instead,
you must use both the drop stage to remove them from the indexed labels and the structured_metadata stage to add them as structured metadata.
A common example is the service.instance.id resource attribute, which tends to have relatively high cardinality.
In the UI, add two resource attribute rules: one with the Drop action and one with the Structured Metadata action, both targeting the same attribute.
Set max line truncation
By default, Grafana Cloud Logs drops all log lines that exceed the maximum log line size, 256KB.
You can enable max_line_size_truncate (refer to the limits configuration docs) to truncate the lines that exceed the maximum log line size instead of dropping the logs.
Use the UI to truncate lines
- In your Grafana Cloud stack, in the main menu, expand More apps.
- Select Databases Configuration.
- Select Logs.
- Click the Line truncation tab on the Database Configuration page.
- If you previously configured line truncation through the API, the page displays a Legacy configuration found banner showing your existing API configuration. Select Import into form to migrate these settings into the form so you can manage them through the UI.
- Switch Enable line truncation on to truncate log lines exceeding 256KB.
- Enter your name in the Author field and optionally provide a Message for reviewers.
- Click Submit change request to submit your changes.


