Data analysis and reports
There are several data sources you can use to analyse the usage of your application and generate audit reports. We will describe them in more detail below and provide several examples of how they can be analysed.
- Web API Log - contains a list events that are created each time a license changes (eg. activation or change of expiration date). Data object changes are also logged in this log. Note, this log contains minimal information about the event.
- Events Log - contains events that were registered using Register Event as well several other internal events.
- Object Log - contains a list of events that are created when certain object types are added or modified to allow you to track all changes made by you and your team members.
The easiest way to analyse the logs is using our Python SDK in combination with Anaconda to manage the packages. Let’s look at how we can get some basics stats on the ratio of successful vs. unsuccessful requests. First, we need to load the relevant data:
from datetime import datetime, timedelta, date from licensing.models import * from licensing.methods import Key, Helpers import pandas as pd import matplotlib.pyplot as plt from tools import * month_back = int(datetime.datetime.timestamp(datetime.datetime.today() - datetime.timedelta(days=30))) logs =  ending_before=0 """ Loading the data """ while True: res = Key.get_web_api_log(token=get_api_token(), order_by="Id descending", limit = 1000, ending_before=ending_before) if res == None: break logs = logs + res if res[-1]["time"] < month_back: break; ending_before = res[-1]["id"] logs = pd.DataFrame(logs) logs = logs[logs["time"]>month_back]
Once we have the data in a pandas DataFrame, let’s create the plot:
def success(state): return state % 100 // 10 - 1 logs["Success"] = success(logs["state"]) logs[logs["Success"]== 0] = "Success" logs[logs["Success"]== 1] = "Failure" logs["Success"].value_counts(normalize=True).plot(kind="bar", title='Successful vs. unsuccessful API requests')
This will create the following plot: