Manage Edge Servers in Atlas - Preview
On this page
An Edge Server-compatible service is your Atlas destination to create, delete, or monitor your Edge Server instances.
There are two types of services that enable you to use Edge Server:
Edge Server Service: use this option if you want clients to connect to an Edge Server instance with MongoDB Drivers and tools. It infers and updates the schema from the documents you insert, and provides a developer experience familiar to MongoDB developers. This service is incompatible with Atlas Device SDK; it rejects incoming Atlas Device SDK connections.
Device Sync Service (with Edge Server): use this option if you want to develop client apps using Atlas Device SDK and MongoDB Drivers and tools. This option involves more strict schema enforcement, which the SDKs use to automatically sync objects across devices and handle conflict resolution.
Regardless of which type of service you choose, Edge Servers use Device Sync to sync data between the Edge Server instance and Atlas.
Important
You can't add Atlas Device SDK later to an Edge Server Service
You can always add Edge Servers to a Device Sync Service. But you can't use Atlas Device SDK connections with an Edge Server Service.
Users are not portable between services. If you start with an Edge Server Service, but later want to develop apps using Atlas Device SDK, there is no way to transfer any users in your Edge Service to a new Device Sync Service.
Before You Begin
You need the following to manage Edge Servers in the Atlas UI:
A MongoDB Atlas account with Project Owner permissions. To learn how to sign up for a free account, see Get Started with Atlas.
You need the following to manage Edge Servers with the Admin API:
A MongoDB Atlas account with Project Owner permissions. To learn how to sign up for a free account, see Get Started with Atlas.
A MongoDB Atlas Admin API public/private key pair. The API key must have Project Owner permissions to work with App Services Admin API.
Your App's internal ObjectId hex string and the Project ID of the Atlas Project that contains your App. To learn how to find these, see Get App Metadata.
Create a Service for Edge Server
You can create an Edge Server-compatible service in Data Services or App Services.
You might select Data Services when you just want to get started building with Edge Server or Device Sync and Edge Server, and don't need other App Services. You can create an Edge Server Service from Data Services.
You might select App Services when you want to bundle your service with authentication, Functions, Triggers, HTTPS Endpoints, or Values and Secrets. You can create a Device Sync Service from App Services, and add Edge Server to it.
Create a Service
Select the type of service you want to create, and follow the prompts to create an Edge Server Service or Device Sync Service.
After creating an Edge Server Service, you're able to immediately add Edge Server instances.
If you create a Device Sync Service, click Edge Server in the left navigation. This opens a list where you can add and view Edge Server instances.
Click the Add a server button, and follow the prompts to name and create your new Edge Server instance.
Create a Device Sync App
Refer to the documentation to Create an App Services App.
When you choose your App type, select Device Sync
. You can add
Edge Servers to your Device Sync App after you configure
Device Sync.
Add Edge Server Instances to Your Device Sync Service
While viewing your Device Sync Service, click Edge Server in the left navigation. This opens a list where you can add and view Edge Server instances.
Click the Add a server button, and follow the prompts to name and create your new Edge Server instance.
Important
Required Field
Documents that you want to sync with an Edge Server must contain an _id
field whose type varies depending on the service type:
Edge Server Service: Type
ObjectId
Device Sync Service: Type
ObjectId
,String
,Long
,Int
,UUID
Any documents without this field cannot sync to an Edge Server.
Supported Authentication Providers
Edge Server supports a subset of authentication providers. Supported authentication providers vary depending on whether you're connecting with Atlas Device SDK or using a MongoDB URI to connect with a MongoDB Driver or tool.
You must enable at least one of these providers to enable clients to connect to an Edge Server instance.
Supported Atlas Device SDK Authentication Providers
Supported MongoDB Driver Authentication Providers
Create an Edge Server Instance
After creating an Edge Server-compatible service, you can add Edge Servers to it. The service can handle multiple Edge Servers, each of which has its own registration key.
Add a server
Click Add a server. You're prompted to name your Edge Server.
The UI provides an installation script, which you can copy and paste into the terminal on the device where you want to install the Edge Server code. You also get a token, which you will use when you configure the Edge Server instance.
Install and Configure the Edge Server code
Copy and paste the installation script into the terminal on the device where you want to install the Edge Server code. For more details, refer to Install and Configure the Edge Server Instance.
After you configure and start the Edge Server instance, its Health status in the Edge Server dashboard changes from Pending to Active.
Authenticate a MongoDB Atlas User
Call the admin user authentication endpoint with your MongoDB Atlas API key pair:
curl -X POST \ https://services.cloud.mongodb.com/api/admin/v3.0/auth/providers/mongodb-cloud/login \ -H 'Content-Type: application/json' \ -H 'Accept: application/json' \ -d '{ "username": "<Public API Key>", "apiKey": "<Private API Key>" }'
If authentication succeeds, the response body contains a JSON object
with an access_token
value:
{ "access_token": "<access_token>", "refresh_token": "<refresh_token>", "user_id": "<user_id>", "device_id": "<device_id>" }
The access_token
grants access to the App Services Admin API. You
must include it as a Bearer token in the Authorization
header for
all Admin API requests.
Call the Create Edge Server Instance Endpoint
Call the Admin API Create an Edge Server instance endpoint to add an Edge Server instance to your service.
Your request must include:
An
Authorization
header with your Admin API access token as a Bearer token.A
name
for the new Edge Server instance
curl -X POST \ https://services.cloud.mongodb.com/api/admin/v3.0/groups/{groupId}/apps/{appId}/edge \ -H 'Content-Type: application/json' \ -H 'Authorization: Bearer <AccessToken>' \ -d '{ "name": "YOUR-EDGE-SERVER-INSTANCE-NAME" }'
A successful request returns a 201
code, as well as a JSON
object with information about the newly-created Edge Server
instance:
{ "id": "6622b8f5118368b943d228a9", "user_id": "6622b8f5118368b943d2288a", "registration_key": "Qi4GgpvVduwwt4k1w77ZzaQ1n4SdTWC8rLBD9vyTib1w9G3CX2ta8WrJvt3giEK7" }
id
: The unique identifier of the Edge Server instance, of type ObjectId, as a string. You can use this identifier to delete or update the Edge Server instance.user_id
: The Edge Server itself is a user. This is the unique identifier of the Edge Server user, of type ObjectId, as a string. You can use this identifier when configuring permissions.registration_key
: Save this information. When you install the Edge Server code on the host, enter this registration token. The Edge Server exchanges this for an API Key that it uses to authenticate with Atlas. You can only use this registration token once.
Install the Edge Server code
Copy and paste the installation script into the terminal on the device where you want to install the Edge Server code. For more details, refer to Install and Configure the Edge Server Instance.
List Edge Server Instances
You can get a list of your Edge Server instances in the Atlas UI, or from the Admin API.
The Edge Server dashboard lists a brief summary for each Edge Server instance, including the date and time of the last connection, and a snapshot of its status. You can optionally view details or logs for each instance.
To view the Edge Server dashboard, choose Edge Server in the left navigation sidebar.
To view the details for a specific Edge Server instance, click View Details for that Edge Server instance. Alternately, click App Logs to browse logs associated with the instance.
Authenticate a MongoDB Atlas User
Call the admin user authentication endpoint with your MongoDB Atlas API key pair:
curl -X POST \ https://services.cloud.mongodb.com/api/admin/v3.0/auth/providers/mongodb-cloud/login \ -H 'Content-Type: application/json' \ -H 'Accept: application/json' \ -d '{ "username": "<Public API Key>", "apiKey": "<Private API Key>" }'
If authentication succeeds, the response body contains a JSON object
with an access_token
value:
{ "access_token": "<access_token>", "refresh_token": "<refresh_token>", "user_id": "<user_id>", "device_id": "<device_id>" }
The access_token
grants access to the App Services Admin API. You
must include it as a Bearer token in the Authorization
header for
all Admin API requests.
Get the List of Edge Server Instances
Call the Admin API List Edge Servers endpoint to get a list of all the Edge Servers instances.
Your request must include an Authorization
header with your
Admin API access token as a
Bearer token.
curl -X GET \ https://services.cloud.mongodb.com/api/admin/v3.0/groups/{groupId}/apps/{appId}/edge \ -H 'Content-Type: application/json' \ -H 'Authorization: Bearer <AccessToken>'
A successful request returns a 200
code, and an
edge_servers
key whose values is an array of objects containing
summary details for each Edge Server instance associated with the
appId
.
{ "edge_servers": [ { "id": "6622b8f5118368b943d228a9", "created": "2024-04-19T08:51:00Z", "name": "Edge-Store-42", "user_id": "6622b8f5118368b943d2288a", "status": "active", "hostname": "ec2-13-58-70-88.us-east-2.compute.amazonaws.com", "last_connection": "2024-04-19T09:51:00Z" } ] }
For more detailed information, find the id
of the instance
whose details you want to view.
Call the Edge Server Info Endpoint
Call the Admin API Get Edge Server information endpoint to get detailed information about an Edge Server instance.
Your request must include an Authorization
header with your
Admin API access token as a
Bearer token.
curl -X GET \ https://services.cloud.mongodb.com/api/admin/v3.0/groups/{groupId}/apps/{appId}/edge/{edgeServerId} \ -H 'Content-Type: application/json' \ -H 'Authorization: Bearer <AccessToken>'
A successful request returns a 200
code, as well as a JSON
object with detailed information about the Edge Server instance:
{ "id": "6622b8f5118368b943d228a9", "created": "2024-04-19T08:51:00Z", "name": "Edge-Store-42", "user_id": "6622b8f5118368b943d2288a", "status": "active", "hostname": "ec2-13-58-70-88.us-east-2.compute.amazonaws.com", "last_connection": "2024-04-19T09:51:00Z", "query": { "Item": "(store_id == \"641cb3d99e425c794ef69315\")" }, "package_version": "v0.21.2", "latest_package_version": "v0.22.2", "metrics": [ { "key": "edge_host_memory_percent", "name": "Memory Usage", "category": "host", "detail": "Percentage of memory used by the edge container", "value": 15, "unit": "%" }, ...additional Edge Server metrics... ] }
For more information about this response body, refer to the API specification.
Edge Server Instance Details
The information available in the Edge Server details varies depending on whether the Edge Server has been configured and connected to Atlas, or whether configuration and connection are still pending.
Pending Edge Server Instances
When an Edge Server instance has not yet connected to Atlas for the first time, the instance's Health status is Pending.
While an Edge Server instance is in Pending state, you can perform the following actions from the detail view:
Rename the instance.
Review alerts about the instance status.
Get the instance ID. You can use this to set permissions for this specific instance.
View the Install command that you can use in the terminal to install the Edge Server code.
Regenerate the registration token.
Delete the Edge Server instance.
Once you have successfully configured and connected an Edge Server instance, the detail view changes to provide additional information.
Active or Failed Edge Server Instances
After you have connected an Edge Server instance to Atlas for the first time, the instance's Health status changes to Active.
If the Edge Server instance encounters a fatal error, its Health status changes to Failed.
You can perform the following actions for active or failed instances:
Rename the instance.
Review alerts about the instance status.
View the date and time of the last connection.
Get the instance ID. You can use this to set permissions for this specific instance.
View the instance query. This determines what data syncs between the instance and Atlas, and what data clients can write to the instance. Clients can only write data that falls within their permissions, and the instance's query. For more information, refer to Specify the Edge Server's Query.
View Metrics about the Edge Server instance. For more information, refer to Edge Server Metrics.
View the instance Logs. For more information, refer to Edge Server Logs.
View version information. This page lists the current version, and the latest available version. If the instance falls more than one major version behind the latest available, it enters a Failed state and cannot sync with Atlas until it is upgraded. For more information, refer to Upgrade the Edge Server Version.
View the Install command that you can use in the terminal to install the Edge Server code.
Regenerate the registration token.
Delete the Edge Server instance.
Delete an Edge Server Instance
You can delete an individual Edge Server instance from Atlas.
Authenticate a MongoDB Atlas User
Call the admin user authentication endpoint with your MongoDB Atlas API key pair:
curl -X POST \ https://services.cloud.mongodb.com/api/admin/v3.0/auth/providers/mongodb-cloud/login \ -H 'Content-Type: application/json' \ -H 'Accept: application/json' \ -d '{ "username": "<Public API Key>", "apiKey": "<Private API Key>" }'
If authentication succeeds, the response body contains a JSON object
with an access_token
value:
{ "access_token": "<access_token>", "refresh_token": "<refresh_token>", "user_id": "<user_id>", "device_id": "<device_id>" }
The access_token
grants access to the App Services Admin API. You
must include it as a Bearer token in the Authorization
header for
all Admin API requests.
Get the ID of the Edge Server to Delete
Call the Admin API List Edge Servers endpoint to get a list of all the Edge Server instances.
Your request must include an Authorization
header with your
Admin API access token as a
Bearer token.
curl -X GET \ https://services.cloud.mongodb.com/api/admin/v3.0/groups/{groupId}/apps/{appId}/edge \ -H 'Content-Type: application/json' \ -H 'Authorization: Bearer <AccessToken>'
A successful request returns a 200
code, and an
edge_servers
key whose values is an array of objects containing
summary details for each Edge Server instance associated with the
appId
.
{ "edge_servers": [ { "id": "6622b8f5118368b943d228a9", "created": "2024-04-19T08:51:00Z", "name": "Edge-Store-42", "user_id": "6622b8f5118368b943d2288a", "status": "active", "hostname": "ec2-13-58-70-88.us-east-2.compute.amazonaws.com", "last_connection": "2024-04-19T09:51:00Z" } ] }
Find the id
of the Edge Server instance that you want to delete
in the array.
Call the Delete Endpoint
Call the Admin API Delete an Edge Server instance endpoint with the ID of the Edge Server instance that you want to delete.
Your request must include an Authorization
header with your
Admin API access token as a
Bearer token.
curl -X DELETE \ https://services.cloud.mongodb.com/api/admin/v3.0/groups/{groupId}/apps/{appId}/edge/{edgeServerId} \ -H 'Content-Type: application/json' \ -H 'Authorization: Bearer <AccessToken>'
A successful request returns a 200
code.
Update an Edge Server's Data Model
The process to update a data model varies depending on whether you're using an Edge Server Service or a Device Sync Service with Edge Server.
Edge Server Service
When you're using an Edge Server Service, the service automatically updates fields in the schema when you make changes to the documents you sync.
If you update your schema manually using the UI, and those schema changes trigger a schema version change, this causes an Edge Server instance with the old schema to reboot and wipe itself.
If you're adding a new collection you haven't synced before, you must define a new schema.
Add a Collection
When you want to add a collection to an Edge Server Service, you must add a schema containing:
The collection name.
An
_id
field that is ofObjectID
type.
The Edge Server Service automatically infers the other fields from the shape of the documents you sync or the documents in the collection.
For information about how to add a schema, refer to Define & Enforce a Schema.
After adding a collection, you must stop and start the Edge Server instance to pick up the new collection details. For more information, refer to Start and Stop the Edge Server.
Change Fields in a Document
When you change the fields in a document using an Edge Server Service, the service automatically changes the schema to add new fields.
Some changes that you can make through the UI are considered "breaking" schema changes. When a "breaking" schema change occurs, any Edge Server instance with the old schema reboots and wipes itself. The wipe process erases any unsynced data.
Important
Wiping and restarting the instance erases all local unsynced data on the instance.
If that data was written by an Atlas Device SDK client, the client itself can handle data recovery. This enables local unsynced data written by the client to eventually make its way to Atlas.
If the data was written by a MongoDB Driver or tool using the Wire Protocol, the unsynced data is unrecoverable.
Before Edge Server moves from Public Preview to General Availability, you will have the option to recover local data when this error occurs.
For details about which types of changes are considered "breaking" changes, refer to Breaking vs. Non-Breaking Change Quick Reference.
Device Sync Service
An Edge Server running in a Device Sync Service uses Device Sync rules for updating a data model.
When a "breaking" schema change occurs, any Edge Server instance with the old schema reboots and wipes itself.
Important
Wiping and restarting the instance erases all local unsynced data on the instance.
If that data was written by an Atlas Device SDK client, the client itself can handle data recovery. This enables local unsynced data written by the client to eventually make its way to Atlas.
If the data was written by a MongoDB Driver or tool using the Wire Protocol, the unsynced data is unrecoverable.
Before Edge Server moves from Public Preview to General Availability, you will have the option to recover local data when this error occurs.
For more information, refer to Update Your Data Model.
Troubleshoot an Edge Server Instance
A few conditions can cause an Edge Server instance to enter a Failed
state:
Edge Server is Offline Longer than Client Maximum Offline Time
Edge Server uses Device Sync to sync data between the Edge Server instance and Atlas. Device Sync has a Client Maximum Offline Time setting.
This setting is enabled by default. It trims history to reduce the amount of storage required in the backing Atlas cluster. The longer the client maximum offline time, the more storage Atlas requires to keep historical records that support Sync.
If an Edge Server instance is offline longer than this setting, this is an unrecoverable error. You must wipe and restart the instance. Alternately, when you bring the instance back online, it will be wiped and restarted automatically.
Important
Wiping and restarting the instance erases all local unsynced data on the instance.
If that data was written by an Atlas Device SDK client, the client itself can handle data recovery. This enables local unsynced data written by the client to eventually make its way to Atlas.
If the data was written by a MongoDB Driver or tool using the Wire Protocol, the unsynced data is unrecoverable.
Before Edge Server moves from Public Preview to General Availability, you will have the option to recover local data when this error occurs.
You can change the length of the client maximum offline time in the Sync Settings.
Important
Edge Server Offline Limit is 60 Days
An Edge Server instance cannot be offline longer than 60 days, no matter what setting you set for the client maximum offline time. If the setting is unset or greater than 60 days, the Edge Server offline limit is 60 days.
Edge Server Instance is More than One Major Version Behind
Edge Server does not support instances that fall more than one major version
behind the current latest version. If your Edge Server instance falls further
behind in versions, you must upgrade it to resolve the Failed
state.
For information about upgrading an Edge Server instance, refer to Upgrade the Edge Server Version.
Edge Server Token is Invalid
If the Edge Server instance token is regenerated, and you do not update the
API Key on the instance itself, it can enter a Failed
state.
For more details about how to update the API Key on the Edge Server instance after regenerating the Edge Server token, refer to Cycle the Edge Server API Key.
Edge Server Limitations
While Edge Server is in Public Preview, it does not yet support the full range of MongoDB and Atlas Device SDK features and functionality.
Collection Types
Edge Server does not currently support time series collections.
When you create an Edge Server service, we automatically create schemas for every collection in your linked database. Trying to use Edge Server with a database that contains a time series collection throws an error.
To resolve this error, you must manually remove the schema for the time series collection. For information about how to remove the schema, refer to Remove a Schema.
Aggregation and CRUD Operations
Edge Server currently supports only a subset of MongoDB aggregation and CRUD operations. For a list of supported operations, refer to Edge Server MongoDB API Support - Preview.
Atlas Device SDK Features
Edge Server does not currently support Data Ingest.