# Connect a FOCUS export

OVHcloud and STACKIT can write your cost as FOCUS files into an S3-compatible bucket of yours.
Costfluent reads those files with an access key that may only read the bucket. One connection is
one export location: a bucket and the prefix the export writes under.

## How Costfluent connects

You choose the provider that writes the files and the bucket's region. Together they form the
endpoint Costfluent reads from; no other endpoint is accepted:

| Provider | Endpoint |
|---|---|
| OVHcloud | `s3.<region>.io.cloud.ovh.net` |
| STACKIT | `object.storage.<region>.onstackit.cloud` |

Costfluent stores the access key ID and secret access key encrypted and uses them only to list and
read the export's files. The connection is identified by its location,
`<endpoint>/<bucket>/<prefix>`: a second connection of the same location is refused, and a new key
for a connection must reach the same location.

:::caution
Costfluent cannot tell from a key whether it may also write to the bucket. Create a key that may
only read it, separate from the key the export writes with.
:::

## Prerequisites

1. The Owner or Integration owner organization role in Costfluent.
2. A bucket in OVHcloud's or STACKIT's object storage that the provider's FOCUS export writes to.
   The export is set up under **Turn on the export**.
3. An access key that may only read that bucket, created under **Create a read-only key**.

## Turn on the export

### OVHcloud

<Stepper>

1. In the OVHcloud Control Panel, set up the bucket export in Cost Center, or call OVHcloud's API
   with `POST /v2/finops/bucketExport`.
2. Choose a daily export with the `CREATE` or `REPLACE` policy.
3. Note the export's path prefix: it is the prefix you enter in Costfluent. Without one, leave the
   prefix empty.

</Stepper>

### STACKIT

<Stepper>

1. In the STACKIT portal, run the FOCUS export wizard. It creates its own service account, which
   writes the files.
2. Note the folder the export writes under: it is the prefix you enter in Costfluent.

</Stepper>

STACKIT writes the first file the day after setup. You can connect before that.

## Create a read-only key

### OVHcloud

Create an Object Storage user with read-only access to the export's bucket, and use its access key
ID and secret access key.

### STACKIT

Create a separate credentials group with an access key that may only read the export's bucket.

:::caution
Never use the export's own `focus-*` credentials for Costfluent. STACKIT says they must not be
touched.
:::

## Connect

<Stepper>

1. Open **Settings**, then **Integrations**, select **FOCUS export**, and open the **Connect** tab.
2. Select **Add access key**, and keep the suggested **Display name** or enter your own.
3. Choose the **Provider**, and enter the bucket's **Region** as the provider names it, such as
   `gra`, `sbg`, `de` or `eu-west-par` for OVHcloud, or `eu01` or `eu02` for STACKIT.
4. Enter the **Bucket**, the **Prefix** the export writes under, the **Access key ID** and the
   **Secret access key**.
5. Select **Test connection** to see each check, or **Connect** to save.

</Stepper>

Before storing anything, Costfluent lists the prefix with the key. If export files are already
there, it reads the header of the newest one and refuses a file that is not FOCUS. An empty prefix
is accepted, because STACKIT writes its first file the day after setup.

## Data and freshness

Costfluent imports daily cost from the newest export of each period: of each month for OVHcloud,
whose export rewrites the month to date on every run, and of each billing period for STACKIT.
Every sync reads its window again, so the running month follows the provider's latest file. Cost
arrives in the export's billing currency.

:::note
Until the provider writes its first file, the connection has nothing to import. For STACKIT that is
the day after the export is set up.
:::

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 the bucket holds
exports that far back. When the provider writes a newer export of a closed period, such as STACKIT's
recreated month report with its credits, Costfluent collects that period again, as far back as your
plan's history reaches and at most three years.

## Reporting dimensions

What each group-by dimension of a [cost report](/cost-reports/explore) holds for a FOCUS export,
and the FOCUS column it comes from.

| Dimension | For a FOCUS export | From |
|---|---|---|
| **Provider name** | The provider the file names, such as OVHcloud or STACKIT | `ServiceProviderName`, or `ProviderName` in files before FOCUS 1.3 |
| **Sub-account** | The sub-account the row states; the billing account for a row without one | `SubAccountId`, else `BillingAccountId` |
| **Service** | The provider's service | `ServiceName` |
| **Region** | The region's name the row states | `RegionName` |
| **Resource** | The resource's name the row states | `ResourceName` |
| **Charge category** | The charge category the row states | `ChargeCategory` |
| **Service category** | The FOCUS category the row states | `ServiceCategory` |
| **SKU** | The meter the row states; the SKU ID where it states none | `SkuMeter`, else `SkuId` |
| **Tag** | Every key of the row's tags, as written | `Tags` |
| **Segment** | Your allocation rules | [Segments and allocation rules](/allocation/segments) |
| **Cluster**, **Namespace** | Never filled; they hold Kubernetes cost ([Connect Kubernetes](/connect/kubernetes)) | |
| **Virtual tag** | Your virtual tag rules | [Virtual tags](/allocation/virtual-tags) |

## Update or disconnect

### After connecting

The **Manage** tab lists the connection by its display name. Open the gear icon beside it to see
whether the export 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

Select **Update credentials** on the connection page and enter the same provider, region, bucket
and prefix with a new read-only key; then delete the old key at the provider. A key entered with
another location is refused.

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

## Troubleshooting

- **The connection saves, but no cost arrives.** The prefix holds no export yet. STACKIT writes its
  first file the day after setup; OVHcloud writes on the export's schedule. Check that the prefix
  is the folder the export writes under.
- **The bucket cannot be reached or listed.** The region does not match the bucket, or the provider
  chosen is not the one whose object storage holds it. The region forms the endpoint under
  **How Costfluent connects**; enter it as the provider names it.
- **The newest file is refused as not FOCUS.** A file in the export's layout under the prefix lacks
  the FOCUS columns: the prefix points at another folder or another export. Files outside the
  export's layout are skipped, not refused. Enter the prefix the export writes under.
- **OVHcloud cost is counted twice.** Both an [OVHcloud](/connect/ovhcloud) API key connection and
  its FOCUS export are connected, and each imports the same cost. Connect one of them and remove
  the other.
