# Connect a FOCUS bucket

OVHcloud and STACKIT can write your cost as FOCUS files into an S3-compatible bucket of yours, and
you can write your own FOCUS files to a bucket on any other S3-compatible storage or to a container in
Azure Blob Storage. Costfluent reads those files with an access key that may only read the bucket.
For Azure Blob Storage it uses a shared access signature (SAS) that grants Read and List on the
container and nothing else. One connection is one export location: a bucket or container and the
prefix the export writes under.

FOCUS files reach Costfluent in one of three ways:

- **A bucket** Costfluent reads on every sync, which this page describes.
- **An upload** of one run's files to a custom provider, in the console.
- **The Public API**, which takes the same uploads, or cost entries as JSON.

The upload and the Public API are on [Upload cost to a custom provider](/connect/custom-provider).

## How Costfluent connects

You choose the provider that writes the files. For OVHcloud and STACKIT, the bucket's region forms
the endpoint Costfluent reads from, and no other endpoint is accepted. For other S3-compatible
storage, you enter the endpoint yourself:

| Provider | Endpoint |
|---|---|
| OVHcloud | `s3.<region>.io.cloud.ovh.net` |
| STACKIT | `object.storage.<region>.onstackit.cloud` |
| Other S3-compatible storage | The **Endpoint** you enter, such as `https://s3.<region>.amazonaws.com` for AWS S3 |
| Azure Blob Storage | `<storage account>.blob.core.windows.net` |

An endpoint you enter is an `https://` address of a public DNS name with a dot in it, with a port
if the storage needs one, and nothing else: no path, query, user name or password, no IP address,
and no local, `.internal` or single-label host. Costfluent connects to it only when the name
resolves to public addresses, presents a certificate a public certificate authority issued for it,
and answers without redirecting. It addresses the bucket by path, as
`https://<endpoint>/<bucket>/<prefix>`, and signs each request with the **Region** you enter, or
with `us-east-1` when you leave it empty.

For Azure Blob Storage, the storage account you enter forms the host, and no endpoint or region is
entered. Costfluent reads the container with a container SAS token instead of a key pair.

Costfluent stores the access key ID and secret access key, or the SAS token, encrypted and uses them
only to list and read the export's files. The connection is identified by its location,
`<endpoint>/<bucket>/<prefix>`, or `<storage account>.blob.core.windows.net/<container>/<prefix>`
for Azure Blob Storage: a second connection of the same location is refused, and a new key or SAS
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. A SAS states its permissions, so for
Azure Blob Storage Costfluent refuses one that grants more than Read and List.
:::

## Prerequisites

