Skip to main content

Cortisol Cortisol

Cortisol, accurately forecast log costs pre-production.

Test

cortisol

Cortisol is an open-source command-line tool designed specifically for web services. It offers easy-to-use cost estimation and forecasting capabilities tailored to main observability tools like Datadog, New Relic, Grafana and GCP Cloud Logging. Cortisol assists users in planning and optimizing their log costs before deploying their web services. It operates on a foundation inspired by Locust, allowing users to define user behavior using a regular Python script 💰📉.

For detailed reference to Cortisol commands please go to: Read the Docs

Installation

Prerequisites

Cortisol requires one of the following Python versions: 3.8, 3.9, 3.10 or 3.11

Install cortisol

At the command line:

pip install cortisol

If you have an Apple M1 CPU, we suggest installing using Poetry as a dependency management. Otherwise, the underline gevent library may not work.

Getting started

First things first! We need a RESTful service and so you'll need to do the following steps:

  1. Clone this example repo https://github.com/CortisolAI/getting-started-example
  2. cd getting-started-example
  3. mkvirtualenv getting-started-cortisol
  4. python -m app.main which will make the service available at http://127.0.0.1:8080/

And, now, it's time to create your first cortisol file. Copy and paste the following in a file named cortisolfile.py:

from locust import task

from cortisol.cortisollib.users import CortisolHttpUser


class WebsiteUser(CortisolHttpUser):
    @task
    def my_task(self):
        self.client.get("/")

Go to the virtualenv where the cortisol library is installed and run the following command in the terminal. Make sure to change the base path for the --log-file argument:

cortisol logs cost-estimate --host http://127.0.0.1:8080 --users 10 --spawn-rate 5 --run-time 10s --cortisol-file cortisolfile.py --log-file /some/path/getting-started-example/cortisol_app.log

Commands

Log Cost Estimate

Name

Forecast log costs

Synopsis

cortisol logs cost-estimate --host HOST --log-file LOG_FILE --users NUM_USERS --spawn-rate SPAWN_RATE --run-time RUN_TIME -cortisol-file CORTISOL_PYTHON_FILE

Description

Forecast log costs pre-production with Cortisol for Datadog, New Relic, and Grafana

Example

cortisol logs cost-estimate --host http://10.20.31.32:8000 --users 10 --spawn-rate 5 --run-time 10s --cortisol-file ./examples/cortisolfile.py --log-file /app/playground_app.log

Required Flags - Option 1

-f, --cortisol-file PATH Path to the CORTISOL_FILE

-h, --host TEXT Host in the following format: http://10.20.31.32 or http://10.20.31.32:8000

-l, --log-file PATH Path to log file

-u, --users INTEGER Peak number of concurrent users

-r, --spawn-rate INTEGER Rate to spawn users at (users per second)

-t, --run-time TEXT Stop after the specified amount of time, e.g. (50, 30s, 200m, 5h, 2h30m, etc.). Default unit in seconds.

Required Flags - Option 2

All the latter options plus the following in case your application run in a Docker container:

-c, --container-id TEXT Optional docker container id where your application runs

Example
cortisol logs cost-estimate --host http://127.0.0.1:8080 --users 100 --spawn-rate 5 --run-time 10s --cortisol-file ./examples/cortisolfile.py --log-file /app/playground_app.log --container-id 1212aa67e530af75b3310e1e5b30261b36844a6748df1d321088c4d48a20ebd0

Required Flags - Option 3

--config PATH Path to config file (YAML or JSON) containing the long version of flags from option 1

Optional Flags

--stats-file PATH Path where to store the cortisol statistics output as a csv

Here's a YAML example:

host: "http://10.20.31.32:8000"
log-file: "/path/to/logfile"
users: 100
spawn-rate: 30
run-time: "20m"
cortisol-file: "some_cortisol_file.py"
stats-file: "cortisol_stats.csv"

Here's a YAML example with docker container id:

host: "http://10.20.31.32:8000"
log-file: "/path/to/logfile"
users: 100
spawn-rate: 30
run-time: "20m"
cortisol-file: "some_cortisol_file.py"
container-id: "80f1bc1e7feb"
stats-file: "cortisol_stats.csv"

and a JSON example:

{
  "host": "http://10.20.31.32:8000",
  "log_file": "/path/to/logfile",
  "users": 100,
  "spawn_rate": 30,
  "run_time": "20m",
  "cortisol_file": "some_cortisol_file.py",
  "container_id": "80f1bc1e7feb",
  "stats-file": "cortisol_stats.csv"
}

Metadata

Release files for cortisol 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cortisol 0.3.0
File Size Uploaded
cortisol-0.3.0.tar.gz 18.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for cortisol 0.3.0
File Interpreter ABI Platform
cortisol-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 39.4 kB

Release files / cortisol-0.3.0.tar.gz

Download URL cortisol-0.3.0.tar.gz
Size 18.5 kB
Tags Source
SHA-256 checksum
How to use checksums
9f3894382a95869809927a678f7dae56be84532e5d78ce3a15292af6b1f69f85
BLAKE2b-256 checksum
How to use checksums
4749248e0760b21e0a2b8803b61f9aa7bdcff073e44da9cc95b6083a9b60ff6a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.5.1 CPython/3.11.5 Linux/6.2.0-1011-azure

Release files / cortisol-0.3.0-py3-none-any.whl

Download URL cortisol-0.3.0-py3-none-any.whl
Size 20.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0df994aaaee6c83bece196db2fc94b4639ac93c92f050ebc5b54c65be279e0e9
BLAKE2b-256 checksum
How to use checksums
7bfb78af8b31ca35e90c49d4165900bb37d7860003d5714d475cbc8233d2b881
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.5.1 CPython/3.11.5 Linux/6.2.0-1011-azure

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page