Access Logs

Every running MongoDB instance collects logs from MongoD. Currently, there is no option to change this configuration. The log messages are shipped to a central storage location with a retention policy of 30 days.

Using the cluster ID, you can access the logs for that cluster via the API.

Requesting logs

The endpoint for fetching logs has four optional query parameters:

ParameterDescriptionDefault valuePossible values

start

Retrieve log lines after this timestamp (format: RCF3339)

30 days ago

between 30 days ago and now (before end)

end

Retrieve log line before this timestamp (format: RFC3339)

now

between 30 days ago and now (after start)

direction

Direction in which the logs are sorted and limited

BACKWARD

BACKWARD or FORWARD

limit

Maximum number of log lines to retrieve. Which log lines are cut depends on direction

100

between 1 and 5000

If you omit all parameters, you will get the most recent 100 log messages.

The following example shows how to receive only the first two messages after 12:00 a.m. on January 5, 2022:

curl --include \
    --request GET \
    --user "clientname@ionos.com:Mb2.r5oHf-0t" \
    --header "Content-Type: application/json" \
    "https://api.ionos.com/databases/mongodb/clusters/498ae72f-411f-11eb-9d07-046c59cc737e/logs?start=2022-01-05T12:00:00Z&end=2022-01-05T13:00:00Z&direction=FORWARD&limit=2"

Response

The response contains the log messages separated per instance and looks similar to this:

{
  "instances": [
    {
      "name": "ionos-498ae72f-411f-11eb-9d07-046c59cc737e-by6qu3m-1",
      "messages": [
        {
          "time": "2022-01-05T12:00:29.793Z",
          "message": "{\"t\":{\"$date\":\"2022-01-05T12:00:29.793+00:00\"},\"s\":\"I\",  \"c\":\"NETWORK\",  \"id\":22943,   \"ctx\":\"listener\",\"msg\":\"Connection accepted\",\"attr\":{\"remote\":\"127.0.0.1:42562\",\"uuid\":\"4ff7c691-8aaa-4ef6-a37d-21386adcbdb0\",\"connectionId\":10751,\"connectionCount\":40}}"
        },
        {
          "time": "2022-01-05T12:00:29.794Z",
          "message": "{\"t\":{\"$date\":\"2022-01-05T12:00:29.794+00:00\"},\"s\":\"I\",  \"c\":\"NETWORK\",  \"id\":22944,   \"ctx\":\"conn10751\",\"msg\":\"Connection ended\",\"attr\":{\"remote\":\"127.0.0.1:42562\",\"uuid\":\"318a7948-4860-4420-ad64-5cd6178f990f\",\"connectionId\":10751,\"connectionCount\":40}}"
        }
      ]
    }
  ]
}

Last updated