Note: To monitor Python application in APM Insight, Data Exporter is mandatory and should be installed along with the Python agent. The Data Exporter is an independent process that communicates application metrics and traces to the Applications Manager server.
To learn how to install Data Exporter, click on any of the links for Windows and Linux OS.
To install APM Insight Python agent, follow the steps given below:
python3 setup.py install
To deploy the Python agent into your application, you need to run your application using the following command:
$ apminsight-run <apm-options> "<user_application_execute_command>"
Following are the list of options that can be used in the place of <apm-options>
argument in the command:
apm-options | Description |
---|---|
---apm_app_name "monitorname" | To add the APM application name. |
--apm_log_dir "log location" | To add a custom log directory for storing APM logs. |
--apm_debug "true/false" | To enable debug mode. |
--apm_exp_host “DataExporter_Host” | To configure the Applications Manager DataExporter host. |
--apm_exp_status_port “DataExporter_Status_Port” | To configure the Applications Manager DataExporter status port. |
--apm_exp_data_port “DataExporter_Data_Port” | To configure the Applications Manager DataExporter data port. |
Examples:
If you want to configure the application name, use the below command:
$ apminsight-run --apm_app_name "monitorname" sampleapp.py
If you want to configure the directory location, use the below command:
$ apminsight-run --apm_app_name "monitorname" --apm_log_dir "logs location" sampleapp.py
from apminsight import initialize_agent
initialize_agent({
"appname" : "<Your_application_name>",
})
from apminsight import initialize_agent
initialize_agent({
"appname" : "<Your_application_name>",
'''Change if Applications Manager Data Exporter is not running in the default ports (20021, 20022):'''
"exporter_status_port" : "<DataExporter_status_port>",
"exporter_data_port" : "<DataExporter_data_port>",
'''If you are running Applications Manager Data Exporter on a separate machine/server or as a Docker container:'''
"exporter_host" : "<HostName/ContainerName_where_Data_Exporter_is_running>"
})
You can also configure the agent using the required environment variables listed below:
Configuration | Description |
---|---|
$ export APM_APP_NAME="<Your_application_name>" | To add the application name. |
$ export APM_LOGS_DIR="<logs_storing_path>" | To configure the log directory. |
$ export APM_EXPORTER_STATUS_PORT=<DataExporter_status_port> $ export APM_EXPORTER_DATA_PORT=<DataExporter_data_port> |
To change the Applications Manager Data Exporter's default running ports (20021, 20022). |
$ APM_EXPORTER_HOST=<HostName/ContainerName_where_DataExporter_is_running> | To change the host of the Applications Manager Data Exporter to a different machine or server or as a Docker container. |