Changing Metric InfluxDB Shard Group Duration

This document will provide the steps that are needed to change how many hours or days of data is stored in one shard group in InfluxDB. In general longer shard group durations are better for performance, while shorter ones allow more flexibility. The default configuration is to store the following amount of data for each default retention policy:

Note:

Recommendations

While the default shard group durations work well for most cases, high-throughput or long-running instances will benefit from using longer shard group durations. The InfluxDB Documentation, which can be found here: https://docs.influxdata.com/influxdb/v1/concepts/schema_and_data_layout/#shard-group-duration-overview has the following recommendations:

Note:

Steps

  1. Start a command line session to the server with the InfluxDB database.

  2. Login to the database using the Assure1 shortcut:

    a1influxroot
    

    Note:

    If a "command not found" error is returned, the following can be run to load the Assure1 shortcuts:

    source $A1BASEDIR/.bashrc
    

    Next, run "a1influxroot" again.

  3. The following can be used to get the current retention policies and group shard durations:

    show retention policies;
    
  4. One or more of the following queries can be used to change the group shard duration. Examples of how to alter the group shard duration are shown below:

    • Raw is changed to a group shard duration of 7 days.

    • Hourly is changed to a group shard duration of 30 days.

    • Daily is changed to a group shard duration of 300 days.

    ALTER RETENTION POLICY "raw"    ON "Metric" SHARD DURATION 7d DEFAULT
    ALTER RETENTION POLICY "hourly" ON "Metric" SHARD DURATION 30d
    ALTER RETENTION POLICY "daily"  ON "Metric" SHARD DURATION 300d
    

    WARNING:

    Changing the shard group duration has tradeoffs on performance or flexibility, depending on the change. Ensure to also read the official Influx documentation before making a change: https://docs.influxdata.com/influxdb/v1/concepts/schema_and_data_layout/#shard-group-duration-overview

  5. Run the "show retention policies" query again and verify that the new value(s) are reported:

    show retention policies;