|
| 1 | +# Cost Tracking with OpenCost in OCI Lens |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +OCI GPU Scanner integrates OpenCost to provide comprehensive cost visibility for Kubernetes workloads running on OCI. OpenCost exposes detailed cost and resource allocation metrics that are automatically collected by Prometheus and can be visualized in Grafana. |
| 6 | + |
| 7 | +## Metrics Reference |
| 8 | + |
| 9 | +### Node Cost Metrics |
| 10 | + |
| 11 | +These metrics provide hourly cost information at the node level. |
| 12 | + |
| 13 | +#### `oci_lens_cost_node_cpu_hourly_cost` |
| 14 | +- **Description**: Hourly cost per oCPU core on the node |
| 15 | +- **Unit**: USD per hour per oCPU core |
| 16 | + |
| 17 | +#### `oci_lens_cost_node_ram_hourly_cost` |
| 18 | +- **Description**: Hourly cost per GiB of RAM on the node |
| 19 | +- **Unit**: USD per hour per GiB |
| 20 | + |
| 21 | +#### `oci_lens_cost_node_gpu_hourly_cost` |
| 22 | +- **Description**: Hourly cost per GPU on the node |
| 23 | +- **Unit**: USD per hour per GPU |
| 24 | + |
| 25 | +#### `oci_lens_cost_node_gpu_count` |
| 26 | +- **Description**: Number of GPUs available on the node |
| 27 | +- **Unit**: Count |
| 28 | + |
| 29 | +#### `oci_lens_cost_node_total_hourly_cost` |
| 30 | +- **Description**: Total hourly cost for the entire node |
| 31 | +- **Unit**: USD per hour |
| 32 | +- **Calculation**: |
| 33 | + - **CPU nodes**: `(vCPU_cores / 2) × oci_lens_cost_node_cpu_hourly_cost + RAM_GiB × oci_lens_cost_node_ram_hourly_cost` |
| 34 | + - **GPU nodes**: `GPU_count × oci_lens_cost_node_gpu_hourly_cost` (CPU/RAM included in GPU cost) |
| 35 | +> **Note**: OCI pricing uses OCPUs (1 OCPU = 2 vCPUs), so CPU cost calculation divides vCPU count by 2. |
| 36 | +
|
| 37 | +--- |
| 38 | + |
| 39 | +### Storage Metrics |
| 40 | + |
| 41 | +#### `oci_lens_cost_pv_hourly_cost` |
| 42 | +- **Description**: Hourly cost for persistent volumes |
| 43 | +- **Unit**: USD per hour |
| 44 | + |
| 45 | +--- |
| 46 | + |
| 47 | +### Container Resource Allocation Metrics |
| 48 | + |
| 49 | +These metrics show actual resource allocations to containers, used for chargeback and cost attribution. |
| 50 | + |
| 51 | +#### `oci_lens_cost_container_cpu_allocation` |
| 52 | +- **Description**: Number of CPU cores allocated to the container |
| 53 | +- **Unit**: CPU cores |
| 54 | + |
| 55 | +#### `oci_lens_cost_container_memory_allocation_bytes` |
| 56 | +- **Description**: Memory (RAM) allocated to the container in bytes |
| 57 | +- **Unit**: Bytes |
| 58 | + |
| 59 | +#### `oci_lens_cost_container_gpu_allocation` |
| 60 | +- **Description**: Number of GPUs allocated to the container |
| 61 | +- **Unit**: GPU count |
| 62 | +- **Supported GPU types**: |
| 63 | + - NVIDIA GPUs (`nvidia.com/gpu`) |
| 64 | + - AMD GPUs (`amd.com/gpu`) |
| 65 | + |
| 66 | +#### `oci_lens_cost_pod_pvc_allocation` |
| 67 | +- **Description**: Persistent volume claim allocation for pods |
| 68 | +- **Unit**: Bytes allocated per claim |
| 69 | + |
| 70 | +--- |
| 71 | + |
| 72 | +### Cluster and Network Metrics |
| 73 | + |
| 74 | +#### `oci_lens_cost_kubecost_cluster_info` |
| 75 | +- **Description**: Cluster metadata and information |
| 76 | + |
| 77 | +#### `oci_lens_cost_kubecost_node_is_spot` |
| 78 | +- **Description**: Indicates if a node is a spot/preemptible instance |
| 79 | +- **Values**: |
| 80 | + - `1` = Spot instance |
| 81 | + - `0` = On-demand instance |
| 82 | + |
| 83 | +#### `oci_lens_cost_kubecost_network_zone_egress_cost` |
| 84 | +- **Description**: Cost per GiB for cross-availability-zone network egress |
| 85 | +- **Unit**: USD per GiB |
| 86 | + |
| 87 | +#### `oci_lens_cost_kubecost_network_region_egress_cost` |
| 88 | +- **Description**: Cost per GiB for cross-region network egress |
| 89 | +- **Unit**: USD per GiB |
| 90 | + |
| 91 | +#### `oci_lens_cost_kubecost_network_internet_egress_cost` |
| 92 | +- **Description**: Cost per GiB for internet network egress |
| 93 | +- **Unit**: USD per GiB |
| 94 | + |
| 95 | +#### `oci_lens_cost_kubecost_cluster_management_cost` |
| 96 | +- **Description**: Hourly cluster management fee |
| 97 | +- **Unit**: USD per hour |
| 98 | + |
| 99 | +#### `oci_lens_cost_kubecost_load_balancer_cost` |
| 100 | +- **Description**: Hourly cost for load balancers |
| 101 | +- **Unit**: USD per hour |
| 102 | + |
| 103 | +--- |
| 104 | + |
| 105 | +## Additional Resources |
| 106 | + |
| 107 | +- [OCI GPU Scanner OpenCost Fork](https://github.com/gablyu-oci/opencost/tree/custom_pricing) - OCI GPU Scanner specific custom pricing implementation |
| 108 | +- [OCI GPU Scanner OpenCost Helm Chart](https://github.com/gablyu-oci/opencost-helm-chart/tree/pricing-configs) - OCI GPU Scanner specific deployment configuration |
| 109 | +- [OpenCost Documentation](https://www.opencost.io/docs/) - OpenCost Official documentation |
| 110 | + |
| 111 | + |
0 commit comments