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 either kdb Insights SDK or kdb Insights Enterprise.
Prerequisites
Before deploying a package containing a UDA on kdb Insights SDK or kdb Insights Enterprise, ensure the following prerequisites are met:
-
You have access to a kdb Insights instance.
-
Optionally, the
kxiCLI is installed and configured on your system. -
Prepare the UDA by following the UDA creation guide.
-
You have access to a kdb Insights instance.
-
The
kxiCLI 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 packaging documentation for more information.
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 initcommand 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.qfile in themypackage/srcfolder 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-accessandaggregatorto ensure that the UDA is loaded by the Data Access and Aggregator processes. To add these entrypoints, use the followingkxi package addcommands:kxi package add --to mypackage entrypoint --name aggregator --path src/myUDA.q kxi package add --to mypackage entrypoint --name data-access --path src/myUDA.qRunning the above
kxi package addcommands ensures thatsrc/myUDA.qis included in theentrypointssection 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 Load a package guide for details on how to load the UDA in kdb Insights Enterprise using the command line interface (CLI).