Configuring the Loki schema: TSDB and schema v13

Loki schema_config tells the cluster which index store and schema apply to data from each date onward. This page covers writing it for a new install, adding a period for a change, and why old data stays as written.

On this page

Configuring the Loki schema: TSDB and schema v13 for a new install

If you are standing up self-hosted Loki on object storage, the schema_config block is the first thing to get right, because it tells Loki how to lay out its index and chunks before any data is written. For a new install, the Loki documentation recommends store: tsdb, schema: v13 and a 24h index period, with a from date that must be in the past. Set these once, before the first ingester starts writing, and treat the block as part of your infrastructure definition rather than a tuning knob.

Each entry in schema_config defines a period that starts at a from date and carries an index store, a schema version, an object store and an index period. The index store determines how label indexes are kept (TSDB is the recommended option for current Loki releases), the schema version determines the on-disk format Loki uses for that period, and the index period sets how often a new index table begins. Teams touch this block in two situations: when they set up a new cluster, and when they must add a new period for a planned change, such as moving to a newer schema version. Confirm the schema version and index period against the release you are deploying, because the supported values depend on it.

Because each period carries its own settings, a schema change is handled by adding a new period with a future-proof from date, not by editing an existing one. Loki's storage schema lets it iterate over the storage layer without migrating existing data, so older chunks remain readable under the period that wrote them. Before you finalize the block, read the Loki storage schema documentation, confirm the from date and index settings with your Loki version, and record the decision in your deployment repository so that later upgrades start from a known configuration.

Writing schema_config for a new install or a planned change

A new Loki cluster needs one entry under schema_config that tells Loki which index store and schema to use for every chunk it writes. The recommended configuration for a new install uses store: tsdb, schema: v13 and an index period of 24 hours, with the period's from date set to a day that has already passed.

  • from date: Use a past date in YYYY-MM-DD form, such as the day before the first deployment (illustrative). A future date leaves Loki without a schema for the data it is writing.
  • store and schema: Set store: tsdb and schema: v13 together in the same entry, so the index and the chunk layout come from one definition.
  • index block: Set period: 24h and a prefix that identifies this install, especially if several Loki clusters share a bucket.
  • object_store: Name the same object store that the storage_config section configures, so index and chunks land in the expected place.
  • Single period: A new install needs only one entry. Add more entries later only when a planned change requires them.

Confirm the exact key names and the from date rule against the storage schema documentation for the Loki version you deploy before the first start, because the first period cannot be corrected without touching data already written under it.

Schema settings and when each choice fits

This table compares the main schema_config fields for a Loki period and the decision each one drives. Read each row as a question to answer before the first start, since most fields cannot be changed later for data already written. The main takeaway is that a wrong value in an existing period is fixed by adding a new period with a later from date, not by editing the old one.

FieldWhat it controlsWhen to choose itIf it is wrong later
fromThe date a period starts; Loki applies that schema to data written on or after this dateSet to a past date for a new install so the schema is active from the first write; choose a date you can confirm was before ingestion beganDo not edit an existing period's from date; add a new period with a later from date that takes effect going forward
storeThe index store that holds label index entries for the periodUse tsdb for Loki 2.8 and newer; the docs recommend it as the index storeOlder stores such as DynamoDB, Bigtable and Cassandra are deprecated, so do not start new periods on them; confirm against your Loki version
schemaThe chunk and index layout version used for the periodUse v13 for a new install, as the recommended config specifies; confirm v13 is supported by your exact Loki versionOlder schema versions remain readable for their periods; a new schema starts in a new period rather than rewriting old data
object_storeThe backend that stores chunks and index files, such as s3, gcs, azure or filesystemMatch the object store you operate; the docs recommend S3, GCS or Azure for production and note S3-compatible and filesystem stores are not typically recommended for productionChanging object_store for an existing period leaves old data in the previous backend; plan a new period and a data move if you must change stores
index period (24h)How often the index tables roll over into a new tableUse 24h, the value in the recommended config, unless your Loki version guidance says otherwiseChanging the period length affects how data maps to tables; treat it as a new-period decision and confirm the effect in the storage docs
Schema change timingWhether a change applies to new data onlyAdd a period when you upgrade or change store or schema; schemas let Loki read older storage without migrating existing dataConfirm before go-live that the new from date does not overlap the prior period in a way your version rejects

Setting up the schema block step by step

