INFLUXDB Learning INFLUXDB Data Retention policy (Retention policies)

Source: Internet
Author: User
Tags influxdb

INFLUXDB can process tens of thousands of data per second, saving all of this data in a large amount of storage space, and sometimes we may not need to store all of the historical data, so INFLUXDB introduced a data retention policy (Retention policies), Used to allow us to customize the data retention time. For more Influxdb detailed tutorials See: INFLUXDB Series Learning Tutorials Catalogue

INFLUXDB Technology Group: 580487672 (click to join)

I. Description of InfluxDB Data retention policy

The INFLUXDB Data Retention policy (RP) is used to define when data is stored in influxdb, or to define the data that is stored for a period.

A database can have multiple retention policies, but each policy must be unique.

Ii. InfluxDB Data Retention policy objective

The INFLUXDB itself does not provide data deletion, so the way to control the amount of data is to define a data retention policy.

The purpose of defining a data retention policy is therefore to allow influxdb to know what data can be discarded, thus processing the data more efficiently.

Third, InfluxDB data retention policy operations

1) Query Policy

You can view the existing policies for the database by using the following statement:

> SHOW RETENTION Policies on Telegrafname    duration    shardgroupduration    replican    DefaultDefault    0        168h0m0s        1        True

As you can see, Telegraf has only one policy, the meanings of each field are as follows:

name--name, this example name is default

duration--Duration, 0 means no Limit

Shardgroupduration--shardgroup storage time, Shardgroup is a basic storage structure of influxdb, should be greater than this time of the data in the query efficiency should be decreased.

replican--full name is replication, number of copies

default--is the default policy

2) New policy

> CREATE RETENTION POLICY "2_hours" on "Telegraf" DURATION 2h REPLICATION 1 default> SHOW RETENTION policies on Tele Grafname    duration    shardgroupduration    replican    defaultdefault    0        168h0m0s        1        false2_hours    2h0m0s        1h0m0s            1        True

The above statement can add a policy, this example adds a 2-hour policy in the Telegraf library, named 2_hours, duration for 2 hours, and a copy of 1, set as the default policy.

Because a policy named default is no longer a defaults policy, you explicitly add the policy name "default" when querying tables that use the default policy.

> select * from "Default". CPU Limit 2NAME:CPU---------time            CPU        host                host_id    usage_guest    usage _guest_nice    usage_idle   usage_iowait        usage_irq    usage_nice        usage_softirq    usage_steal    usage_system        usage_user1467884670000000000    cpu-total    resourcepool-0246-billing07        0        0            99.79994164175388    0            0        0.06251823446523729    0        0        0.12920435125646068    0.0083357646034517271467884670000000000    cpu9        billing07                0        0            97.79338014069532    1.8054162487519367    0        0            0        0        0.10030090272883943    0.3009027081135398

3) Modify the policy

Modify the policy using the following statement to modify

> ALTER RETENTION POLICY "2_hours" on "Telegraf" DURATION 4h default> show RETENTION policies on Telegrafname    du Ration    shardgroupduration    replican    defaultdefault    0        168h0m0s        1        false2_hours    4h0m0s        1h0m0s            1        True

As you can see, the modified policy has changed.

4) Delete Policy

The deletion of the policy in Influxdb is as follows:

> Drop retention POLICY "2_hours" on "Telegraf" > Show retention Policies on Telegrafname    duration    shardgr Oupduration    replican    defaultdefault    0        168h0m0s        1        false

As you can see, the policy named 2_hours has been removed.

Iv. Other Notes

Strategy this keyword "policy" in use should be uppercase, lowercase should be bold.

When a table uses a policy other than the default policy, you must explicitly specify the policy name when you do the operation, or an error occurs.

OK, about the INFLUXDB Data retention policy (Retention policies) related content first introduced here, has the question to welcome the message discussion to everybody.

For more Influxdb detailed tutorials See: INFLUXDB Series Learning Tutorials Catalogue

INFLUXDB Technology Group: 580487672 (click to join)

INFLUXDB Learning INFLUXDB Data Retention policy (Retention policies)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.