Package: cortisol
Cortisol, accurately forecast log costs pre-production.cortisolCortisol 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 likeDatadog,New Relic,GrafanaandGCP Cloud Logging. Cortisol assists users in planning and optimizing their log costs before deploying their web services. It operates on a foundation inspired byLocust, allowing users to define user behavior using a regular Python script 💰📉.For detailed reference to Cortisol commands please go to:Read the DocsInstallationPrerequisitesCortisol requires one of the following Python versions: 3.8, 3.9, 3.10 or 3.11Install cortisolAt the command line:pip install cortisolIf you have an Apple M1 CPU, we suggest installing using Poetry as a dependency management. Otherwise, the underline gevent library may not work.Getting startedFirst things first! We need a RESTful service and so you'll need to do the following steps:Clone this example repohttps://github.com/CortisolAI/getting-started-examplecd getting-started-examplemkvirtualenv getting-started-cortisolpython -m app.mainwhich will make the service available athttp://127.0.0.1:8080/And, now, it's time to create your first cortisol file. Copy and paste the following in a file namedcortisolfile.py:fromlocustimporttaskfromcortisol.cortisollib.usersimportCortisolHttpUserclassWebsiteUser(CortisolHttpUser):@taskdefmy_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-fileargument: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.logCommandsLog Cost EstimateNameForecast log costsSynopsiscortisol logs cost-estimate --host HOST --log-file LOG_FILE --users NUM_USERS --spawn-rate SPAWN_RATE --run-time RUN_TIME -cortisol-file CORTISOL_PYTHON_FILEDescriptionForecast log costs pre-production with Cortisol for Datadog, New Relic, and GrafanaExamplecortisol 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.logRequired Flags - Option 1-f, --cortisol-file PATHPath to the CORTISOL_FILE-h, --host TEXTHost in the following format:http://10.20.31.32orhttp://10.20.31.32:8000-l, --log-file PATHPath to log file-u, --users INTEGERPeak number of concurrent users-r, --spawn-rate INTEGERRate to spawn users at (users per second)-t, --run-time TEXTStop after the specified amount of time, e.g. (50, 30s, 200m, 5h, 2h30m, etc.). Default unit in seconds.Required Flags - Option 2All the latter options plus the following in case your application run in a Docker container:-c, --container-id TEXTOptional docker container id where your application runsExamplecortisol 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 1212aa67e530af75b3310e1e5b30261b36844a6748df1d321088c4d48a20ebd0Required Flags - Option 3--config PATHPath to config file (YAML or JSON) containing the long version of flags from option 1Optional Flags--stats-file PATHPath where to store the cortisol statistics output as a csvHere's a YAML example:host:"http://10.20.31.32:8000"log-file:"/path/to/logfile"users:100spawn-rate:30run-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:100spawn-rate:30run-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"}