How to Add a UDA to a Package
Introduction
Adding a User Defined Analytics (UDA) to a package involves organizing the necessary files, defining metadata, and configuring settings to ensure smooth deployment within kdb Insights.
Steps to add a UDA to a package
This section describes how to package a UDA that counts the number of records for specified columns and tables within a selected time range. This example is based on the Creating UDAs example and outlines how to deploy the package to kdb Insights.
Prerequisites
Before deploying a package containing a UDA, ensure the following prerequisites are met:
-
You have access to a kdb Insights instance.
-
The
kxi
CLI is installed and configured on your system. -
Prepare the UDA by following the UDA creation guide.
If you are unfamiliar with packaging in kdb Insights Enterprise, it is recommended to review this process before proceeding.
Refer to the Package Lifecycle documentation and the packaging Quickstart for more details.
Step 1 - Create or choose an existing package
Use the kxi package init
command to create a bare package structure.
kxi package init mypackage
Refer to the kdb Insights SDK specific documentation for guidance on deploying a UDA.
-
Add the UDA to an existing package that contains the database your UDA reads data from:
-
Refer to the Packaging guide to create the database package.
-
If the database is already configured, you can pull the database package locally, add the UDA to it, and then push the updated version to the deployment.
-
-
Alternatively, if want the UDA to be in a code-only package and loaded into the your database when it is deployed, you can use the
kxi package init
command to create a bare package structure.kxi package init mypackage
Step 2 - Create, define, and register the UDA
-
Add code to the package
Copy the code defined in the Creating a UDA section into a
myUDA.q
file in themypackage/src
folder within the package. This step adds the UDA to the package and registers it with the DAPs and Aggregator. -
Add entrypoints for the UDA
In the package, specify entrypoints labeled
data-access
andaggregator
to ensure that the UDA is loaded by the Data Access and Aggregator processes. To add these entrypoints, use the followingkxi package add
commands:kxi package add --to mypackage entrypoint --name aggregator --path src/myUDA.q kxi package add --to mypackage entrypoint --name data-access --path src/myUDA.q
Running the above
kxi package add
commands ensures thatsrc/myUDA.q
is included in theentrypoints
section of the manifest, as shown:entrypoints: default: init.q data-access: src/myUDA.q aggregator: src/myUDA.q
Step 3 - Load the UDA
To complete the deployment of the UDA, you must load it into the processes that utilize it. Follow the instructions below:
Refer to the Installing UDAs on kdb Insights SDK guide for details on setting environment variables to locate and load the package.
Refer to the Installing UDAs on kdb Insights Enterprise guide to configure environment variables in the database package to locate and load the UDA.