Access logs
You can deliver the access logs of EPG instances to Simple Log Service (SLS) and query and analyze the logs in the EPG console to trace the source, destination, egress IP address, and rule action of each outbound request. This helps you quickly locate access exceptions and meet security audit and compliance requirements.
Prerequisites
You have created an EPG instance.
You have activated Simple Log Service (SLS).
Enable access logs
Log on to the EPG console. In the left-side navigation pane, choose Instance Management > Instance List, and then click the ID of the target instance.
On the instance details page, click the Log Configuration tab, and then click Create Access Log. Select a Project in the same region as the instance and one of its Logstore, and then click Confirm.
If no Project or Logstore is available, select the create option in the drop-down list.
When you enable access logs, the system automatically creates the service-linked role AliyunServiceRoleForSLSAudit.
Access logs contain sensitive information, such as client IP addresses and destination domain names. Configure appropriate access permissions and a retention period for the logs in SLS.
In the Use Existing Logstore dialog box, confirm the impacts and click Confirm.
View access logs
Log on to the EPG console. In the left-side navigation pane, choose Instance Management > Instance List, click the ID of the target instance to go to the instance details page, and then click the Log Configuration tab.
On the Log Configuration tab, select Global Overview, Outbound Logs, or Log Details as needed, specify filter conditions, and then query the related metrics.
Category
Description
Global Overview
An overview of outbound traffic. Statistics are collected from all delivered logs and help you quickly check the number of outbound requests, request success rate, blocks, and latency.
Provides metric cards such as the number of outbound requests, request success rate, number of 4xx requests, number of 5xx requests, number of access control interceptions, number of Cloud Firewall blocks, average request time, and number of exception marker requests, as well as charts such as the outbound request trend, status code composition, interception phase distribution, top target domain, abnormal marker distribution, and time consumption index.
Outbound Logs
Focuses on requests that have completed egress scheduling. Provides metrics such as the number of egress requests, the number of requests that did not enter egress, the number of egress IP addresses in use, and the number of egress address pools in use, as well as charts such as the egress address pool distribution, top egress IP addresses, and status code composition by egress dimension.
Log Details
Integrates with SLS Logstore. Provides a query editor, a field sidebar, and a detail table. Supports request queries, SQL, and SPL to search all delivered fields one by one and view the details of each request.
Disable access logs
After you disable access logs, EPG stops delivering new access logs to SLS. Existing logs are retained based on the retention period configured for the Logstore.
Log on to the EPG console. In the left-side navigation pane, choose Instance Management > Instance List, and then click the ID of the target instance.
Click the Log Configuration tab. In the Basic Information section, click Disable Log Configuration and then Confirm.
Log fields
Access logs record the information that EPG actually obtains while processing requests. If a stage in the request pipeline does not occur, such as no TLS handshake is performed, no request content is parsed, the request does not enter egress scheduling, the request is not inspected by Cloud Firewall, or the request is not proxied to the destination service, the fields related to that stage are empty. Scenarios that cause empty fields include but are not limited to the following:
The request is an HTTP request: HTTP requests do not go through a TLS handshake. The TLS negotiation-related fields are empty.
The request is an HTTPS request but TLS interception is not enabled for EPG: In this case, EPG only passes through the traffic, does not perform TLS handshakes or parse request content, and Cloud Firewall does not inspect the request. The related fields are empty.
The request is blocked by an access control rule or by Cloud Firewall: The request does not enter egress scheduling and is not proxied to the destination service. Fields such as the egress IP address, destination service, and latency are empty.
Field | Description |
Instance and topic | |
epg_id | The ID of the EPG instance. |
__topic__ | The log topic. The value is fixed to |
Time information | |
start_time | The time when the request started. The time is in the |
Connection information | |
client_ip | The IP address of the client that initiates the outbound request. |
client_port | The source port that the client uses to initiate the outbound request. |
vip | The virtual IP address (VIP) of the EPG instance. |
vport | The listener port of the EPG instance that receives the request. |
upstream_ip | The IP address of the destination service. |
upstream_port | The port of the destination service. |
upstream_egress_ip | The egress IP address, which is the source IP address actually used to access the destination service after egress scheduling. |
upstream_egress_port | The egress port. |
upstream_egress_pool_id | The ID of the egress address pool that matches the request. |
Protocol information | |
downstream_tls_version | After TLS interception is enabled, the TLS protocol version negotiated in the TLS handshake between the client and EPG, in which EPG presents a dynamically issued certificate. Example: |
downstream_tls_cipher | After TLS interception is enabled, the cipher suite negotiated in the TLS handshake between the client and EPG, in which EPG presents a dynamically issued certificate. Example: |
upstream_tls_version | After TLS interception is enabled, the TLS protocol version used by the TLS connection that EPG establishes with the destination service. Example: |
upstream_tls_cipher | After TLS interception is enabled, the cipher suite used by the TLS connection that EPG establishes with the destination service. Example: |
scheme | The protocol of the request: HTTP or HTTPS. |
downstream_http_protocol | The HTTP protocol version between the client and EPG. |
upstream_http_protocol | The HTTP protocol version between EPG and the destination service. |
Request and response content | |
request_method | The request method. Example: |
request_uri | The URI of the request. |
request_user_agent | The content of the |
upstream_hostname | The destination domain name and port. If no DNS domain name exists, the value is the |
status | The response status code. |
Latency information | |
request_time | The total duration of the request. Unit: milliseconds. |
upstream_connect_time | The time required for EPG to establish a TCP connection with the destination service. Unit: microseconds. |
upstream_response_time | The time from when EPG starts sending data to the destination service until it receives the complete response. Unit: microseconds. |
Troubleshooting | |
response_flags | The response flags, which contain additional details about the response or connection. |
status_details | The details of the response status code, such as |
Cloud Firewall | |
cfw_action | The inspection result of Cloud Firewall. |
cfw_rt | The request latency of Cloud Firewall. Unit: milliseconds. |
cfw_request_id | The request ID that can be used to query the corresponding request in Cloud Firewall proxy logs. |
Access control | |
final_rule_action | The action (allow or deny) of the last matched rule. |
final_rule_id | The ID of the last matched rule. |
all_matches | The details of all rules that match the request, encoded in JSON format. The
|
Query examples
On the Log Details tab, or go to the Logstore that corresponds to the EPG instance in the Simple Log Service console. Then, you can use the following methods to filter and analyze logs.
Before you query logs by using the field:value syntax, make sure that the indexes are enabled for the target fields.Filter by destination domain name: enter
upstream_hostname:api.example.comto display only the outbound requests to this domain name.Filter by blocking result: enter
final_rule_action:denyto query the requests denied by access control rules. Combine the query withfinal_rule_idto locate the specific rule.Filter by status code: enter
status:403to query the requests that return the specified status code, or enterstatus:5*to match all5xxresponses.Filter by client IP address: enter
client_ip:172.16.20.8to query the outbound requests initiated by a specific client IP address.Filter by egress IP address: enter
upstream_egress_ip:139.196.x.xorupstream_egress_pool_id:eppool-xxxto check the egress IP address and egress address pool used by requests.Combine multiple conditions: use
andto connect multiple conditions. Example:client_ip:172.16.20.8 and final_rule_action:denyqueries the blocked requests initiated by the specified client IP address.Statistical analysis: use SQL statements to perform aggregate analysis on indexed fields. Example:
* | SELECT upstream_hostname, COUNT(*) AS pv GROUP BY upstream_hostname ORDER BY pv DESC LIMIT 10sorts the destination domain names by the number of requests.
Billing
Enabling access logs does not incur fees on the EPG side. After access logs are delivered to SLS, you are charged by SLS. For more information, see billing.
FAQ
Can I view log data generated before access logs were enabled?
No. EPG does not collect access logs before they are enabled. Therefore, historical data cannot be viewed.
A request is denied. How do I check which rule the request matches and at which phase the request is blocked?
Check
final_rule_action(allow or deny) andfinal_rule_idto identify the rule that takes effect for the request.Check the
all_matchesfield to view the details of all rules that match the request. Thehookfield indicates the phase in which each rule takes effect.