QRadar Python helper library functions
The QRadar® Python helper library (qpylib) contains several useful functions that you can use to add logging, make REST API calls, and convert JSON objects to Python dictionaries.
All functions that you import into your app's views.py file can be called globally.
The following table describes functions that you can import into your app's views.py file.
Function | Format | Description |
---|---|---|
log() |
Here's an example:
|
Import the qpylib helper library into your app's
views.py to use the log() function. This function writes
messages at your chosen log level to the /store/log/app.log file. By default, logging is turned on and set to INFO level. Lower level logging messages are ignored. Use the POST /log_level endpoint to change |
set_log_level( log_level ) |
|
Set the current log level. Used by the POST /log_level endpoint but can also be called programmatically. |
REST() |
For example:
|
Import the qpylib library to use this function to make calls to the QRadar REST API endpoints. The endpoint takes care of authentication and authorization by reusing the security tokens that are passed on the request from QRadar. |
to_json_dict( JSON ) |
|
Converts a JSON object in to a Python dictionary. |