Documentation

⌘K
Connectors
Getting started with the Kensu Community Edition
Marketing campaign
Financial data report
Getting credentials
Recipe: Observe Your First Pipeline
Agents: getting started
Python
PySpark
Scala Spark
Databricks Notebook
Agent Listing
Docs powered by archbee 

Install the library

12min

Here we show how to set up a virtual environment and add the required Python packages.

⚙️ Pre-requisites

1️⃣ Credentials

You need an ingestion Token and the Ingestion API URL. Follow these instructions.

2️⃣ Clone Kensu sample code to try the agent

Clone the repository:

Shell
|
git clone https://github.com/kensuio-oss/kensu-getting-started-with-agents.git
cd kensu-getting-started-with-agents/kensu-py-example


Inside find:

  • sample programs: script.py and script_with_kensu.py
  • data files in: data
  • config file:conf.ini

Set up a virtual environment

You need to create a Python virtual environment. This is because on UNIX-based systems, like Mac and Ubuntu, Python 2.x is part of the operating system. So you might get conflicts installing Python packages into that. A virtual environment means one created in the logged-in user's directories instead of system directories.

See below for notes on setting up a virtual environment on Windows

First, you need to install Python 3. On Mac and Windows systems you can just download that from https://www.python.org/downloads/. On Ubuntu 20.04 and greater, it is already installed. If it is not installed the which python command will say nothing.

Shell
|
which python3
/home/walker/py3/bin/python3




Install it with:

Shell
|
sudo apt-get install python3




Check the version with this:

Shell
|
python --version




On Linux systems, like Ubuntu and Debian, you also need to install:

Shell
|
sudo apt-get install python3-venv




Then create a virtual environment using the command below. Do this in your home directory as it will put it there. In this example, we use the name py38, but you can use any name.

Shell
|
python3 -m venv py38 




Now activate the environment:

Shell
|
source py38/bin/activate




To deactivate the environment just type deactivate.

Set up a virtual environment on Windows

Open the DOS command prompt by running cmd. Create and activate a Python virtual environment like shown below. Here we use the name py310, but you can use any name you like. If it works, the prompt will change to (py310).

Shell
|
python.exe -m py310
py310\Scripts\activate.bat


Install Python packages

After you have sourced the environment created above, add these three Python packages. Kensu is the Kensu-py package. Since it extends Pandas we will install that as well.

For M1 Mac users: if Pandas is not already installed, we advise you to use conda instead of pip.

Shell
|
pip install kensu
pip install pandas==1.3.5




Updated 03 Mar 2023
Did this page help you?
Yes
No
PREVIOUS
Python
NEXT
Configure the Python agent
Docs powered by archbee 
TABLE OF CONTENTS
⚙️ Pre-requisites
Set up a virtual environment
Set up a virtual environment on Windows
Install Python packages