Skip to content

Quick Start

Introduction

With Hawkflow.ai you can send data by using one of our integrations, or straight to our API.

Apache Airflow Integration

Hawkflow Airflow integration gives you access to all Hawkflow monitoring features by simply adding a single line of code to any of your Airflow DAGs. Check out the repository for detailed instructions here GitHub Repository for hawkflow-airflow.

Hawkflow API

The HawkFlow.ai API allows data to be sent to three different end points using one of our pre-built packages, or by sending data straight to our API by coding it yourself.

  • Timed API: Here you either send a start and end message, or use a decorator to time any part of your code.
  • Metrics API: Here you send key value pairs to record any numerical value. This can be anything you can think of, from model accuracy to number of rows in a database table.
  • Exceptions: Here you can send any exceptions and their content.

The Timed and Metrics end points will automatically analyse your data and let you know all kinds of interesting and important information about your code. Trends, anomalies, changes in time, and much more.

To see how to authenticate and send data to the APIs, you can look at the examples in the repo linked below, or follow our detailed development guide, also linked below.

How to get started

Code examples on GitHub

Take a look at our hawkflow code examples repo.

Detailed development guide

Check out our detailed development guide here.

Quick start guide

You can also find these examples on GitHub linked above.

Step One - Install the hawkflow pip package from your terminal

pip install hawkflow

Step Two - Try timing some code with start and end

Save this code to a .py file and run it. You will see how easy it is to time any part of your code and then see the results You can see the data you send on the Dashboard and on the Timed Data page Note: Once you have sent this example data, you can delete it on the Timed Data page

import time
from hawkflowclient.hawkflow_api import *

# authenticate with your API key, you only need to do this once in your app
hf = HawkflowAPI("YOUR-API-KEY")

# start timing your code - pass through process (required) and meta (optional) parameters
hf.start("your_process_name", "your_meta_data")

# you would not normally add a sleep, this is just for the example
time.sleep(5)

# end timing this piece of code - process (required) and meta (optional) parameters should match the start
hf.end("your_process_name", "your_meta_data")

Step One - Step Three - Try timing some code by using a decorator

Save this code to a .py file and run it. You will see how easy it is to time any part of your code and then see the results You can see the data you send on the Dashboard and on the Timed Data page Note: Once you have sent this example data, you can delete it on the Timed Data page

import time
from hawkflowclient.hawkflow_decorators import *

# use a decorator instead of HawkFLow start and end API calls
# the hawkflow_meta parameter is optional, include it if you would like to send more information
@HawkflowTimed(api_key="YOUR-API-KEY")
def my_example_function(hawkflow_meta="your_meta_data"):
    # put any code in this function, here we are sleeping just for an example
    time.sleep(5)

# run the code by calling your function
my_example_function(hawkflow_meta="example meta data")

Step One - Step Four - Try sending some metrics

Save this code to a .py file and run it. You will see how easy it is to send any number through to HawkFlow and then see the results You can see the metrics you send on the Dashboard and on the Metric Data page Note: Once you have sent this example data, you can delete it on the Metric Data page from hawkflowclient.hawkflow_api import *

# authenticate with your API key, you only need to do this once in your app
hf = HawkflowAPI("YOUR-API-KEY")

# create a dictionary with some metrics
my_metrics = {
    "kurtosis": 1441,
    "mean": 0.845,
    "users_count": 5465
}

# sending the metrics data to hawkflow
hf.metrics("your_process_name", "your_meta_data", my_metrics)

Step One - Step Five - Try sending an exception

Save this code to a .py file and run it. You will see how easy it is to send an exception through to HawkFlow and then see the results You can see the exception you send on the Exceptions page Note: Once you have sent this exception, you acknowledge it on the Exceptions page

import traceback
from hawkflowclient.hawkflow_api import *

# authenticate with your API key, you only need to do this once in your app
hf = HawkflowAPI("YOUR-API-KEY")

try:
    # cause a divide by zero exception
    1/0
except Exception as err:
    # sending the exception through to hawkflow
    # we are using traceback here, but you can use any technique you choose to capture your exception message
    hf.exception("your_process_name", "your_meta_data", traceback.format_exc())