Customizing the Python data collector for IBM Cloud applications

You can add environment variables in the IBM® Cloud user interface (UI) to customize the monitoring for your IBM Cloud application. Use the following information to add the variables according to your needs.

User-defined environment variables for the Python data collector

You can use the information in the following table to customize Python monitoring on IBM Cloud.

Table 1. Supported user-defined environment variables for Python monitoring on IBM Cloud
Variable name Importance Value Description
APM_BM_GATEWAY_URL Optional
  • https://<server ip or hostname>:443
  • http://<server ip or hostname>:80
The target on-premises server gateway URL.
APM_KEYFILE_PSWD Optional Encrypted password of the key file The encrypted key file password that is paired with the key file. If you are a Linux user, you can use the echo -n <keyfile password> | base64 command to encrypt your password.
Note: Set this variable only when you configured the Gateway to use HTTPS.
APM_KEYFILE_URL Optional http://<hosted http server>:<port>/keyfile.p12 The URL to download the key file.
Note: Set this variable only when you configured the Gateway to use HTTPS.
KPG_ENABLE_DEEPDIVE Optional
  • False
  • True
Enables or disables the collection of diagnostics data.
  • True: The default value. If you set this variable to True, diagnostics data are collected.
  • False: If you set this variable to False, diagnostics data are not collected.

If you do not set this variable, diagnostics data are collected.

KPG_DD_CONFIG_FILE Optional File name of the diagnostics monitoring configuration file. File name of the diagnostics monitoring configuration file. The default file name is kpg_dd_config.xml.
Note: After you customize the settings in this file, you must put it in the application root directory.

If you do not set this variable, the default configuration file kpg_dd_config.xml in the data collector package is used.

KPG_DD_APP_PATH Optional Path to the Python application. The path to the Python application or the module for which the data collector collects diagnostics data. Separate the paths of different Python applications and modules that you want to monitor with a semi-colon ;.

If you do not set this variable, the data collector collects data for requests and the modules that your application use. Data of requests in Python lib are not collected.

KPG_DD_SECURITY_FILTER Optional
  • True
  • False
  • True: The default value. If you set this variable to True, values (such as the passwords) are masked in SQL statements and parameters are not displayed in group widget Request Context.
  • False: If you set this variable to False, values in SQL statements are not masked and parameters are displayed in group widget Request Context.

If you do not set this variable, values (such as the passwords) are masked in SQL statements and parameters are not displayed in group widget Request Context.

KPG_GC_STATS Optional True All statistical functions of python garbage collection are enabled. When you set this value to True, it equals running the following command:

gc.set_debug(gc.DEBUG_STATS |
gc.DEBUG_COLLECTABLE |
gc.DEBUG_UNCOLLECTABLE | 
gc.DEBUG_INSTANCES | 
gc.DEBUG_OBJECTS )

To disable KPG_GC_STATS, delete this environment variable. Do not set it to False.

Note: Never set KPG_SAVE_ALL=True in your formal production environment. It is only for the debug mode. Make sure that enough memory is assigned to the application.
KPG_LOG_LEVEL Optional
  • DEBUG
  • ERROR
  • INFO
  • DEBUG: Only useful debug information is printed in the log, for example, collected data, data that are sent to server, and server response.
  • ERROR: Only information about exceptions and unexpected situations is printed in the log.
  • INFO: The summary information about the data collector for the user to know what it is doing is printed in the log.
KPG_LOG_TOCONSOLE Optional
  • Y
  • True
  • Any other value that is not False
The log is printed to console and you can see the log by running the command cf logs <appname>.
KPG_SAVE_ALL Optional True All unreferenced objects are saved into gc.garbage, and you need to clear gc.garbage every minute (the data collector clears it for you). When the value is set to True, it equals running the following command:
gc.set_debug(gc.SAVE_ALL)
To disable KPG_SAVE_ALL, delete this environment variable. Do not set it to False.
Note: Never set KPG_SAVE_ALL=True in your formal production environment. It is only for the debug mode. Make sure that enough memory is assigned to the application.