Navigation

Get Measurements of a Database for a MongoDB Process

Get the measurements of the specified databases for a Atlas MongoDB process. A Atlas MongoDB process can be either a mongod or mongos.

The Atlas API uses HTTP Digest Authentication. Provide your Atlas username and group API key as the username and password when constructing the HTTP request.

For complete documentation on configuring API access for an Atlas group, see Configure Atlas API Access.

Base URL: https://cloud.mongodb.com/

Resource

GET api/atlas/v1.0/groups/{GROUP-ID}/processes/{HOST}:{PORT}/databases/{DATABASE-ID}/measurements

Request Path Parameters

Parameter Required/Optional Description
GROUP-ID Required ID of the group that owns this Atlas MongoDB process.
HOST Required The hostname of the machine running the Atlas MongoDB process.
PORT Required The port to which the Atlas MongoDB process listens.
DATABASE-ID Required The name of the database to retrieve measurements for.

Request Query Parameters

Field Required/Optional Description
granularity Required

An ISO-8601-formatted time period that specifies the interval between measurement data points. For example, PT1M specifies 1-minute granularity.

The supported values for this parameter are:

  • PT1M
  • PT5M
  • PT1H
  • P1D

When you specify granularity, you must specify either period or start and end.

period Required An ISO-8601-formatted time period that specifies the length of time in the past to query. For example, to request the last 36 hours, specify: period=P1DT12H. Mutually exclusive with start and end.
start Required The time at which to start retrieving measurements, as specified by an ISO-8601 timestamp string. If you specify start you must also specify end. Mutually exclusive with period.
end Required The time at which to stop retrieving measurements, as specified by an ISO-8601 timestamp string. If you specify end you must also specify start. Mutually exclusive with period.
m Optional

Specifies which measurements to return. If m is not specified, all measurements are returned.

To specify multiple values for m, you must repeat the m parameter. For example:

../measurements?m=<measurement>&m=<measurement>&m=...

You must specify measurements that are valid for the host. Atlas returns an error if any specified measurements are invalid For available measurements, see Measurement Values.

pageNum Optional.

The page to return.

Defaults to 1.

itemsPerPage Optional.

Maximum number of items to return per page.

Defaults to 100.

envelope Optional.

A boolean that specifies whether or not to wrap the response in an envelope.

Defaults to false.

pretty Optional

A boolean that specifies whether or not to return a “pretty-printed” JSON document.

Defaults to false.

Request Body Parameters

This endpoint does not use HTTP request body parameters.

Response Elements

Free Tier

M0 Free Tier clusters return a subset of the metrics documented here.

If you set the query element envelope to true, the response is wrapped by the content object.

The HTTP response returns a JSON document that includes the following objects:

Name Type Description
databaseName string The name of the database to which the measurements pertain.
end string The end of the period for which to retrieve measurements, specified as an ISO-8601 timestamp.
granularity string An ISO-8601-formatted time period that specifies the size of the interval covered by each data point. For example, PT5M specifies a 5-minute granularity.
groupId string ID of the group that owns the Atlas MongoDB process.
hostId string The hostname of the machine running the Atlas MongoDB process.
links array An array of documents, representing a link to one or more sub-resources and/or related resources such as list pagination. See Linking for more information.
measurements object array An array of measurements and their data points.
measurements.dataPoints object array An array of objects, where each object represents a single data point. If there is no data point available for a particular moment in time (i.e., a timestamp), the value field is set to null.
measurements.dataPoints.timestamp string The timestamp of the beginning of the time interval represented by this data point.
measurements.dataPoints.value float The value of the data point.
measurements.name string The name of the measurement. For possible values, see Measurement Values below on this page.
measurements.units string

How the measurement is quantified. Possible units are:

  • PERCENT
  • MILLISECONDS
  • BYTES
  • GIGABYTES
  • BYTES_PER_SECOND
  • MEGABYTES_PER_SECOND
  • GIGABYTES_PER_HOUR
  • SCALAR_PER_SECOND
  • SCALAR
processId string The hostname and port of the machine running the Atlas MongoDB process.
start string The start of the period for which to retrieve measurements, specified as an ISO-8601 timestamp.

Measurement Values

  • DATABASE_AVERAGE_OBJECT_SIZE
  • DATABASE_COLLECTION_COUNT
  • DATABASE_DATA_SIZE
  • DATABASE_STORAGE_SIZE
  • DATABASE_INDEX_SIZE
  • DATABASE_INDEX_COUNT
  • DATABASE_EXTENT_COUNT
  • DATABASE_OBJECT_COUNT
  • DATABASE_VIEW_COUNT
Measures the database’s on-disk storage space, as collected from the MongoDB dbStats command.

Example Request

Replace the information in brackets {} with your own Atlas information to execute this example request:

curl -u "<ATLAS-USERNAME>:<API-KEY>" --digest -i "https://cloud.mongodb.com/api/atlas/v1.0/groups/{GROUP-ID}/processes/{HOST}:{PORT}/databases/measurements?granularity=PT24H&period=PT24H&pretty=true"

Example Response

{
   "databaseName":"monitoring",
   "granularity":"PT1M",
   "groupId":"12345678",
   "hostId":"shard-00-00.mongodb.net:27017",
   "links":[
      {
         "href":"https://cloud.mongodb.com/api/atlas/v1.0/groups/12345678/processes/shard-00-00.mongodb.net:27017/databases/monitoring/measurements?granularity=PT24H&period=PT24H&pretty=true",
         "rel":"self"
      },
      {
         "href":"https://cloud.mongodb.com/api/atlas/v1.0/groups/12345678/processes/shard-00-00.mongodb.net:27017",
         "rel":"http://mms.mongodb.com/host"
      }
   ],
   "measurements":[
      {
         "dataPoints":[

         ],
         "name":"DATABASE_AVERAGE_OBJECT_SIZE",
         "units":"BYTES"
      },
      ...
   ],
   "processId":"shard-00-00.mongodb.net:27017"
}