Docker에서 Python용 App and API Protection 설정
You can enable App and API Protection for Python services with the following setup options:
- If your Python service already has APM tracing set up and running, then skip to service configuration
- If your Python service doesn't have APM tracing set up, you can easily enable App and API Protection with Datadog's Automatic Installation
- Otherwise, keep reading the following manual setup instructions
Overview
App and API Protection leverages the Datadog Python library to monitor and secure your Python service. The library integrates seamlessly with your existing application without requiring code changes.
For detailed compatibility information, including supported Python versions, frameworks, and deployment environments, see Python Compatibility Requirements.
This guide explains how to set up App and API Protection (AAP) for Python applications. The setup involves:
- Installing the Datadog Agent
- Enabling App and API Protection monitoring
- Running your Python application with the Datadog Agent
- Verifying the setup
전제 조건
- 호스트에 설치된 Docker
- Docker로 컨테이너화된 Python 애플리케이션
- Datadog API 키
- Datadog Python SDK(버전 요구 사항 참조)
1. Datadog Agent 설치
Docker용 설정 지침에 따라 Datadog Agent를 설치합니다.
2. App and API Protection 모니터링 활성화
Automatically enabling App and API Protection through Remote Configuration
You can enable services with remote configuration on your services dashboard.
Check the box for the service you want to enable App and API Protection for under Activate on your APM services.
App and API Protection 모니터링 수동 활성화
Dockerfile에 다음 환경 변수를 추가합니다.
# Install the Datadog Python SDK
RUN pip install ddtrace
# Set environment variables
ENV DD_APPSEC_ENABLED=true
ENV DD_SERVICE=<YOUR_SERVICE_NAME>
ENV DD_ENV=<YOUR_ENVIRONMENT>
# Use ddtrace-run to start your application
CMD ["ddtrace-run", "python", "app.py"]
App and API Protection을 활성화한 상태에서 APM 추적을 비활성화하려면 APM 추적 변수를 ‘false’로 설정해야 합니다.
Dockerfile에 다음 환경 변수를 추가합니다.
# Install the Datadog Python SDK
RUN pip install ddtrace
# Set environment variables
ENV DD_APPSEC_ENABLED=true
ENV DD_APM_TRACING_ENABLED=false
ENV DD_SERVICE=<YOUR_SERVICE_NAME>
ENV DD_ENV=<YOUR_ENVIRONMENT>
# Use ddtrace-run to start your application
CMD ["ddtrace-run", "python", "app.py"]
3. 애플리케이션 실행
이미지를 빌드한 다음 컨테이너를 실행합니다.
컨테이너를 실행할 때 다음을 수행합니다.
- 컨테이너를 Datadog Agent와 동일한 Docker 네트워크에 연결합니다.
- 필수 환경 변수를 설정합니다.
docker run -d \
--name your-python-app \
your-python-app-image
4. Verify setup
To verify that App and API Protection is working correctly:
- Send some traffic to your application
- Check the Application Signals Explorer in Datadog
- Look for security signals and vulnerabilities
문제 해결
Python 애플리케이션에 App and API Protection을 설정하는 과정에서 문제가 발생할 경우, Python App and API Protection 문제 해결 가이드를 참조하세요.
추가 자료