Docs Menu
Docs Home
/
MongoDB Compass
/ /

Create a Time Series Collection

On this page

  • Procedure
  • Restrictions and Limitations

Time series collections efficiently store sequences of measurements over a period of time.

1

From the Collections screen, click the Create Collection button.

2
3
4

Specify which field should be used as the timeField for the time-series collection. This field must have a BSON type date.

5

Specify the name of the field that contains metadata in each time series document. The metadata in the specified field should be data that is used to label a unique series of documents.

6

Specify a coarser granularity so measurements over a longer time span can be more efficiently stored and queried. The default value is "seconds".

If you set the granularity parameter, you can't set the bucketMaxSpanSeconds and bucketRoundingSeconds parameters.

7
Field
Type
Description
bucketMaxSpanSeconds
number

Specifies the maximum time span between measurements in a bucket.

The value of bucketMaxSpanSeconds must be the same as bucketRoundingSeconds. If you set the bucketMaxSpanSeconds, parameter, you can't set the granularity parameter.

bucketRoundingSeconds
number

Specifies the time interval that determines the starting timestamp for a new bucket.

The value of bucketRoundingSeconds must be the same as bucketMaxSpanSeconds. If you set the bucketRoundingSeconds, parameter, you can't set the granularity parameter.

expireAfterSeconds
number
Enables the automatic deletion of documents that are older than the specified number of seconds.
8

Your collection will be marked by a time series badge.

For more information on time series fields, see Time Series Object Fields.

The following restrictions and limitations apply when creating a time series collection:

  • Custom collation is the only Advanced Collection Option that can be used alongside your time series collation.

  • See Time Series Collection Limitations for all time series collection limitations.

Back

Encrypted Collections