# Connect Elastic Cloud (Elasticsearch)

Costfluent reads your Elastic Cloud spend from Elastic's billing API, with an organization API key
you create for it. One connection is one Elastic Cloud organization, and the cost of every hosted
deployment and serverless project in it.

## How Costfluent connects

Costfluent stores the API key encrypted and uses it for one kind of call: the cost of each instance
in the organization you name, one day at a time. The organization ID you enter is the connection's
identity, and the key is only ever used for that connection.

:::caution
Elastic Cloud has no role that only reads billing. The "Billing admin" role that reads the cost can
also manage the organization's billing details, such as its credit card and subscription.
Costfluent only reads the cost. Give the key that one role and no other, create it for Costfluent
alone, and give it an expiry.
:::

## Prerequisites

1. The Owner or Integration owner organization role in Costfluent.
2. An Elastic Cloud API key for Costfluent alone, created in the organization you connect. In the
   Elastic Cloud console, open "Organization", then "API keys", and select "Create API key". Name it
   for Costfluent and choose an expiry of a year or less: the key stops working then, so note the
   date to replace it before. Give it the "Billing admin" role and no other role, select
   "Create API key", and copy the key before you leave that screen: Elastic Cloud does not show it
   again.
3. The organization ID, a number of 1 to 20 digits, shown on the "Organization" page of the Elastic
   Cloud console. It must be the organization the key was created in.

## Connect

<Stepper>

1. Open **Settings**, then **Integrations**, select **Elastic Cloud**, and open the **Connect** tab.
2. Select "Add API key", keep the suggested **Display name** or enter your own, and paste the key
   into **API key** and the organization ID into **Organization ID**. Spaces around either value are
   removed.
3. Select "Test connection" to see each check, or "Connect" to save.

</Stepper>

Costfluent reads yesterday's cost of the organization before storing anything, so a connection that
saves can read your cost. A second connection of the same organization is refused. If Elastic Cloud
does not answer during that check, the connection is saved anyway and checked again automatically.

## Data and freshness

Connecting imports as far back as your plan's backfill reaches, and at most six months
([Manage connections](/connect/manage-connections#how-it-behaves)), as long as Elastic Cloud reports
cost that far back. Cost arrives by UTC day, once the day has ended. Each sync reads the running
month, and until the 15th the previous month again, so a correction Elastic makes later still
arrives.

Amounts are in US dollars. Elastic Cloud states its cost in Elastic Consumption Units (ECU), and
Costfluent counts one ECU as one US dollar, its nominal value.

:::note
A discount in your Elastic contract, such as a lower price for ECU bought in advance, is not part of
the cost Elastic's billing API reports, so cost is shown before it, at one US dollar per ECU. Your
Elastic invoice can be lower.
:::

:::caution
If you pay for Elastic Cloud through a cloud marketplace, its charges are also on that cloud's bill.
Connecting both counts them twice.
:::

## Reporting dimensions

- **Service** is `Elastic Cloud Hosted` for a hosted deployment, `Elastic Cloud Serverless` for a
  serverless project, and `Elastic Cloud` for anything else Elastic Cloud bills.
- **Service category** follows the kind of instance: `Analytics` for a hosted deployment and an
  Elasticsearch project, `Management and Governance` with the **Service subcategory**
  `Observability` for an Observability project, `Security` for a Security project, and `Other`
  otherwise.
- **Resource** is the deployment or project, by its name and ID, and **Resource type** is the kind
  of instance, such as `deployment` or `observability`. For a hosted deployment the ID is that of its
  Elasticsearch resource, not the deployment ID the Elastic Cloud console shows; it matches
  `resources.elasticsearch[0].id` in Elastic's deployments API.
- **SKU** is Elastic's SKU of the line item, such as `aws.es.datahot.c6gd_us-east-1_4096_2`, and
  the line item description is its name as the Elastic Cloud console shows it. The usage quantity is
  the line item's, in its unit, such as hours or GB, at its rate.
- **Region** is read from the SKU where it names one, as written there, such as `us-east-1` or
  `gcp-europe-west1`. A charge whose SKU names no region, such as data transfer, has none.
- The billing account is the organization, and the billing period is the calendar month.

## 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 cost is 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

Elastic Cloud does not rotate the key for you, and it stops working at its expiry. Before then,
create a new key the same way, select **Update credentials** on the connection page and paste it
with the same organization ID; then delete the old key in the Elastic Cloud console, under
"Organization", then "API keys". Another organization's ID is refused.

To retire the connection, remove it in Costfluent, then delete its key in the Elastic Cloud console.
Removing it erases the cost it imported
([Remove a connection](/connect/manage-connections#remove-a-connection)).

## Troubleshooting

- **An Elastic Cloud API key and the organization ID are required.** One of the two fields is
  empty. Paste both.
- **An Elastic Cloud organization ID is a number of 1 to 20 digits, as the Elastic Cloud console
  shows it on the organization page.** The organization ID field holds something else, such as the
  organization's name or a deployment ID. Copy the ID from the "Organization" page.
- **Elastic Cloud refused this API key for organization ... Check that the key has not expired,
  holds the Billing admin role and was created in that organization.** The message names the
  organization ID you entered. Elastic Cloud gives the same answer for all three causes, so check
  each: whether the key has expired or was deleted, whether it holds the "Billing admin" role, and
  whether it was created in the organization the ID names. Create a new key as the prerequisites
  describe if it is wrong, and select **Update credentials**.
- **Elastic Cloud knows no organization ... Copy the organization ID from the organization page of
  the Elastic Cloud console.** The organization ID does not exist. Copy it again from the
  "Organization" page.
- **Elastic Cloud could not be reached to verify these credentials.** Elastic Cloud did not answer,
  or answered with an error of its own, whose status the message names. Select **Run checks**
  later; a connection saved meanwhile is checked again automatically.
- **The supplied Elastic Cloud organization ID does not match the validated key.** Shown when
  updating credentials with another organization's ID. Connect that organization as a new
  connection.

Elasticsearch is a trademark of elasticsearch B.V., registered in the U.S. and in other countries.
