Note that /var/lib/influxdb is the default folder for a Linux installation. You need to modify it depending on your configuration. If you need to restore a backup on your Scalingo server, please contact our support at support@scalingo.com. Why you cannot manage the backups for InfluxDB on Scalingo. InfluxDB v2.0 is the latest stable version. InfluxQL offers a full suite of administrative commands. If you’re looking for SHOW queries (for example, SHOW DATABASES or SHOW RETENTION POLICIES), see Schema Exploration. The examples in the sections below use the InfluxDB Command Line Interface (CLI).
This is archived documentation for InfluxData product versions that are no longer maintained.For newer documentation, see the latest InfluxData documentation.
PDF - Download influxdb for free Previous Next. This modified text is an extract of the original Stack Overflow Documentation created by following contributors and released under CC BY-SA 3.0. This website is not affiliated with Stack Overflow.
The InfluxDB configuration file contains configuration settings specific to a local node.
Using Configuration Files
The system has internal defaults for every configuration file setting.View the default configuration settings with the influxd config
command.
Most of the settings in the local configuration file(/etc/influxdb/influxdb.conf
) are commented out; allcommented-out settings will be determined by the internal defaults.Any uncommented settings in the local configuration file override theinternal defaults.If you uncomment and configure a setting you will also need touncomment that setting’s section headerfor that setting to take effect.Note that the local configuration file does not need to include everyconfiguration setting.
There are two ways to launch InfluxDB with your configuration file:
Point the process to the correct configuration file by using the
-config
option:Set the environment variable
INFLUXDB_CONFIG_PATH
to the path of yourconfiguration file and start the process.For example:
InfluxDB first checks for the -config
option and then for the environmentvariable.
Environment variables
All configuration options can be specified in the configuration file or in anenvironment variable.The environment variable overrides the equivalent option in the configurationfile.If a configuration option is not specified in either the configuration fileor in an environment variable, InfluxDB uses its internal defaultconfiguration.
In the sections below we name the relevant environment variable in thedescription for the configuration setting.
Note:To set or override settings in a config section that allows multipleconfigurations (any section with [[double_brackets
]] in the header supportsmultiple configurations), the desired configuration must be specified by ordinalnumber.For example, for the first set of [[graphite]]
environment variables,prefix the configuration setting name in the environment variable with therelevant position number (in this case: 0
):
For the Nth Graphite configuration in the configuration file, the relevantenvironment variables would be of the form INFLUXDB_GRAPHITE_(N-1)_BATCH_PENDING
.For each section of the configuration file the numbering restarts at zero.
Configuration Sections
Configuration Options
Every configuration section has configuration options.Every configuration option is optional.If a configuration option is not provided, its default value will be used.All configuration options listed below are set to their default value.
Note: This page documents configuration options for the latest official release - the sample configuration file on GitHub will always be slightly ahead of what is documented here.
Global Options
reporting-disabled = false
InfluxData, the company, relies on reported data from running nodesprimarily to track the adoption rates of different InfluxDB versions.This data helps InfluxData support the continuing development ofInfluxDB.
The reporting-disabled
option togglesthe reporting of data every 24 hours to usage.influxdata.com
.Each report includes a randomly-generated identifier, OS, architecture,InfluxDB version, and thenumber of databases,measurements, andunique series. Settingthis option to true
will disable reporting.
Note: No data from user databases is ever transmitted.
Environment variable: INFLUXDB_REPORTING_DISABLED
bind-address = “:8088”
This is the port that backup/restore will use.
Environment variable: INFLUXDB_BIND_ADDRESS
[meta]
This section controls parameters for InfluxDB’s metastore,which stores information on users, databases, retention policies, shards, andcontinuous queries.
dir = “/var/lib/influxdb/meta”
The meta
directory.Files in the meta
directory include meta.db
.
Note: The default directory for macOS installations is /Users/<username>/.influxdb/meta
Environment variable: INFLUXDB_META_DIR
retention-autocreate = true
Retention policy auto-creation automatically creates the DEFAULT
retention policyautogen
when a database is created.The retention policy autogen
has an infinite duration and is also set as thedatabase’s DEFAULT
retention policy, which is used when a write or query doesnot specify a retention policy.Disable this setting to prevent the creation of this retention policy when creating databases.
Environment variable: INFLUXDB_META_RETENTION_AUTOCREATE
logging-enabled = true
Meta logging toggles the logging of messages from the meta service.
Environment variable: INFLUXDB_META_LOGGING_ENABLED
[data]
This section controls where the actual shard data for InfluxDB lives and how it is flushed from the WAL. dir
may need to be changed to a suitable place for you system, but the WAL settings are an advanced configuration. The defaults should work for most systems.
dir = “/var/lib/influxdb/data”
The directory where InfluxDB stores the data.This directory may be changed.
Note: The default directory for macOS installations is /Users/<username>/.influxdb/data
Environment variable: INFLUXDB_DATA_DIR
wal-dir = “/var/lib/influxdb/wal”
The WAL directory is the location of the write ahead log.
Environment variable: INFLUXDB_DATA_WAL_DIR
query-log-enabled = true
The query log enabled setting toggles the logging of parsed queries before execution.Very useful for troubleshooting, but will log any sensitive data contained within a query.
Environment variable: INFLUXDB_DATA_QUERY_LOG_ENABLED
cache-max-memory-size = 1048576000
The cache maximum memory size is the maximum size (in bytes) a shard’s cache can reach before it starts rejecting writes.
Environment variable: INFLUXDB_DATA_CACHE_MAX_MEMORY_SIZE
cache-snapshot-memory-size = 26214400
The cache snapshot memory size is the size at which the engine will snapshot the cache and write it to a TSM file, freeing up memory.
Environment variable: INFLUXDB_DATA_CACHE_SNAPSHOT_MEMORY_SIZE
cache-snapshot-write-cold-duration = “10m”
The cache snapshot write cold duration is the length of time at which the engine will snapshot the cache and write it to a new TSM file if the shard hasn’t received writes or deletes.
Environment variable: INFLUXDB_DATA_CACHE_SNAPSHOT_WRITE_COLD_DURATION
compact-full-write-cold-duration = “4h”
The compact full write cold duration is the duration at which the engine will compact all TSM files in a shard if it hasn’t received a write or delete.
Environment variable: INFLUXDB_DATA_COMPACT_FULL_WRITE_COLD_DURATION
max-series-per-database = 1000000
The maximum number of series allowedper database.The default setting is one million.Change the setting to 0
to allow an unlimited number of series per database.
If a point causes the number of series in a database to exceedmax-series-per-database
InfluxDB will not write the point, and it returns a500
with the following error:
Note: Any existing databases with a series count that exceeds max-series-per-database
will continue to accept writes to existing series, but writes that create anew series will fail.
Environment variable: INFLUXDB_DATA_MAX_SERIES_PER_DATABASE
max-values-per-tag = 100000
The maximum number of tag valuesallowed per [tag key]((/influxdb/v1.1/concepts/glossary/#tag-key).The default setting is 100000
.Change the setting to 0
to allow an unlimited number of tag values per tagkey.If a tag value causes the number of tag values of a tag key to exceedmax-values-per-tag
InfluxDB will not write the point, and it returnsa partial write
error.
Any existing tag keys with tag values that exceed max-values-per-tag
will continue to accept writes, but writes that create a new tag valuewill fail.
Environment variable: INFLUXDB_DATA_MAX_VALUES_PER_TAG
trace-logging-enabled = false
Toggles logging of additional debug information within the TSM engine and WAL.
Environment variable: INFLUXDB_DATA_TRACE_LOGGING_ENABLED
[coordinator]
This section contains configuration options for query management.For more on managing queries, see Query Management.
write-timeout = “10s”

The time within which a write request must complete on the cluster.
Environment variable: INFLUXDB_COORDINATOR_WRITE_TIMEOUT
max-concurrent-queries = 0
The maximum number of running queries allowed on your instance.The default setting (0
) allows for an unlimited number of queries.
Environment variable: INFLUXDB_COORDINATOR_MAX_CONCURRENT_QUERIES
query-timeout = “0”
The maximum time for which a query can run on your instance before InfluxDBkills the query.The default setting (0
) allows queries to run with no time restrictions.This setting is a duration literal.
Environment variable: INFLUXDB_COORDINATOR_QUERY_TIMEOUT
log-queries-after = “0”
The maximum time a query can run after which InfluxDB logs the query with aDetected slow query
message.The default setting ('0'
) will never tell InfluxDB to log the query.This setting is aduration literal.
Environment variable: INFLUXDB_COORDINATOR_LOG_QUERIES_AFTER
max-select-point = 0
The maximum number of points that aSELECT
statement can process.The default setting (0
) allows the SELECT
statement to process an unlimitednumber of points.
Environment variable: INFLUXDB_COORDINATOR_MAX_SELECT_POINT
max-select-series = 0
The maximum number of series that aSELECT
statement can process.The default setting (0
) allows the SELECT
statement to process an unlimitednumber of series.
Environment variable: INFLUXDB_COORDINATOR_MAX_SELECT_SERIES
max-select-buckets = 0
The maximum number of GROUP BY time()
buckets that a query can process.The default setting (0
) allows a query to process an unlimited number ofbuckets.
Environment variable: INFLUXDB_COORDINATOR_MAX_SELECT_BUCKETS
[retention]
This section controls the enforcement of retention policies for evicting old data.
enabled = true
Set to false
to prevent InfluxDB from enforcing retention policies.
Environment variable: INFLUXDB_RETENTION_ENABLED
check-interval = “30m0s”
The rate at which InfluxDB checks to enforce a retention policy.
Environment variable: INFLUXDB_RETENTION_CHECK_INTERVAL
[shard-precreation]
Controls the precreation of shards so that shards are available before data arrive.Only shards that, after creation, will have both a start- and end-time in the future are ever created.Shards that would be wholly or partially in the past are never precreated.
enabled = true
Environment variable: INFLUXDB_SHARD_PRECREATION_ENABLED
check-interval = “10m0s”
Environment variable: INFLUXDB_SHARD_PRECREATION_CHECK_INTERVAL
advance-period = “30m0s”

The maximum period in the future for which InfluxDB precreates shards.The 30m
default should work for most systems.Increasing this setting too far in the future can cause inefficiencies.
Environment variable: INFLUXDB_SHARD_PRECREATION_ADVANCE_PERIOD
[admin]
Controls the availability of the built-in, web-based admin interface.
Note: The Admin UI is deprecated as of InfluxDB 1.1 and will be removed entirely in a subsequent version.
enabled = false
Set to true
to enable the admin interface.
Environment variable: INFLUXDB_ADMIN_ENABLED
bind-address = “:8083”
The port used by the admin interface.
Environment variable: INFLUXDB_ADMIN_BIND_ADDRESS
https-enabled = false
Set to true
to enable HTTPS for the admin interface.
Note: HTTPS must be enable for the [http] service for the admin UI to function properly using HTTPS.
Environment variable: INFLUXDB_ADMIN_HTTPS_ENABLED
https-certificate = “/etc/ssl/influxdb.pem”
The path of the certificate file.
Environment variable: INFLUXDB_ADMIN_HTTPS_CERTIFICATE
[monitor]
This section controls InfluxDB’s system self-monitoring.
By default, InfluxDB writes the data to the _internal
database.If that database does not exist, InfluxDB creates it automatically.The DEFAULT
retention policy on the _internal
database is seven days.If you want to use a retention policy other than the seven-day retention policy, you must create it.
store-enabled = true
Set to false
to disable recording statistics internally.If set to false
it will make it substantially more difficult to diagnose issues with your installation.
Environment variable: INFLUXDB_MONITOR_STORE_ENABLED
store-database = “_internal”
The destination database for recorded statistics.
Environment variable: INFLUXDB_MONITOR_STORE_DATABASE
store-interval = “10s”
The interval at which InfluxDB records statistics.
Environment variable: INFLUXDB_MONITOR_STORE_INTERVAL
[subscriber]
This section controls how Kapacitor will receive data.
enabled = true
Set to false
to disable the subscriber service.
Environment variable: INFLUXDB_SUBSCRIBER_ENABLED
http-timeout = “30s”
Controls how long an http request for the subscriber service will run before it times out.
Environment variable: INFLUXDB_SUBSCRIBER_HTTP_TIMEOUT
insecure-skip-verify = false
Allows insecure HTTPS connections to subscribers.This is useful when testing with self-signed certificates.
Environment variable: INFLUXDB_SUBSCRIBER_INSECURE_SKIP_VERIFY
ca-certs = “”
The path to the PEM encoded CA certs file.If the empty string, the default system certs will be used.
Environment variable: INFLUXDB_SUBSCRIBER_CA_CERTS
write-concurrency = 40
The number of writer goroutines processing the write channel.
Environment variable: INFLUXDB_SUBSCRIBER_WRITE_CONCURRENCY
write-buffer-size = 1000
The number of in-flight writes buffered in the write channel.
Environment variable: INFLUXDB_SUBSCRIBER_WRITE_BUFFER_SIZE
[http]
This section controls how InfluxDB configures the HTTP endpoints.These are the primary mechanisms for getting data into and out of InfluxDB.Edit the options in this section to enable HTTPS and authentication.See Authentication and Authorization.
enabled = true
Set to false
to disable HTTP.Note that the InfluxDB command line interface (CLI) connects to the database using the HTTP API.
Environment variable: INFLUXDB_HTTP_ENABLED
bind-address = “:8086”
The port used by the HTTP API.
Environment variable: INFLUXDB_HTTP_BIND_ADDRESS
auth-enabled = false
Set to true
to require authentication.
Environment variable: INFLUXDB_HTTP_AUTH_ENABLED
log-enabled = true
Set to false
to disable logging.
Environment variable: INFLUXDB_HTTP_LOG_ENABLED
write-tracing = false
Set to true
to enable logging for the write payload.If set to true
, this will duplicate every write statement in the logs and is thus not recommended for general use.
Environment variable: INFLUXDB_HTTP_WRITE_TRACING
pprof-enabled = true
Determines whether the pprof endpoint is enabled. This endpoint is used fortroubleshooting and monitoring.
Environment variable: INFLUXDB_HTTP_PPROF_ENABLED
https-enabled = false
Set to true
to enable HTTPS.
Environment variable: INFLUXDB_HTTP_HTTPS_ENABLED
https-certificate = “/etc/ssl/influxdb.pem”
The path of the certificate file.
Environment variable: INFLUXDB_HTTP_HTTPS_CERTIFICATE
https-private-key = “”
The separate private key location.If only the https-certificate
is specified, the httpd service will try to loadthe private key from the https-certificate
file.If a separate https-private-key
file is specified, the httpd service will loadthe private key from the https-private-key
file.
Environment variable: INFLUXDB_HTTP_HTTPS_PRIVATE_KEY
max-row-limit = 10000
This limits the number of rows that can be returned in a non-chunked query.
Environment variable: INFLUXDB_HTTP_MAX_ROW_LIMIT
max-connection-limit = 0
Limit the number of connections for the http service. 0 is unlimited.
Environment variable: INFLUXDB_HTTP_MAX_CONNECTION_LIMIT
shared-secret = “”
The shared secret used for JWT signing.
Environment variable: INFLUXDB_HTTP_SHARED_SECRET
realm = “InfluxDB”
Realm is the JWT realm used by the http endpoint.
Environment variable: INFLUXDB_HTTP_REALM
unix-socket-enabled = false
Set to true
to enable http service over unix domain socket.
Environment variable: INFLUXDB_HTTP_UNIX_SOCKET_ENABLED
bind-socket = “/var/run/influxdb.sock”
The path of the unix domain socket.
Environment variable: INFLUXDB_HTTP_UNIX_BIND_SOCKET
[[graphite]]
This section controls one or many listeners for Graphite data.See the README on GitHub for more information.
enabled = false
Set to true
to enable Graphite input.
Environment variable: INFLUXDB_GRAPHITE_0_ENABLED
bind-address = “:2003”
The default port.
Environment variable: INFLUXDB_GRAPHITE_0_BIND_ADDRESS
database = “graphite”
The name of the database that you want to write to.
Environment variable: INFLUXDB_GRAPHITE_0_DATABASE
retention-policy = “”
The relevant retention policy.An empty string is equivalent to the database’s DEFAULT
retention policy.
Environment variable: INFLUXDB_GRAPHITE_0_RETENTION_POLICY
protocol = “tcp”

Set to tcp
or udp
.
Environment variable: INFLUXDB_GRAPHITE_PROTOCOL
The next three options control how batching works.You should have this enabled otherwise you could get dropped metrics or poor performance.Batching will buffer points in memory if you have many coming in.
batch-size = 5000
The input will flush if this many points get buffered.
Environment variable: INFLUXDB_GRAPHITE_BATCH_SIZE
batch-pending = 10
The number of batches that may be pending in memory.
Environment variable: INFLUXDB_GRAPHITE_BATCH_PENDING
batch-timeout = “1s”
The input will flush at least this often even if it hasn’t reached the configured batch-size.
Environment variable: INFLUXDB_GRAPHITE_BATCH_TIMEOUT
consistency-level = “one”
The number of nodes that must confirm the write.If the requirement is not met the return value will be either partial write
if some points in the batch fail or write failure
if all points in the batch fail.For more information, see the Query String Parameters for Writes section in the Line Protocol Syntax Reference .
Environment variable: INFLUXDB_GRAPHITE_CONSISTENCY_LEVEL
separator = “.”
This string joins multiple matching ‘measurement’ values providing more control over the final measurement name.
Environment variable: INFLUXDB_GRAPHITE_SEPARATOR
udp-read-buffer = 0
UDP Read buffer size, 0 means OS default.UDP listener will fail if set above OS max.
Environment variable: INFLUXDB_GRAPHITE_UDP_READ_BUFFER
[[collectd]]
This section controls the listener for collectd data. See theREADMEon Github for more information.
enabled = false
Set to true
to enable collectd writes.
Environment variable: INFLUXDB_COLLECTD_ENABLED
bind-address = “:25826”
The port.
Environment variable: INFLUXDB_COLLECTD_BIND_ADDRESS
database = “collectd”
The name of the database that you want to write to.This defaults to collectd
.
Environment variable: INFLUXDB_COLLECTD_DATABASE
The next three options control how batching works.You should have this enabled otherwise you could get dropped metrics or poor performance.Batching will buffer points in memory if you have many coming in.
retention-policy = “”
The relevant retention policy.An empty string is equivalent to the database’s DEFAULT
retention policy.
Environment variable: INFLUXDB_COLLECTD_RETENTION_POLICY
batch-size = 5000
The input will flush if this many points get buffered.
Environment variable: INFLUXDB_COLLECTD_BATCH_SIZE
batch-pending = 10
The number of batches that may be pending in memory.
Environment variable: INFLUXDB_COLLECTD_BATCH_PENDING
batch-timeout = “10s”
The input will flush at least this often even if it hasn’t reached the configured batch-size.
Environment variable: INFLUXDB_COLLECTD_BATCH_TIMEOUT
read-buffer = 0
UDP Read buffer size, 0 means OS default.UDP listener will fail if set above OS max.
Environment variable: INFLUXDB_COLLECTD_READ_BUFFER
typesdb = “/usr/share/collectd/types.db”
Defaults to /usr/share/collectd/types.db
. A sample types.db
filecan be foundhere.
Environment variable: INFLUXDB_COLLECTD_TYPESDB
[[opentsdb]]
Controls the listener for OpenTSDB data.See the README on GitHub for more information.
enabled = false
Set to true
to enable openTSDB writes.
Environment variable: INFLUXDB_OPENTSDB_0_ENABLED
bind-address = “:4242”
The default port.
Environment variable: INFLUXDB_OPENTSDB_BIND_ADDRESS
database = “opentsdb”
The name of the database that you want to write to.If the database does not exist, it will be created automatically when the input is initialized.
Environment variable: INFLUXDB_OPENTSDB_DATABASE
retention-policy = “”
The relevant retention policy.An empty string is equivalent to the database’s DEFAULT
retention policy.
Environment variable: INFLUXDB_OPENTSDB_RETENTION_POLICY
consistency-level = “one”
Sets the write consistency level: any
, one
, quorum
, or all
for writes.
Environment variable: INFLUXDB_OPENTSDB_CONSISTENCY_LEVEL
tls-enabled = false
Environment variable: INFLUXDB_OPENTSDB_TLS_ENABLED
certificate = “/etc/ssl/influxdb.pem”
Environment variable: INFLUXDB_OPENTSDB_CERTIFICATE
The next three options control how batching works.You should have this enabled otherwise you could get dropped metrics or poor performance.Only points metrics received over the telnet protocol undergo batching.
batch-size = 1000

The input will flush if this many points get buffered.
Environment variable: INFLUXDB_OPENTSDB_BATCH_SIZE
batch-pending = 5
The number of batches that may be pending in memory.
Environment variable: INFLUXDB_OPENTSDB_BATCH_PENDING
batch-timeout = “1s”
Metabase Query Builder
The input will flush at least this often even if it hasn’t reached the configured batch-size.
Environment variable: INFLUXDB_OPENTSDB_BATCH_TIMEOUT
log-point-errors = true
Log an error for every malformed point.
Environment variable: INFLUXDB_OPENTSDB_0_LOG_POINT_ERRORS
[[udp]]
This section controls the listeners for InfluxDB line protocol data via UDP.See the UDP page for more information.
enabled = false
Set to true
to enable writes over UDP.
Environment variable: INFLUXDB_UDP_ENABLED
bind-address = “:8089”
An empty string is equivalent to 0.0.0.0
.
Environment variable: INFLUXDB_UDP_BIND_ADDRESS
database = “udp”
The name of the database that you want to write to.
Environment variable: INFLUXDB_UDP_DATABASE
retention-policy = “”
The relevant retention policy for your data.An empty string is equivalent to the database’s DEFAULT
retention policy.
Environment variable: INFLUXDB_UDP_RETENTION_POLICY
The next three options control how batching works.You should have this enabled otherwise you could get dropped metrics or poor performance.Batching will buffer points in memory if you have many coming in.
batch-size = 5000
The input will flush if this many points get buffered.
Environment variable: INFLUXDB_UDP_0_BATCH_SIZE
batch-pending = 10
The number of batches that may be pending in memory.
Environment variable: INFLUXDB_UDP_0_BATCH_PENDING
read-buffer = 0
UDP read buffer size, 0 means OS default.UDP listener will fail if set above OS max.
Environment variable: INFLUXDB_UDP_BATCH_SIZE
batch-timeout = “1s”
The input will flush at least this often even if it hasn’t reached the configured batch-size.
Environment variable: INFLUXDB_UDP_BATCH_TIMEOUT
precision = “”
Time precision used when decoding time values. Defaults to nanoseconds
which is the default of the database.
Environment variable: INFLUXDB_UDP_PRECISION
[continuous_queries]
This section controls how continuous queries (CQs) run within InfluxDB.CQs are automated batches of queries that execute over recent time intervals.InfluxDB executes one auto-generated query per GROUP BY time()
interval.
log-enabled = true
Set to false
to disable logging for CQ events.
Environment variable: INFLUXDB_CONTINUOUS_QUERIES_LOG_ENABLED
enabled = true
Set to false
to disable CQs.
Environment variable: INFLUXDB_CONTINUOUS_QUERIES_ENABLED
run-interval = “1s”
The interval at which InfluxDB checks to see if a CQ needs to run. Set this option to the lowest interval at which your CQs run. For example, if your most frequent CQ runs every minute, set run-interval
to 1m
.
Environment variable: INFLUXDB_CONTINUOUS_QUERIES_RUN_INTERVAL
This page documents an earlier version of InfluxDB.InfluxDB v2.0 is the latest stable version.
InfluxQL offers a full suite of administrative commands.
Data Management: | Retention Policy Management: |
CREATE DATABASE | CREATE RETENTION POLICY |
DROP DATABASE | ALTER RETENTION POLICY |
DROP SERIES | DROP RETENTION POLICY |
DELETE | |
DROP MEASUREMENT | |
DROP SHARD |
If you’re looking for SHOW
queries (for example, SHOW DATABASES
or SHOW RETENTION POLICIES
), see Schema Exploration.
The examples in the sections below use the InfluxDB Command Line Interface (CLI).You can also execute the commands using the InfluxDB API; simply send a GET
request to the /query
endpoint and include the command in the URL parameter q
.For more on using the InfluxDB API, see Querying data.
Note: When authentication is enabled, only admin users can execute most of the commands listed on this page.See the documentation on authentication and authorization for more information.
Data management
CREATE DATABASE
Creates a new database.
Syntax
Description of syntax
CREATE DATABASE
requires a database name.
The WITH
, DURATION
, REPLICATION
, SHARD DURATION
, and NAME
clauses are optional and create a single retention policy associated with the created database.If you do not specify one of the clauses after WITH
, the relevant behavior defaults to the autogen
retention policy settings.The created retention policy automatically serves as the database’s default retention policy.For more information about those clauses, see Retention Policy Management.
A successful CREATE DATABASE
query returns an empty result.If you attempt to create a database that already exists, InfluxDB does nothing and does not return an error.
Examples
Create a database
The query creates a database called NOAA_water_database
.By default, InfluxDB also creates the autogen
retention policy and associates it with the NOAA_water_database
.
Create a database with a specific retention policy
The query creates a database called NOAA_water_database
.It also creates a default retention policy for NOAA_water_database
with a DURATION
of three days, a replication factor of one, a shard group duration of one hour, and with the name liquid
.
Delete a database with DROP DATABASE
The DROP DATABASE
query deletes all of the data, measurements, series, continuous queries, and retention policies from the specified database.The query takes the following form:
Drop the database NOAA_water_database:
A successful DROP DATABASE
query returns an empty result.If you attempt to drop a database that does not exist, InfluxDB does not return an error.
Drop series from the index with DROP SERIES
The DROP SERIES
query deletes all points from a series in a database,and it drops the series from the index.
The query takes the following form, where you must specify either the FROM
clause or the WHERE
clause:
Drop all series from a single measurement:
Drop series with a specific tag pair from a single measurement:
Drop all points in the series that have a specific tag pair from all measurements in the database:
A successful DROP SERIES
query returns an empty result.
Delete series with DELETE
The DELETE
query deletes all points from aseries in a database.UnlikeDROP SERIES
, DELETE
does not drop the series from the index.
You must include either the FROM
clause, the WHERE
clause, or both:
Delete all data associated with the measurement h2o_feet
:
Delete all data associated with the measurement h2o_quality
and where the tag randtag
equals 3
:
Delete all data in the database that occur before January 01, 2020:
A successful DELETE
query returns an empty result.
Things to note about DELETE
:
DELETE
supportsregular expressionsin theFROM
clause when specifying measurement names and in theWHERE
clausewhen specifying tag values.DELETE
does not support fields in theWHERE
clause.- If you need to delete points in the future, you must specify that time period as
DELETE SERIES
runs fortime < now()
by default. Syntax
Delete measurements with DROP MEASUREMENT
The DROP MEASUREMENT
query deletes all data and series from the specified measurement and deletes themeasurement from the index.
The query takes the following form:
Delete the measurement h2o_feet
:
Note:DROP MEASUREMENT
drops all data and series in the measurement.It does not drop the associated continuous queries.
A successful DROP MEASUREMENT
query returns an empty result.
Currently, InfluxDB does not support regular expressions with DROP MEASUREMENTS
.See GitHub Issue #4275 for more information.
Delete a shard with DROP SHARD
The DROP SHARD
query deletes a shard. It also drops the shard from themetastore.The query takes the following form:
Delete the shard with the id 1
:
A successful DROP SHARD
query returns an empty result.InfluxDB does not return an error if you attempt to drop a shard that does notexist.
Retention policy management
The following sections cover how to create, alter, and delete retention policies.Note that when you create a database, InfluxDB automatically creates a retention policy named autogen
which has infinite retention.You may disable its auto-creation in the configuration file.
Create retention policies with CREATE RETENTION POLICY
Syntax
Description of syntax
DURATION
- The
DURATION
clause determines how long InfluxDB keeps the data.The<duration>
is a duration literalorINF
(infinite).The minimum duration for a retention policy is one hour and the maximumduration isINF
.
REPLICATION
The
REPLICATION
clause determines how many independent copies of each pointare stored in the cluster.By default, the replication factor
n
usually equals the number of data nodes. However, if you have four or more data nodes, the default replication factorn
is 3.To ensure data is immediately available for queries, set the replication factor
n
to less than or equal to the number of data nodes in the cluster.
Important: If you have four or more data nodes, verify that the database replication factor is correct.
- Replication factors do not serve a purpose with single node instances.
SHARD DURATION
- Optional. The
SHARD DURATION
clause determines the time range covered by a shard group. - The
<duration>
is a duration literaland does not support anINF
(infinite) duration. - By default, the shard group duration is determined by the retention policy’s
DURATION
:
Retention Policy’s DURATION | Shard Group Duration |
---|---|
< 2 days | 1 hour |
>= 2 days and <= 6 months | 1 day |
> 6 months | 7 days |
The minimum allowable SHARD GROUP DURATION
is 1h
.If the CREATE RETENTION POLICY
query attempts to set the SHARD GROUP DURATION
to less than 1h
and greater than 0s
, InfluxDB automatically sets the SHARD GROUP DURATION
to 1h
.If the CREATE RETENTION POLICY
query attempts to set the SHARD GROUP DURATION
to 0s
, InfluxDB automatically sets the SHARD GROUP DURATION
according to the default settings listed above.
SeeShard group duration managementfor recommended configurations.
Metbase
DEFAULT
Sets the new retention policy as the default retention policy for the database.This setting is optional.
Examples
Create a retention policy
The query creates a retention policy called one_day_only
for the databaseNOAA_water_database
with a one day duration and a replication factor of one.
Create a DEFAULT retention policy
The query creates the same retention policy as the one in the example above, butsets it as the default retention policy for the database.
A successful CREATE RETENTION POLICY
query returns an empty response.If you attempt to create a retention policy identical to one that already exists, InfluxDB does not return an error.If you attempt to create a retention policy with the same name as an existing retention policy but with differing attributes, InfluxDB returns an error.
Note: You can also specify a new retention policy in the CREATE DATABASE
query.See Create a database with CREATE DATABASE.
Modify retention policies with ALTER RETENTION POLICY
The ALTER RETENTION POLICY
query takes the following form, where you must declare at least one of the retention policy attributes DURATION
, REPLICATION
, SHARD DURATION
, or DEFAULT
:
Replication factors do not serve a purpose with single node instances.
First, create the retention policy what_is_time
with a DURATION
of two days:
Modify what_is_time
to have a three week DURATION
, a two hour shard group duration, and make it the DEFAULT
retention policy for NOAA_water_database
.
In the last example, what_is_time
retains its original replication factor of 1.
A successful ALTER RETENTION POLICY
query returns an empty result.
Delete retention policies with DROP RETENTION POLICY
Delete all measurements and data in a specific retention policy:
Dropping a retention policy will permanently delete all measurements and data stored in the retention policy.
Delete the retention policy what_is_time
in the NOAA_water_database
database:
A successful DROP RETENTION POLICY
query returns an empty result.If you attempt to drop a retention policy that does not exist, InfluxDB does not return an error.
Support and feedback
Thank you for being part of our community!We welcome and encourage your feedback and bug reports for InfluxDB and this documentation.To find support, the following resources are available:
InfluxDB Cloud and InfluxDB Enterprise customers can contact InfluxData Support.