This sequence takes a new Loki install from an unconfigured schema to a verified storage layout. Each step ends with a check, so you know the schema loaded, the data landed in the object store and reads work before you add more data.

  1. Confirm the Loki version and object store

    Your platform or infrastructure owner confirms which Loki release you will run and which object store holds chunks and the index. Check the Loki releases page for the version you plan to deploy, and confirm that the bucket or container exists and that the Loki process can read and write to it. Pick a production-recommended store where possible. Done when you have a written record of the version, the store type and the bucket name, and a test write from the Loki host to that store succeeds.

  2. Choose a from date in the past

    The platform engineer sets the from date for the first period. Loki requires this date to be in the past, so pick a day that is already over, such as the day you begin the install or the day before. Record the date in your change ticket with the reason for it. Done when the date is earlier than the current day and the team has agreed on it, because this value becomes part of the stored data layout and should not be edited later.

  3. Write the period with TSDB and schema v13

    The engineer adds a schema_config block to the Loki configuration file with one period entry. Set the from date from the previous step, set store to tsdb, set object_store to the store you confirmed, and set schema to v13. Follow the storage schema documentation for the exact key names and layout for your Loki version. Done when the file passes a syntax check and the period lists all four values in one place.

  4. Set the 24-hour index period

    In the same period entry, the engineer sets the index period to 24h, which is the value the recommended configuration uses for a new install. The index period controls how often Loki creates a new index table, so this setting determines how index files are grouped in the store. Confirm the value in the file and note it in the change record. Done when the period block contains the from date, store, schema, object store and a 24h index period, and no other period exists yet.

  5. Start Loki and confirm the config loads

    The operator starts Loki with the new configuration and watches the startup log for schema or storage errors. Look for messages that name the schema period, the store and the object store, and confirm that no component exits during startup. Then check the readiness endpoint of the Loki service. Done when Loki reports ready and the log shows that it loaded the schema period you wrote, with no errors about the from date or the index settings.

  6. Write test logs and confirm chunks land

    The operator sends a small set of test log lines through your planned client, or a direct push to the Loki API with a test label set, and waits for ingestion to complete. Then the operator lists the object store and checks that new chunk objects and index files appeared under the paths for the schema period. Done when the bucket or container contains objects created after the test, which confirms that Loki writes to the store you configured and not to a local disk.

  7. Query the test logs and confirm reads

    The operator runs a query for the test label set in Grafana or with the Loki query API, covering a time range that includes the test push. The query should return the test lines. Then the operator restarts the Loki process and repeats the query to confirm that data written under the period is still readable after a restart. Done when both queries return the expected lines, which shows that the index and chunks work together under the period.

  8. Record the period and plan future changes

    The platform team stores the final schema_config in version control and records the from date, store, schema version and index period in its runbook. Any later change goes in as a new period with a later from date, added below the existing one, and the previous period stays in place so existing data remains readable. Review the storage schema documentation before each change. Done when the configuration is committed, the runbook entry is approved and the team knows that editing an existing period is not the way to change the schema.

How writes move across schema periods

The diagram starts with a log write arriving at Loki's ingester, which checks the entry's timestamp against the schema_config periods. The write is routed to the period whose from date covers that timestamp, using the store and schema defined for that period. Older periods stay in place, so data already written under them is still read under its original schema. Before you add a period, confirm the from date is in the past and that no period overlaps the one you are changing.

Each write follows the schema period that covers its timestamp, leaving older data untouched.

Trade-offs in planning schema changes

A schema change in Loki adds a new period for future writes and leaves existing data where it is. The cards below cover the choices that follow from that rule, from where a new period starts to how it interacts with retention and testing, so the change is planned before anything is applied.

New period versus editing an old one

Add a new period instead of editing an existing one. Loki applies each period to the data written from its from date onward, so editing a past entry changes how Loki reads files that were written under the old rules. Plan the change as an additional entry with a future from date, and keep the previous entries unchanged in the file.

Storage schema docs

Aligning from dates with upgrades

Set the from date to the upgrade window, not the day you edit the file. Loki applies a new period from the date you give it, so a date that lands before the Loki version running in production supports the schema will cause problems. Confirm the target version's support for the schema and index settings with the upgrade guide before choosing the date.

Reads that span two periods

Queries over a time range that crosses the from date read two schema periods. Loki must understand the older and newer layouts at the same time, so the older period stays in the config for as long as data written under it is queryable. Removing it early makes older logs unreadable, so keep it until retention has removed that data.

Object store lifecycle and retention

Bucket lifecycle rules must not delete chunks before Loki retention does. If an object store expires objects on its own schedule, Loki may find index entries that point to missing chunks. Keep lifecycle rules longer than the retention period you configure, and confirm the interaction with your storage provider's documentation.

