在 Docker 容器中安装 S247DataExporter 和 Python Agent(同一容器)
注意
在开始安装之前,请参阅此 知识库文章,了解前提条件、配置步骤和备选安装方式的详细信息。
按照以下步骤在 Docker 容器中安装 S247DataExporter 和 Python Agent:
- 在 Dockerfile 中安装 APM Insight Python 包,并通过 APM_APP_NAME 环境变量设置 Python 应用程序名称。
- 在 Dockerfile 中添加带有安装参数的 S247DataExporter 安装命令。
- 在 entrypoint 脚本文件中,通过将命令作为参数传递给 apminsight-run 命令来启动 S247DataExporter 和您的 Python 应用程序。
Dockerfile 示例
FROM python:3.9
#
# Your code
#
# Prerequisite (ignore if already installed)
RUN apt-get update && apt-get install -y wget unzip procps curl
# Set your license key and appplication name to be shown in site24x7 apm client
ENV S247_LICENSE_KEY="license-key"
ENV APM_APP_NAME="Python-Application"
# installing the Python agent
pip3 install -U apminsight
# installing the S247DataExporter (This is mandatory for the Python agent to work)
RUN wget -O InstallDataExporter.sh https://staticdownloads.site24x7.com/apminsight/S247DataExporter/linux/InstallDataExporter.sh
RUN sh InstallDataExporter.sh -root -nsvc
# Entrypoint script
COPY ./example-entrypoint.sh /example-entrypoint.sh
ENTRYPOINT [ "sh","/example-entrypoint.sh" ]
入口脚本示例
#!/bin/sh
# Start S247DataExporter
sh /opt/S247DataExporter/bin/service.sh start
# Pass your application start command to the apminsight-run script
apminsight-run <user application execute command>
注意
默认情况下,Python 应用程序分别使用 20021 和 20022 作为状态端口和数据端口。如果您需要修改这些端口,可以使用以下键通过环境变量设置:
- 状态端口 - AGENT_STATUS_PORT
- 数据端口 - AGENT_DATA_PORT
相关文章
如何在 Docker 容器中安装各种 APM Insight Agent
Java | .NET | PHP | Node.js
如何在 Kubernetes 环境中安装各种 APM Insight Agent
Java | .NET | PHP | Node.js | Python
-
本页内容
- Dockerfile 示例
- 入口脚本示例
- 相关文章
