# FinOps uses case with FOCUS and superset

This guide provides step-by-step instructions on configuring your Data Project to take your first steps inside the FinOps with a FOCUS file.

![billing-guide](pics/banner.png)

---

- [Overview](#overview)
- [Prerequisites](#prerequisites)
- [Step-by-Step Billing Endpoint Configuration](#step-by-step-billing-endpoint-configuration)
  - [1. Retrieve the FOCUS file](#_1-retrieve-the-focus-file)
  - [2. Load the FOCUS file inside the Lakehouse](#_2-load-the-focus-file-inside-the-lakehouse)
  - [3. Create the Superset Application](#_3-create-the-superset-application)
  - [4. Create the Charts](#_4-create-the-charts)
  - [5. Create the Dashboard](#_5-create-the-dashboard)
- [Conclusion](#conclusion)

---

## Overview

[FOCUS](https://focus.finops.org/) is a specification inside the FinOps world to expose data consumption throughout multiple cloud providers. This guide will provide an example on how to consume this kind of file inside the Data Platform, and leverage the power of superset to create useful dashboards.


---

## Prerequisites

Before beginning, ensure you have:

- An active OVHcloud account with billing access

---

## Step-by-Step configuration

## 1. Retrieve the FOCUS file

We need to have a FOCUS formatted file to develop this use case. You can easily extract a CSV file with your OVHcloud account consumption by following this link: [OVHcloud Focus Extractor](https://finops.labs.ovh.net/).

![billing-guide](pics/finops-lab-1.png)

You can login on the interface through the OVHcloud SSO. This tool is a POC developped by our OVHcloud internal team meanwhile we are working to provide a more standard way to extract a FOCUS formatted file.

![billing-guide](pics/finops-lab-2.png)

Once logged, you can click on "Load Services Consumption".

![billing-guide](pics/finops-lab-3.png)

When the table is created, you can now click on "Export to CSV" to extract a complete file with your consumption.

![billing-guide](pics/finops-lab-4.png)

You have now a FOCUS formatted CSV that can be loaded inside the Data Platform

---


## 2. Load the FOCUS file inside the Lakehouse

### 2.1. Create the Data Source

You can now go to the [`Data Platform`](https://eu.dataplatform.ovh.net), inside the `Project` of your choice, then `Connectors` section, and to finish `Sources` in order to create a new `File Upload` source.

![billing-guide](pics/datacatalog-1.png)

You can name your source `focus`, and add the `export.csv` file you downloaded inside the previous step. You can now click on `Create`.

![billing-guide](pics/datacatalog-2.png)

Now the file is loaded, you can go into the `Explorer` section, and then click on your new source `finops` and then start the analysis of the file on clicking `export.csv`. After few seconds, your file should be analyzed successfully.

![billing-guide](pics/datacatalog-3.png)


### 2.3. Load the data into the Lakehouse

You can now go into the `Lakehouse Manager` section, and then `Tables`. You can hit `New Table` and `Create from a Connectors source`. Select your `export.csv` file, then hit `next`, rename the table into `consumption` and `create`.

![billing-guide](pics/lakehouse-1.png)
![billing-guide](pics/lakehouse-2.png)
![billing-guide](pics/lakehouse-3.png)
![billing-guide](pics/lakehouse-4.png)

---

## 3. Create the Superset Application

Now all the data is ready to be analyze in the Lakehouse, you need to create the Apache Superset Application. You can do so by following [this tutorial](/en/getting-further/install-apache-superset/index.md).

Considering this tutorial, we consider you followed it until the `Step 5: Create your first Chart` and until the `3. New Dataset' where you create the Dataset for:
- Database: `trino`
- Schema: `Default dataset`
- Table: `consumption` 

![billing-guide](pics/dataset-1.png)

You can now hit `Create Dataset and create dashboard`

---

## 4. Create the Charts

For now, we are going to create multiple charts, always from the same process:
- Click `Charts`, then `+ Chart`
- Chose the dataset `consumption`

We are going through multiple chart you can create:

### Effective cost - current

- Type: `Big number with Trendline` 
- Temporal axis: `billingperiodstart`
- Metric: `Billed Cost` aggregate `SUM`
- Comparison Period Lag: `1`
- Show timestamp: true

![billing-guide](pics/chart-1.png)


### Effective cost - previous month

- Type: `Big number` 
- Metric: `Billed Cost` aggregate `SUM`
- Filters: `billingperiodstart` with `Range type: advanced` as per the screenshot
- Display settings
  - Subtitle: `1 month ago`

![billing-guide](pics/chart-2.png)
![billing-guide](pics/chart-3.png)


### Effective cost - 2 month

- Type: `Big number` 
- Metric: `Billed Cost` aggregate `SUM`
- Filters: `billingperiodstart` with `Range type: advanced` and `- 3 month` and `-2 month`
- Display settings
  - Subtitle: `2 month ago`

![billing-guide](pics/chart-4.png)

### Most popular region by effective cost

- Type: `World Cloud` 
- Dimension: `regionname`
- Metric: `billedcost` with aggregate `SUM`


![billing-guide](pics/chart-5.png)


### Total accounts

- Type: `Big number` 
- Metric: `billingaccountname` aggregate `COUNT DISTINCT`
- Filters: `billingperiodstart` with `Last Month`
- Display settings
  - Subtitle: `Previous month`

![billing-guide](pics/chart-6.png)

### Total services

- Type: `Big number` 
- Metric: `resourceid` aggregate `COUNT DISTINCT`
- Filters: `billingperiodstart` with `Last Month`
- Display settings
  - Subtitle: `Previous month`

![billing-guide](pics/chart-7.png)

### Total providers

- Type: `Big number` 
- Metric: `resourceid` aggregate `COUNT DISTINCT`
- Filters: `billingperiodstart` with `Last Month`
- Display settings
  - Subtitle: `Previous month`

![billing-guide](pics/chart-8.png)


### Effective cost per service

- Type: `mixed chart` 
- X-Axis: `billingperiodstart`
- Time Grain: `Month`

- Query A:
  - Metrics: 'billedcost' with aggregate 'SUM'
  - Dimension: `Custom SQL` with `CONCAT(servicecategory, '-', servicesubcategory)`
  - filters: `billingperiodstart`

- Query B:
  - Metrics: 'billedcost' with aggregate 'SUM'
  - filters: `billingperiodstart`

- Customize:
  - Query A:
    - Serie type: `Bar`
    - Stack serie: `true`

![billing-guide](pics/chart-9.png)


### Cost repartition per service category and subcategory

- Type: `sunburst chart` 
- hierarchy: `servicecategory` and `servicecategory`
- primary metric: `billed cost`

- Filters:
  - `billingperiodstart`: 'Last month'

![billing-guide](pics/chart-10.png)

### Service Category Effective cost per region

- Type: `Sankey chart`
- Source: `region name`
- Target: `servicecategory`
- Metric: `billedcost`
- Filters: `billingperiodstart`

![billing-guide](pics/chart-11.png)

### Effective cost per sub account name

- Type: `Partition Chart`
- Metrics: `billedcost` aggregate by `SUM`
- Filters: `billingperiodstart`
- Dimensions: `billingaccountname`, `subaccountname`, `servicecategory`

![billing-guide](pics/chart-12.png)

---

## 5. Create the Dashboard

Now you have a lot of charts, you can put them together into a single place: the Dashboards. Click on `Dashboard`, then `Create`. You can name your dashboard `Billing Summary`, and drag and drop all the charts you previously created to finalize the view.

![billing-guide](pics/banner.png)

---
## Conclusion

By following these steps, you can effectively configure and utilize the OVHcloud Data Platform to implement your first advanced FinOps use case based on the FOCUS format.

---
##  Need help? 🆘

> If you are logging-in with an OVHcloud account, you can create a ticket to raise an incident or if you need support at the [OVHcloud Help Centre](https://help.ovhcloud.com/csm/fr-home?id=csm_index). Additionally, you can ask for support by reaching out to us on the Data Platform Channel within the [Discord Server](https://discord.com/channels/850031577277792286/1163465539981672559). There is a step-by-step guide in the [support](/en/support/index.md).
