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 

Create a monitoring rule programmatically

3min

Kensu also lets you create rules with code.

For the third run of the pipeline, we add a new function, add_variability_constraint_data_source, to reporting_v2.py.

This function creates a rule that will create a ticket when Adj Close.mean value deviates by more than 30% from the previous value.

Here is the code:

Python
|
from kensu.utils.rule_engine import add_variability_constraint_data_source
add_variability_constraint_data_source('report_AppTech.csv',"Adj Close.mean",variation_in_percent=30)


1️⃣ Run the following commands, selecting either Docker or Local scripts:

Docker Pandas
Docker PySpark
Local Pandas
Local PySpark
|
python3 data_ingestion.py jan 2022 ; python3 reporting_v2.py jan 2022


2️⃣ In Kensu, you will see a new ticket. Click on the Tickets item on the Kensu homepage.

Document image


3️⃣ The new ticket violates a variability rule.

Document image




Updated 03 Mar 2023
Did this page help you?
Yes
No
PREVIOUS
Find the root cause with Kensu
NEXT
Getting credentials
Docs powered by archbee