> ## Documentation Index
> Fetch the complete documentation index at: https://docs.streamnative.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Enable Billing Dashboard

[apache-pulsar-grafana-dashboard-k8s image](https://hub.docker.com/r/streamnative/apache-pulsar-grafana-dashboard-k8s/) added a new billing dashboard from `0.1.0` which includes the

* Detailed hourly Compute Unit (CU) and Storage Unit (SU) usage snapshots.
* Compute Unit (CU) and Storage Unit (SU) usage accumulation by day.

## How to enable the billing dashboard

The billing dashboard requires data from [kube-state-metrics](https://github.com/kubernetes/kube-state-metrics) to provide CPU and memory data for Pulsar Pods. So it requires user to install `kube-state-metrics` in their kubernetes.

### Install kube-state-metrics

You can install the `kube-state-metrics` by

```
helm install kube-state-metrics -n kube-system prometheus-community/kube-state-metrics --version 4.29.0 -f https://raw.githubusercontent.com/streamnative/charts/master/examples/kube-state-metrics.yaml
```

And you can get the `kube-state-metrics` configuration example at [kube-state-metrics.yaml](https://github.com/streamnative/charts/blob/master/examples/kube-state-metrics.yaml)

### Add extra Prometheus scrape in `sn-platform`

By default the Prometheus in the `sn-platform` chart won’t scrape the `kube-state-metrics` metrics, it requires to add an `extraScrapeConfigs` in the Prometheus to scrape the KSM metrics.

<Note title="Note">
  If you install the `kube-state-metrics` in a different namespace, need to use the installed namespace in `kubernetes_sd_configs.namespaces.names`

  ```
  prometheus:
    extraScrapeConfigs:
      - job_name: kube-state-metrics
        honor_labels: true
        scheme: http
        kubernetes_sd_configs:
        - role: endpoints
          namespaces:
            names:
            - <Your KSM installed namespace>
  ```
</Note>

```
prometheus:
  extraScrapeConfigs:
    - job_name: kube-state-metrics
      honor_labels: true
      scheme: http
      kubernetes_sd_configs:
      - role: endpoints
        namespaces:
          names:
          - kube-system
      relabel_configs:
      - action: keep
        source_labels:
        - __meta_kubernetes_service_label_app_kubernetes_io_name
        regex: kube-state-metrics
      - action: keep
        source_labels:
        - __meta_kubernetes_endpoint_port_name
        regex: http
      - separator: ;
        regex: __meta_kubernetes_pod_label_(.+)
        replacement: $1
        action: labelmap
      - source_labels:
        - __meta_kubernetes_endpoint_address_target_kind
        - __meta_kubernetes_endpoint_address_target_name
        separator: ;
        regex: Node;(.*)
        replacement: ${1}
        target_label: node
      - source_labels:
        - __meta_kubernetes_endpoint_address_target_kind
        - __meta_kubernetes_endpoint_address_target_name
        separator: ;
        regex: Pod;(.*)
        replacement: ${1}
        target_label: pod
      - source_labels:
        - __meta_kubernetes_pod_name
        target_label: pod
      - source_labels:
        - __meta_kubernetes_namespace
        target_label: namespace
      - source_labels:
        - __meta_kubernetes_service_name
        target_label: service
      - source_labels:
        - __meta_kubernetes_service_name
        target_label: job
        replacement: ${1}
      - target_label: endpoint
        replacement: http
```