Retention docs

Testing on a non-production copy

Apply the schema change to a copy of the cluster before production. A copy shows whether Loki starts, whether the new period is picked up and whether queries across the boundary return results. Use a copy of the configuration and a sample of data, then record the results so the production change has a documented baseline.

Questions teams ask before changing Loki schema_config

How much effort does a Loki schema setup take?

The schema block itself is a small change: a schema_config entry with a from date, store: tsdb, object_store, schema: v13 and a 24h index period. The effort lies in everything around it: confirming the object store and credentials, checking the Loki version, deciding where the new period starts, rolling the change through each environment and verifying that writes and queries succeed afterward. Effort rises with the number of clusters, the number of environments and how many teams depend on the logs. Ask any partner to break the quote into discovery, change design, rollout per environment and verification.

Can an in-house team write and apply schema_config without a partner?

Yes, if the team already runs Loki and has someone comfortable with its configuration and object storage. The change is documented in the Loki storage schema reference, and the risk is mostly operational: a wrong from date or a mismatched store type can make new data hard to find. A partner is most useful when the team lacks recent Loki operations experience, runs several clusters, or needs an evidence trail for a change review. Decide based on who will read the config, test it and own the rollback plan.

What does the work need from our team?

Plan for four inputs: read and write access to the object store used by Loki, the exact Loki version running in each environment, a maintenance or change window agreed with the platform owners, and a named person who can approve the config change. Where Loki runs in Kubernetes or on servers, the team also needs access to the config source, such as a Helm values file or a config repository. Confirm these early, because access requests are often the longest step in the schedule.

Does adding a schema period rewrite logs already stored in Loki?

No. According to the Loki storage schema documentation, schemas let Loki iterate over the storage layer without migrating existing data. A new period applies to data written from its from date onward, and older chunks and indexes stay where they are and are read under the schema that wrote them. This is why a schema change is a configuration change rather than a data migration. Confirm the behavior against the documentation for your exact Loki version before relying on it in a change record.

How should we choose the from date for a new schema period?

The from date must be in the past, and it sets the day from which new data uses the new period. Teams usually pick a date at or before the moment the config is deployed, so that the period is active when Loki starts writing with it. Choose a date on a day boundary that matches your 24h index period, and record it in the change ticket. Do not set it to a future date expecting a later cut-over, because the docs require a past date. Test the choice in a non-production cluster first.

What would a partner scope and quote for a schema change?

A written scope usually covers an inventory of Loki versions, object stores and existing schema_config periods, the target configuration for each environment, the rollout and rollback steps, verification queries that confirm old and new logs are readable, and the handover documentation. The quote follows from that scope and from the number of environments, clusters and approval gates. Ask whether retesting after a Loki upgrade is included and whether the work is fixed-scope or part of a retainer. DeployOpen does not publish a price list, so request a quote from a written scope.

What breaks most often when a schema period is added incorrectly?

The most common problems are a from date that is not in the past, a store or schema value that does not match what the Loki version supports, and object store permissions that let Loki write but not read older objects. Operators also miss that a new period does not change retention behavior, so retention and lifecycle rules must still be checked separately. Verify after rollout by running a query that spans the boundary and confirming that ingestion, index lookups and chunk reads all succeed in the target environment.

How DeployOpen scopes and delivers Loki schema work

DeployOpen treats the Loki schema as a dated change to a running storage layer, not a one-time file edit. We agree the store, schema version, index period and cutover date in writing before anything changes, then build, test and document the configuration so your team can review and operate it.

How we scope

  • We confirm your Loki version, deployment mode and current schema_config before defining the change.
  • The written scope names the store, schema version, index period and from dates for each period.
  • Engagements are fixed-scope, with deliverables and timelines agreed in writing before work starts.

How we build

  • We write the schema_config block in your infrastructure-as-code repository and review it with your team.
  • We test the configuration in a non-production Loki before any change reaches production.
  • We check that queries across the cutover date return results from both the old and new periods.

How we hand over

  • You receive the final configuration, a record of each schema period and its from date.
  • We document why earlier periods stay in place and how old data continues to be read.
  • We walk your operators through the change steps and the checks to run after each rollout.

How we support

  • Ongoing support, upgrades and continuous testing are available as a retainer for your Loki cluster.
  • Future schema periods follow the same scoped process, with a new from date set in advance.
  • Retainer scope and response expectations are confirmed in writing before the retainer starts.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.