Connect a source

Connect MongoDB Atlas

Enter a MongoDB Atlas service account with only the Organization Billing Viewer role, and its organization ID, and Costfluent imports the organization's daily cost per project, cluster and SKU.

Costfluent reads your MongoDB Atlas spend from the organization's invoices and their line items, through the Atlas Administration API, with a service account you create for it. One connection is one Atlas organization, and the cost of every project, cluster and App Services app in it.

How Costfluent connects

Costfluent stores the service account's client ID and secret encrypted. The secret never leaves Costfluent's control plane: for each collection it is exchanged at MongoDB for an access token that lasts an hour at most, and only that token reads the organization you name. Costfluent reads the organization's invoices, the pending invoice of the running month and each invoice's line items, and nothing else. The organization ID you enter is the connection's identity, and the service account is only ever used for that connection.

Give the service account the Organization Billing Viewer role and no other, create it for Costfluent alone, and give its secret an expiry.

Prerequisites

  1. The Owner or Integration owner organization role in Costfluent.
  2. A service account for Costfluent alone, in the organization you connect. In the Atlas UI, open the organization's "Access Manager", then "Applications", then "Service Accounts", and create a service account. Name it for Costfluent, give it the "Organization Billing Viewer" role and no other, and choose when its secret expires: the secret stops working then, so note the date to replace it before.
  3. The service account's client ID and secret. Copy the secret before you leave that screen: Atlas shows it only once.
  4. The organization ID, copied from the organization's settings in the Atlas UI, such as 32b6e34b3d91647abb20e7b8: 24 lowercase hexadecimal digits.

An organization that requires an IP access list for the Atlas Administration API cannot be connected: Costfluent publishes no addresses to add to it. Turn that requirement off in the organization's settings to connect it.

Connect

  1. Open Settings, then Integrations, select MongoDB Atlas, and open the Connect tab.
  2. Select "Add service account", keep the suggested Display name or enter your own, and paste the client ID into Client ID, the secret into Client secret and the organization ID into Organization ID. Spaces around each value are removed.
  3. Select "Test connection" to see each check, or "Connect" to save.

Before storing anything, Costfluent asks MongoDB for a token with the client ID and secret and reads the organization's pending invoice with it, so a connection that saves can read your invoices, even before the organization has one. A second connection of the same organization is refused.

Data and freshness

Atlas tabulates cost daily and posts a day's charges the next day. Each day's line items are one row per project, resource and SKU on that day, so daily, month and longer views are exact. The running month is read from the pending invoice, a day behind.

Each sync reads every invoice whose period overlaps the days it collects, the pending one included. Until the 15th of the month it also reads the previous month again, so a month's invoice, once Atlas closes it, replaces what the pending invoice showed.

Amounts are in US dollars. List cost is each line item's price; billed cost is that less its discount. A credit Atlas itemizes is a credit row on its own day. A closed invoice's sales tax, and its credits where Atlas does not itemize them, are one row each, filed on the invoice's last day.

Before a closed invoice is imported, its line items must reach its subtotal and its credits. One that does not fails the collection naming the invoice, rather than importing a total that may be wrong.

Connecting imports as far back as your plan's backfill reaches, and at most six months (Manage connections), for each day Atlas has invoiced.

Reporting dimensions

  • The billing account is the organization, by its ID, and the billing period is the invoice's period.
  • Sub-account is the project, by its name and ID. A line item without a project, such as a credit, sits under the organization.
  • Resource is the cluster, or the App Services app for an App Services line item.
  • Service is Clusters for a cluster's instance hours, and MongoDB Atlas for every other line item, such as storage, data transfer, backup or App Services, and for tax and credits.
  • SKU is the line item's SKU, such as ATLAS_AWS_INSTANCE_M10.
  • Charge category is Credit for a credit, Tax for sales tax, and Usage otherwise.
  • The line item's tags are kept as tags; a tag with several values keeps them joined with a comma.

Update or disconnect

After connecting

The Manage tab lists the connection by its display name, with its organization ID. Open the gear icon beside it to see whether the invoices are still readable, which workspaces the connection feeds, and which months have been imported. Run checks runs the checks again on request.

Rotating or removing access

Atlas does not rotate the secret for you, and it stops working when it expires. Before then, generate a second secret for the same service account, select Update credentials on the connection page and enter it with the same client ID and organization ID; then delete the old secret in the Atlas UI.

To retire the connection, remove it in Costfluent, then delete the service account in the Atlas UI. Removing it erases the cost it imported (Remove a connection).

Troubleshooting

  • A MongoDB Atlas service account's client ID and secret and the organization ID are required. One of the three fields is empty. Enter all three.
  • A MongoDB Atlas organization ID is 24 lowercase hexadecimal digits, as the Atlas UI shows it in the organization's settings. The organization ID field holds something else, such as the organization's name. Copy the ID from the organization's settings.
  • MongoDB Atlas refused this client ID and secret. Check the service account's client ID, and that its secret is current and has not expired. The client ID or secret is wrong, or the secret has expired or was deleted. Generate a new secret as the prerequisites describe and select Update credentials.
  • MongoDB Atlas refused this service account the invoices of organization ... Give the service account the Organization Billing Viewer role in that organization, and check the organization ID. The message names the organization ID you entered. The service account lacks the role there, or belongs to another organization.
  • This MongoDB Atlas organization requires an IP access list for the Atlas Administration API. Costfluent cannot be added to that list; turn the requirement off in the organization's settings.
  • MongoDB Atlas is limiting requests for this service account. Try again in a minute. MongoDB allows a service account ten token requests a minute. Select Run checks a minute later.
  • MongoDB Atlas could not be reached to verify these credentials. MongoDB did not answer, or answered with an error of its own, whose detail the message names. Select Run checks later.
  • MongoDB Atlas invoice ... does not add up, or ... credits do not add up, on a collection: the line items of the invoice the message names do not reach its subtotal or its credits. The collection fails rather than invent the difference; tell us through the contact form, naming the message.