Capture Request Body
Overview
The Capture Request Body feature allows to store the request body of an HTTP transaction, making it a useful tool for debugging and troubleshooting.
The request body usually contains confidential information like credit card numbers and passwords. Therefore, if your service deals with such sensitive data, enable this feature with caution.
Supported Platforms
AWS Lambda | Docker | ECS | Instance | Kubernetes
The following configurations are applicable to all platforms.
Supported Frameworks
Django
Enable Capture Request Body
Do the following steps in Settings.py
to enable the Capture Request Body feature.
- Add the following key-value pair within the
ELASTIC_APM
block ofSettings.py
file.
'CAPTURE_BODY': 'all'
- Add the below line within the
try
block ofSettings.py
file.
SFTRACE_CONFIG['SFTRACE_GLOBAL_LABELS'] += ',_tag_redact_body=true'
By default, the value is 'true'.
Customize Document Type and Index
To customize the Document Type and Index, perform the following steps within the try
block of the Settings.py
file. (Optional)
- Add the below line within the
try
block in theSettings.py
file to customize the Index.
SFTRACE_CONFIG['SFTRACE_GLOBAL_LABELS'] += ',_tag_IndexType=log'
The Index Type is set to Log
by default, and the possible values that can be used for this field are Logs and Metrics.
- Add the below line within the
try
block in theSettings.py
file to customize the Document Type.
SFTRACE_CONFIG['SFTRACE_GLOBAL_LABELS'] += ',_tag_documentType=user-input'
By default, the Document Type is set to user-input
.
Complete Configuration
try:
SFTRACE_CONFIG['SFTRACE_GLOBAL_LABELS'] += ',_tag_redact_body=true'
SFTRACE_CONFIG['SFTRACE_GLOBAL_LABELS'] += ',_tag_IndexType=log'
SFTRACE_CONFIG['SFTRACE_GLOBAL_LABELS'] += ',_tag_documentType=user-input'
ELASTIC_APM={
'CAPTURE_BODY': 'all'
}
except Exception as error:
print("Error while fetching snappyflow tracing configurations", error)
View the Captured Request Body
Follow the below steps to verify and view the trace data.
Go to the Application tab in SnappyFlow and navigate to your Project > Application > Dashboard.
In the Dashboard window, go to the Log Management section.
Select the Source and Log Type to view logs in the dashboard.
To see the unprocessed data, go to the Browse Data section and select the following details:
- Index:
Metrics
- Plugin:
trace_body
- Document Type:
user_input
- Index:
FLASK
Enable Capture Request Body
Do the following steps in app.py
file to enable the Capture Request Body feature.
- Add the following key-value pair within the
app.config['ELASTIC_APM']
block of theapp.py
file.
'CAPTURE_BODY': 'all'
- Add the below line within the
try
block of theapp.py
file.
SFTRACE_CONFIG['SFTRACE_GLOBAL_LABELS'] += ',_tag_redact_body=true'
By default, the value is 'true'.
Customize Document Type and Index
To customize the Document Type and Index, perform the following steps within the try
block of the app.py
file. (Optional)
- Add the below line within the
try
block of theapp.py
file to customize the Index.
SFTRACE_CONFIG['SFTRACE_GLOBAL_LABELS'] += ',_tag_IndexType=log'
The Index Type is set to Log
by default, and the possible values that can be used for this field are Logs and Metrics.
- Add the below line within the
try
block of theapp.py
file to customize the Document Type.
SFTRACE_CONFIG['SFTRACE_GLOBAL_LABELS'] += ',_tag_documentType=user-input'
By default, the Document Type is set to user-input
.
Complete Configuration
SFTRACE_CONFIG['SFTRACE_GLOBAL_LABELS'] += ',_tag_redact_body=true'
SFTRACE_CONFIG['SFTRACE_GLOBAL_LABELS'] += ',_tag_IndexType=log'
SFTRACE_CONFIG['SFTRACE_GLOBAL_LABELS'] += ',_tag_documentType=user-input'
app.config['ELASTIC_APM'] = {
'CAPTURE_BODY': 'all'
}
View the Captured Request Body
Follow the below steps to verify and view the trace data.
Go to the Application tab in SnappyFlow and navigate to your Project > Application > Dashboard.
In the Dashboard window, go to the Log Management section.
Select the Source and Log Type to view logs in the dashboard.
To see the unprocessed data, go to the Browse Data section and select the following details:
- Index:
Metrics
- Plugin:
trace_body
- Document Type:
user_input
- Index: