Skip to content

Commit 992f5af

Browse files
authored
Merge pull request #4 from jnywong/docs
Initial docs
2 parents 49d7772 + c78f879 commit 992f5af

9 files changed

Lines changed: 195 additions & 3 deletions

File tree

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
**/__pycache__
1+
**/__pycache__
2+
# MyST build outputs
3+
_build

CONTRIBUTING.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,8 @@ This will set up the hooks defined in `.pre-commit-config.yaml` to run automatic
5757

5858
## Chartpress
5959

60-
Helm charts are automatically published with [Chartpress](https://github.com/jupyterhub/chartpress) and hosted at [2i2c.org/jupyterhub-cost-monitoring](https://2i2c.org/jupyterhub-cost-monitoring/). Images are hosted at [Quay.io](https://quay.io/repository/2i2c/jupyterhub-cost-monitoring).
60+
Helm charts are automatically published with [Chartpress](https://github.com/jupyterhub/chartpress) and hosted at [2i2c.org/jupyterhub-cost-monitoring](https://2i2c.org/jupyterhub-cost-monitoring/).
61+
62+
Images are hosted at [Quay.io](https://quay.io/repository/2i2c/jupyterhub-cost-monitoring).
63+
64+
See the configuration in the [`chartpress.yaml`](https://github.com/2i2c-org/jupyterhub-cost-monitoring/blob/main/chartpress.yaml) file for more details.

docs/CONTRIBUTING.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Contributing
2+
3+
Please refer to [Project Jupyter's Code of Conduct](https://github.com/jupyter/governance/blob/HEAD/conduct/code_of_conduct.md) for guidelines on fostering a friendly and collaborative environment.
4+
5+
## Setting up a local development environment
6+
7+
This project uses the Python package manager `uv`. Below are the steps to set up a local development environment.
8+
9+
1. Clone this repository
10+
11+
```bash
12+
git clone https://github.com/2i2c-org/jupyterhub-cost-monitoring.git
13+
```
14+
15+
1. Install `uv`
16+
17+
```bash
18+
curl -LsSf https://astral.sh/uv/install.sh | sh
19+
```
20+
21+
1. Install project dependencies and source the `.venv` environment
22+
23+
```bash
24+
uv sync
25+
source .venv/bin/activate
26+
```
27+
28+
1. Authenticate with [AWS credentials](https://docs.aws.amazon.com/cli/v1/userguide/cli-configure-files.html) (requires [AWS CLI installation](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html)). This example uses a [session token](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html) from an MFA code associated with an MFA device:
29+
30+
```bash
31+
export AWS_PROFILE=<aws-profile-name>
32+
export CLUSTER_NAME=<cluster-name>
33+
export MFA_DEVICE_ID=<mfa-device-id>
34+
aws sts get-session-token --serial-number $MFA_DEVICE_ID --profile $AWS_PROFILE --token-code ******
35+
```
36+
37+
1. Run the Flask web server
38+
39+
```bash
40+
cd src/jupyterhub_cost_monitoring
41+
flask run --port=8080
42+
```
43+
44+
1. Visit [http://127.0.0.1:8080](http://127.0.0.1:8080) to view the application.
45+
46+
If you need to add or update dependencies, follow the guidance in [Working on projects | uv](https://docs.astral.sh/uv/guides/projects/#managing-dependencies)
47+
48+
## Pre-commit
49+
50+
This project uses [pre-commit](https://pre-commit.com/) to manage pre-commit hooks. To install the pre-commit hooks, run:
51+
52+
```bash
53+
pre-commit install
54+
```
55+
56+
This will set up the hooks defined in `.pre-commit-config.yaml` to run automatically on `git commit`.
57+
58+
## Chartpress
59+
60+
Helm charts are automatically published with [Chartpress](https://github.com/jupyterhub/chartpress) and hosted at [2i2c.org/jupyterhub-cost-monitoring](https://2i2c.org/jupyterhub-cost-monitoring/).
61+
62+
Images are hosted at [Quay.io](https://quay.io/repository/2i2c/jupyterhub-cost-monitoring).
63+
64+
See the configuration in the [`chartpress.yaml`](https://github.com/2i2c-org/jupyterhub-cost-monitoring/blob/main/chartpress.yaml) file for more details.

docs/README.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# jupyterhub-cost-monitoring
2+
3+
Cloud cost monitoring is moving beyond just preventing runaway cost explosions – it’s about empowering JupyterHub administrators with the guardrails they need to run efficient, transparent, and sustainable infrastructures. A cloud cost bill can show a broad view of services and machines provisioned, but how can we provide granular insights into each user and the value they are deriving from the hub on an application level?
4+
5+
This tool provides a per-user cost reporting system for JupyterHubs running on AWS, enabling hub administrators to monitor and report the costs associated with each user. This approach delivers cloud observability and cost transparency that can be reliably deployed using Kubernetes and integrated with Zero to JupyterHub distributions.
6+
7+
## Features
8+
9+
1. Metric Collection – Prometheus collects resource usage metrics (including CPU, memory, and storage) from individual user pods via standard and custom exporters.
10+
2. Cost Estimation – Usage is correlated with AWS cost data to estimate per-user costs.
11+
3. Visualization – Grafana dashboards display rich, interactive views of usage and cost data, making it easy to monitor trends, identify high-cost workloads, and generate reports for funders and decision-makers.
12+
13+
## Installation
14+
15+
This project is designed to be compatible with Zero to JupyterHub distributions, making it easy to deploy in the cloud with Kubernetes.
16+
17+
Add this project as a subchart of the z2jh `Chart.yaml` file with
18+
19+
```yaml
20+
dependencies:
21+
- name: jupyterhub-cost-monitoring
22+
version: "<version-number>"
23+
repository: "https://2i2c.org/jupyterhub-cost-monitoring/"
24+
condition: jupyterhub-cost-monitoring.enabled
25+
```
26+
27+
In the values file, enable the cost monitoring chart for your Kubernetes cluster:
28+
29+
```yaml
30+
jupyterhub-cost-monitoring:
31+
enabled: true
32+
extraEnv:
33+
- name: CLUSTER_NAME
34+
value: "<name-of-cluster>"
35+
```
36+
37+
## Contributing
38+
39+
Contributions to the `jupyterhub-cost-monitoring` project are welcome! Please follow the standard GitHub workflow:
40+
41+
1. Fork the repository.
42+
2. Create a feature branch.
43+
3. Submit a pull request.
44+
45+
Please refer to [`CONTRIUBUTING.md`](CONTRIBUTING.md) for more details.
46+
47+
## License
48+
49+
This project is licensed under the [BSD 3-Clause License](LICENSE).

docs/architecture.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Architecture
2+
3+
This document outlines the architecture of the project, including its dependencies, their interactions, and the overall design principles.
4+
5+
## Overview
6+
7+
![images/diagram.jpg](images/diagram.jpg)
8+
9+
:::{note}
10+
The diagram above is a temporary placeholder. The highlighted arrow indicates the key usage metrics pulled from the Prometheus server for the [per-user cost weightings](https://hackmd.io/@jnywong/HJB8ewSree#Compute-component).
11+
:::
12+
13+
Cost data is exposed with `jupyterhub-cost-monitoring` via a Flask web application that serves as an endpoint for other applications in the cluster. The following endpoints are available:
14+
15+
- `/index`: Returns all available endpoints.
16+
- `/ready`: Returns a 200 OK response if the application is ready to serve requests.
17+
- `hub_names`: Returns a list of all JupyterHub names in the cluster.
18+
- `total_costs`: Returns daily total costs and divided into two types:
19+
- *Account*: The total costs as reported by the cloud provider.
20+
- *Attributable*: The total costs that can be attributed by the `jupyterhub-cost-monitoring` application. For example, the act of querying the totals costs reported by cloud provider incurs a cost and is not included in *attributable* costs but is included in *account* costs.
21+
- `total_costs_per_hub`: Returns the daily total costs per hub listed in `hub_names`.
22+
- `total_costs_per_component`: Returns the daily total costs per cloud component.

docs/images/diagram.jpg

583 KB
Loading

docs/myst.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# See docs at: https://mystmd.org/guide/frontmatter
2+
version: 1
3+
project:
4+
id: e3df9ec3-12eb-4ef1-a8e6-0c4b4d8de40f
5+
# title:
6+
# description:
7+
# keywords: []
8+
# authors: []
9+
github: https://github.com/2i2c-org/jupyterhub-cost-monitoring
10+
# To autogenerate a Table of Contents, run "myst init --write-toc"
11+
site:
12+
template: book-theme
13+
# options:
14+
# favicon: favicon.ico
15+
# logo: site_logo.png

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@ dependencies = [
1111

1212
[dependency-groups]
1313
dev = [
14+
"mystmd>=1.6.0",
1415
"ruff>=0.12.5",
1516
]

uv.lock

Lines changed: 36 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)