1. The Owner or Integration owner organization role in Costfluent.
2. A bucket that a FOCUS export writes to: in OVHcloud's or STACKIT's object storage, written by
   the provider's export, or on other S3-compatible storage or a container in Azure Blob Storage,
   written by you as [Write your own FOCUS export](#write-your-own-focus-export) describes. The
   export is set up under **Turn on the export**.
3. An access key that may only read that bucket, or for Azure Blob Storage a container SAS that may
   only read and list the container, 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.

### Other S3-compatible storage

Write your FOCUS files to the bucket in the layout under
[Write your own FOCUS export](#write-your-own-focus-export). The folder above the period folders is
the prefix you enter in Costfluent; leave the prefix empty when the period folders start at the top
of the bucket.

### Azure Blob Storage

Write your FOCUS files to a container in the same layout, under
[Write your own FOCUS export](#write-your-own-focus-export). The folder above the period folders is
the prefix you enter in Costfluent; leave the prefix empty when the period folders start at the top
of the container.

## 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.
:::

### Other S3-compatible storage

Create an access key on the storage that may only list the bucket and read its objects, separate
from the key your export writes with. On AWS S3, that is an IAM user's access key whose policy
allows `s3:ListBucket` on the bucket and `s3:GetObject` on its objects, and nothing else.

### Azure Blob Storage

Costfluent reads the container with a SAS for that container. It accepts only a SAS whose
permissions it can read from the token itself: a container SAS (`sr=c`), not an account SAS and not
one tied to a stored access policy, granting Read and List (`sp=rl`) and nothing else, allowing
HTTPS only, and with an expiry.

<Stepper>

1. In the Azure portal, open the storage account, then the container, and select
   "Shared access tokens".
2. Choose "Account key" as the signing method and leave "Stored access policy" at none.
3. Under "Permissions", select only "Read" and "List".
4. Choose the expiry, and set "Allowed protocols" to HTTPS only.
5. Select "Generate SAS token and URL", and copy the "Blob SAS token", not the SAS URL.

</Stepper>

With the Azure CLI:

```bash
az storage container generate-sas \
  --account-name <storage account> \
  --name <container> \
  --permissions rl \
  --https-only \
  --expiry <YYYY-MM-DDTHH:MMZ> \
  --output tsv
```

:::note
The SAS's expiry is the connection's: within 7 days of it the connection shows as Degraded, and once
it passes the connection fails until you enter a new SAS
([Rotating or removing access](#rotating-or-removing-access)).
:::

## Connect

<Stepper>

1. Open **Settings**, then **Integrations**, select **FOCUS bucket**, 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. For
   **Other S3-compatible storage**, enter the storage's **Endpoint**, and in **Region** the region
   the storage signs requests with; leave **Region** empty for `us-east-1`. On AWS S3, both are the
   bucket's own: `https://s3.eu-central-1.amazonaws.com` and `eu-central-1` for a bucket in
   eu-central-1. A bucket outside us-east-1 needs its regional endpoint and its region. For
   **Azure Blob Storage**, enter the **Storage account** instead, 3 to 24 lower-case letters and
   digits.
4. Enter the **Bucket**, the **Prefix** the export writes under, the **Access key ID** and the
   **Secret access key**. For **Azure Blob Storage**, enter the **Container**, the **Prefix** and the
   **SAS token**.
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. For other S3-compatible
storage, a prefix that holds files but none in the layout Costfluent reads is refused. For Azure
Blob Storage, Costfluent first reads the SAS: one that has expired is refused, and its expiry is
stored as the connection's.

For other S3-compatible storage and Azure Blob Storage, **Test connection** also reports whether the
files will import. It
reads the first 1,000 rows of the CSV file written last in the newest run that holds one and judges each by the FOCUS
mapping and currency rules a sync applies,
then shows, under the cost data check: the periods found, first to last; the files the layout
skipped; the rows sampled, how many would be set aside and the first reason; how many are charged
outside their run's period and so not imported; and up to five sellers and five currencies. An export
of Parquet files only is not sampled, and the report gives its file count. When every sampled row would
be set aside, the check fails with the first reason. The report is labels, counts and the file's own
names, so it reads the same in every language.

## Write your own FOCUS export

To have Costfluent read FOCUS files you write yourself, put them in a bucket on S3-compatible
storage or a container in Azure Blob Storage, in the layout below, and connect it as
**Other S3-compatible storage** or **Azure Blob Storage**.

### Layout

Under the prefix, each billing period has a folder, named in one of these forms:

| Period folder | Period |
|---|---|
| `YYYY-MM`, such as `2026-11` | The month |
| `BILLING_PERIOD=YYYY-MM`, such as `BILLING_PERIOD=2026-11` | The month |
| `year=YYYY/month=MM`, such as `year=2026/month=11` (the month may have one digit) | The month |
| `YYYYMMDD-YYYYMMDD`, such as `20261101-20261130` | The days from the first date to the second, both included |

Each file is a `.csv`, `.csv.gz` or `.parquet` file, either directly in the period folder or in one
folder below it:

- **Files directly in the period folder** are one run, which FOCUS calls Append: every file there is
  read, so each new file adds its rows to the period.
- **Each folder below the period folder** is one run, which FOCUS calls Overwrite: the run holds the
  whole period, and only the newest run is read.

The newest run of a period is the one whose files were written last, by the time the storage lists
them. While a period has an older run, Costfluent passes over a run written within the last
15 minutes, which may still be being written, and reads it on a later sync. Files that fit no
period folder, such as a manifest, are skipped, never read. Folders above the period folders belong
to the export, so two exports under one prefix stay apart.

### Columns

Every file needs these FOCUS columns: `BilledCost`, `BillingAccountId`, `BillingCurrency`,
`ChargeCategory`, `ChargePeriodEnd`, `ChargePeriodStart` and `ServiceName`. A file without one of
them is refused. An upload to a [custom provider](/connect/custom-provider#file-format) needs fewer:
`ChargePeriodStart`, `ChargeCategory`, `ServiceName`, `BilledCost` and `BillingCurrency`.

Name the seller in `ServiceProviderName`: it is the **Seller** dimension under
**Reporting dimensions**.

### Rows

A row belongs to the period its `ChargePeriodStart` falls in. Write each row into the folder of
that period: a row whose `ChargePeriodStart` falls outside its run's period is dropped, not
imported. A `ChargePeriodStart` that is not a timestamp fails the sync of its period, naming the
file and the row.

:::caution
A newer run replaces what Costfluent imported for its days. A sync that would import fewer than half
of the charges already imported for its days, or none, is refused, and Costfluent keeps the charges
it imported (see **Troubleshooting**). Write each Overwrite run with the whole period.
:::

### Formats

- CSV, with a header row.
- CSV compressed with gzip, ending in `.csv.gz`.
- Parquet, compressed with SNAPPY, GZIP, BROTLI or LZ4, or not compressed. Parquet compressed with
  ZSTD is refused.

## 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.
For other S3-compatible storage and Azure Blob Storage, it imports from the newest run of each
period, as
[Write your own FOCUS export](#write-your-own-focus-export) describes. Every sync reads its window
again, so the running month follows the provider's latest file. Cost arrives in the export's
billing currency.

Listing and reading one sync window of other S3-compatible storage may take at most 30 minutes.
Past that, the window fails as a timeout and is collected again on a later sync.

:::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 bucket,
and the FOCUS column it comes from.

| Dimension | For a FOCUS bucket | From |
|---|---|---|
| **Seller** | 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. For other
S3-compatible storage, keep the same endpoint too. A key entered with another location is refused.

For Azure Blob Storage, generate a new SAS as under
[Create a read-only key](#create-a-read-only-key), with Read and List only, HTTPS only and an expiry.
Select **Update credentials** and enter the new **SAS token**, keeping the same storage account,
container and prefix; a SAS for another container is refused. A SAS cannot be revoked by itself:
once the new one is stored, rotate the storage account key that signed the old one, which stops
every SAS that key signed.

To retire the connection, remove it in Costfluent and delete its key at the provider, or for Azure
Blob Storage rotate the storage account key that signed its SAS. 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. For a file
  you write yourself, add the columns under
  [Write your own FOCUS export](#write-your-own-focus-export).
- **The endpoint is refused before anything is sent.** The **Endpoint** is not an `https://`
  address, carries a path, a query, a user name or a password, names an IP address, or names a
  local, `.internal` or single-label host. Enter the storage's address alone, such as
  `https://s3.eu-central-1.amazonaws.com`, and the bucket and the prefix in their own fields.
- **The endpoint "does not exist".** Its name does not resolve. Check the storage's endpoint.
- **The endpoint "resolves to an address that is not public".** Costfluent reads an export only
  from storage reachable on the public internet, so a name that resolves to a private, loopback or
  metadata address is not connected to. Use the storage's public endpoint.
- **The endpoint "presented a certificate that is not trusted".** The key was not sent. The
  endpoint needs a certificate from a public certificate authority that is valid for its name.
- **The endpoint "rejected the signing region".** The **Region** is not the one the bucket signs
  with. Enter the region the bucket is in, such as `eu-central-1`; on AWS S3, an empty region means
  `us-east-1`.
- **The endpoint "is not the endpoint of the bucket".** The storage redirected the request to
  another address, as AWS S3 does for a bucket in another region. Enter the bucket's regional
  endpoint, such as `https://s3.eu-central-1.amazonaws.com`, and its region.
- **"None of the files … fits the layout Costfluent reads".** The prefix holds files, but none in a
  period folder Costfluent reads. Point the prefix at the folder above the period folders, and name
  the folders as [Write your own FOCUS export](#write-your-own-focus-export) shows.
- **A Parquet file is refused for its codec.** The message says "its ZSTD codec is not one
  Costfluent reads; write the file with SNAPPY, GZIP, BROTLI, LZ4 or no compression". Write the file
  again with one of those.
- **A sync fails because "the provider redelivered" its days with fewer charges.** The newest run
  holds fewer than half of the charges Costfluent imported for those days, or none, which more often
  means a lost export, permission or account than deleted charges. Costfluent keeps the charges it
  imported. Write the run again with the whole period; if the charges were removed on purpose,
  [contact us](https://costfluent.com/contact) and support can accept the change.
- **"Paste the SAS token only, not the SAS URL."** The **SAS token** holds the SAS URL. Paste the
  "Blob SAS token" alone, the part after the `?`.
- **"Use a container SAS whose permissions are in the token, not an account SAS or a stored access
  policy."** The SAS is an account SAS, a SAS for one blob, or one tied to a stored access policy.
  Generate it on the container, with no stored access policy, as under
  [Create a read-only key](#create-a-read-only-key).
- **"The SAS must grant Read and List and nothing else: Costfluent only lists and reads the export's
  files."** The SAS lacks Read or List, or also grants another permission, such as Write or Delete.
  Generate a SAS with only Read and List.
- **"The SAS must allow HTTPS only."** The SAS allows HTTP. Generate it with "Allowed protocols" set
  to HTTPS only.
- **"The SAS token has no expiry."** Generate a SAS with an expiry.
- **"The SAS has expired."** Generate a new SAS and enter it under
  [Rotating or removing access](#rotating-or-removing-access).
- **"Azure refused the SAS for …".** The SAS was not signed for this container, has expired, or
  the storage account key that signed it was rotated. Generate a new SAS on the container.
- **The storage account "does not exist".** Its Blob host does not resolve. Check the storage
  account's name.
- **"There is no container … in the storage account …".** Check the container's name.
- **OVHcloud cost is counted twice.** Both an [OVHcloud](/connect/ovhcloud) API key connection and
  a FOCUS bucket OVHcloud writes to are connected, and each imports the same cost. Connect one of them and remove
  the other.
