Skip to main content
Version: 2.4.1

Resoto Notebook

Resoto Notebook is a library that allows you to interact with Resoto Core using Jupyter Notebook, a web-based interactive Python shell. It is a powerful tool for interactive data analysis and visualization.

Installation

Simply install the resotonotebook package and Jupyter's notebook package using pip:

pip install notebook resotonotebook

Then, start Jupyter Notebook:

jupyter notebook

Usage

Setup

First, create a new notebook by clicking New Python 3:

Create a new notebook

Then, instantiate the ResotoNotebook object with the URL and PSK (if configured) of your Resoto Core instance:

from resotonotebook import ResotoNotebook
rnb = ResotoNotebook("https://localhost:8900", psk=None)

Visualization

Visualizing the dependencies between resources as a graph can be useful to understand what's running in your cloud. Here are some examples:

Render the accounts as an svg graph:

from IPython.display import display_png as render_png, display_svg as render_svg
render_svg(rnb.graph("is(cloud)"))

render_cloud

Make a graph of all clouds with name do and their successors one level deep and render it as a PNG image:

render_png(rnb.graph("is(cloud) and name=do <-[0:2]->"))

render_cloud_do

Show the instances/cores/account heatmap, to see which accounts use a lot of expensive instances:

import plotly.express as px
data = rnb.search("is(instance)")
px.density_heatmap(data, x="account_id", y="instance_cores")

heatmap

Search all resources for a properties with values digitalocean and foobar. Full text search is useful when you have a keyword, e.g. e-mail address or name, and you want to find all resources related to it:

rnb.search('"digitalocean" and "foobar"')

search_foo

Counting

Get number of all collected instances by kind:

rnb.search("is(instance)").groupby(["kind"])["kind"].count()

count

Searching by Kind

Get list of all the DigitalOcean droplets:

rnb.search("is(digitalocean_droplet)")

search_by_kind

Selecting Properties

Get list of name, type, cores, and memory for each instance:

rnb.search("is(instance)")[["region_id", "instance_type","instance_cores", "instance_memory"]]

instance_list

Filtering

Get list of all compute instances with more than two CPU cores:

rnb.search("is(instance) and instance_cores > 2")['id']

filter

Get list volumes that are not in use, larger than 10GB, older than 30 days.

rnb.search("is(volume) and volume_status != in-use and volume_size > 10 and age > 30d")['id']

filter2

Aggregation

Count the number of instances by account ID:

rnb.search("is(instance)").groupby(["account_id"])["account_id"].count()

aggreagation-1

Aggregate CPU cores data grouped by account and cloud. This is useful for identifying the most expensive accounts:

rnb.search("is(instance) and instance_status == running") \
.groupby(["account_id", "cloud_id"], as_index=False)[["instance_cores"]] \
.sum()

aggregation-2

Next Steps

You can find the examples from this page in the someengineering/resotonotebook GitHub repository.

That's it for now. Happy exploring!