Skip to content

Advanced UDA configuration

This page details advanced UDA configuration options for kdb Insights.

Adding logging to UDAs

You can use the logging wrapper functions provided by kdb Insights, which streamlines the logging process provided by Qlog.

  1. Make sure logging is enabled.

    Processes respect KXI_LOG_FORMAT, KXI_LOG_DEST, KXI_LOG_LEVELS or a KXI_LOG_CONFIG JSON file for routing and formatting, so set those as needed in your deployment.

    When debugging UDA issues, you can also follow the guidance in the UDA testing documentation and inspect DAP and Aggregator logs alongside your own log entries.

  2. Initialize logging in each code file:

    \d .example
    .log.initns[]
    
  3. Add log entries to the query and aggregation functions, making sure to use the namespace in the function call as follows:

    .example.log.info"Hello, world"
    

Recommendations

To assist with debugging debugging to have the following log entries as a minimum:

  • A debug log entry that takes the args dictionary or parameters

  • A completion log entry

  • Additional log entries specific to your code

Examples:

  • Using strings with log.info

    ```q \d .uda

    .log.initns[];

    example: {[args] / Log start with parameters log.info "Starting .uda.example";

    //UDA code
    
    / Log that the function is complete
    log.info ".uda.example: complete";
    
    // .kxi.response.ok output
    
    }
    

    ```

  • Adding args to the log output with log.debug

    ```q \d .uda

    .log.initns[];

    example: {[args] / Log start with parameters log.debug("Starting .uda.example args=%d";args);

    //UDA code
    
    / Log that the function is complete
    log.info ".uda.example: complete";
    
    // .kxi.response.ok output
    
    }
    

    ```

  • Adding multiple parameters to the log output with log.info

    \d .uda
    
    .log.initns[];
    
    example:{[param1;param2]
        / Log start with parameters
        log.info("Starting .uda.example, param1=%G param2=%G"; param1; param2);
    
        //UDA code
    
        / Log that the function is complete
        log.info("Completed .uda.example, param1=%G param2=%G"; param1; param2);
    
        // .kxi.response.ok output
    
        }
    
Back to top