Log Forwarding
When your website or application uses the Arvancloud CDN, Arvancloud sits as an intermediary between your visitors and the origin servers that host your web servers. Requests sent by your visitors first reach Arvancloud servers and are then sent to your origin servers if needed.
Visitor requests contain valuable information, some of which you can see in aggregated form in the Arvancloud panel. But these requests also hold other valuable information that may be useful to you as the owner of the website or domain, such as:
- Which path of your website was the request sent to?
- Which browser and operating system does the requester use?
- What is the requester's IP?
- What response did Arvancloud give to the request? (Hit/Miss)
By receiving this data, which we call logs, in real time, you can run countless analyses on visitor behavior and identify visitors with malicious behavior, for example:
- Identifying malicious bots
- Identifying unauthorized web crawlers
- Real-time analysis of web server behavior
- Real-time attack detection
Log Forwarding Feature
The log aggregation and processing system is a vital part of the Arvancloud CDN, to the extent that several parts of Arvancloud's services depend directly on this infrastructure service. Arvancloud CDN users can receive their request logs in near real time with a few simple settings in the panel. By creating a new log forwarder, you can send logs of HTTP requests, DNS requests, errors, domain events, and WAF events to log management services such as Arvancloud Cloud Logs, syslog, loggly, and kafka, as well as Arvancloud Object Storage and other S3-compatible storage services.
To enable this feature, log in to the panel, select your domain from the CDN menu, and go to Log Forwarding under the Monitoring and Reports menu.
Click New Log Forwarder.
Then select the type of log you want to receive.
You can use various parameters to filter the received logs precisely and effectively. This lets you specify the field and the operator you want (such as equal to, greater than, less than, etc.) and then enter the value to filter by.
In addition, you can use the logical operators AND and OR to combine multiple filters. With this feature, you can combine several conditions so that only logs matching all or some of them are sent. When a request matches the applied filters, the related log is sent; but if none of the filters match the data, no log is sent.
Note that the cost of log forwarding is calculated based on all logs, before filters are applied.
The following tables describe each parameter:
-
WAF Events
Description Field Cloud security product name Product Timestamp of log Timestamp Client real IP address Remote Address HTTP request host name Domain Cloud security raw log Data -
DNS Requests
Description Field Timestamp of DNS log Timestamp Unique ID of DNS request UUID DNS record of query Record DNS record type in request query Type Client real IP address IP Client real country name Country Client IP AS number AS Number Status code user received in response Response Status Code Process time of request Process Time -
HTTP Requests
Description Field HTTP request method (GET, POST, ...) Method HTTP request scheme (HTTP or HTTPS) Scheme HTTP request host header Domain Name HTTP request referrer header Referer Real IP address of visitor IP Address HTTP request user agent header User Agent Country of visitor's IP based on maxmind geoIP database Country AS number of visitor's IP AS Number Content type of HTTP request Content Type Response status code for HTTP request Response Status Code Server port that request was sent to Server Port Sum of bytes send to visitor Bytes Sent Byte received from upstream Bytes Received Time of read request from upstream Upstream Time Cache status of response (HIT, BYPASS, MISS, ...) Cache Status Unique identifier of HTTP request Request ID URI address in HTTP request URI Query string key-values in url Query String Fingerprinting algorithm used to identify SSL/TLS client applications based on their handshake characteristics JA3 Fingerprint -
Errors
Description Field IP of the client Client IP The protocol of the upstream Upstream Protocol The URI of the upstream Upstream URI The port of the upstream Upstream Port The IP of the upstream Upstream IP HTTP request host header Domain Name The version of the HTTP protocol HTTP Version HTTP request method (GET, POST, ...) Request Method URI Address in the HTTP request Request URI Real timestamp of the log Real Timestamp The error message Error Message The ID of the pop site Pop Site The ID of the request Request ID -
Event Logs
Domain event logs generally include information about the firewall, Cookie or JS challenges, rate limiting, WAF, DNS details, the ID of the applied page rule, image optimization and resizing, the source of the error page (InternalServerError, BadGateway, ServiceUnavailable, GatewayTimeout, firewall, rate limiting, etc.), JS and CSS acceleration settings, and edge computing.
Description Field HTTP Requset Host Header Domain Name JA3 Fingerprint hash is a fingerprinting alghorithm to identify SSL/TLS client applications based on their handshake characteristics JA3 Fingerprint The timestamp of the original request Timestamp HTTP Request method (GET,POST, …) Method HTTP Request Schema (HTTP or HTTPS) Scheme Visitor's true IP Address IP Address Country of visitor’s IP based on maxmind geoip database Country Response Status code for http request Response Status Code Upstream Server IP ServerIP Server port that sent to Server Port URI address in HTTP request URI Query String key-values in URI Query String Firewall Detailed Log (Action, BypassFeatures, RuleMatched, KnownBotDetected, HostnameAndTLSMismatch, GlobalAllowlistMatched, GlobalDenylistMatched, UserFirewallIsDisabled) Firewall Proxy Detailed Log (InvalidHost, CDNLoopBlocked, OperationalEndpointMatched, ReadBody, Redirect, SecureLinkVerified, PageRuleMatched, LoadConfigResult, ErrorPage, ErrorPageStatus) Proxy DNS Detailed Log (ResolverCacheFirstTimeUpdate , ResolverCacheBackgroundUpdate) DNS RateLimit Detailed Log (Enabled, UserRlimitIsDisabled, RunningCheckPhase, RunningUpdatePhase, IsNearThreshold, RateLimitRuleMatched, RateLimitAction) RateLimit DDoS Challenge Detailed Log (UserChallengeIsDisabled, IgnoreRuleMatched, ChallengeMode, Action, FinalChallengeDecision) DDoS Challenge WAF Detailed Log (WAFDeclined, WAFLog, WAFStatus, WAFRuleMatched) WAF
You can then mask or filter the logs to get the output you want.
Filtering Fields
With field filtering, you can choose which fields are included in your forwarded logs and which are removed. By default, all fields are selected for log forwarding, but you can easily remove the fields you don't need from the list.
For example, if you want to remove the "Country" field from your logs, simply deselect it in the list of selected fields, and from then on the "Country" field will no longer be sent in your logs.
Masking Logs
Data masking lets you mask sensitive information in logs using custom patterns (Regular Expressions, or RegEx). With this feature, you can replace any data that needs to be hidden with a value of your choice.
For example, if you want to hide cookie values in your logs, you can use the following RegEx pattern:
- The RegEx pattern is:
(cookie=)(.*)
- The replacement value is:
$1***
In this case, any value after cookie= is replaced with ***, and sensitive data is hidden this way.
As another example, if you want to receive the server_ip and uuid fields of the Event log in masked form, you can use a RegEx pattern that works on both fields at the same time. This way, you can hide sensitive data in your logs.
- Sample Event Log
{
"domain": "example.ir",
"uuid": "4f936b03-7856-4550-b75e-37f8adffd841",
"timestamp": 1741423411,
"iso_timestamp": "2025-03-08T08:43:31Z",
"method": "GET",
"scheme": "https",
"ip": "157.245.1.1",
"country": "IN",
"status": 429,
"server_ip": "185.143.1.1",
"server_port": 443,
"uri": "/about",
"query_string": "",
"tls_fingerprint": "",
"firewall": {
"action": "allow",
"rule_matched_id": "default"
},
"proxy": {
"error_page": "ratelimit",
"error_page_status": 429
},
"ddos": {
"final_challenge_decision": "ignore"
},
"ratelimit": {
"running_check_phase": true,
"rule_matched_id": "1c30bab5-3ab6-41b1-b643-52e5a6afabfc",
"action": "block"
}
}
- RegEx pattern to mask server_ip and uuid
("uuid":\s*")([a-f0-9\-]+)("|,"|})|("server_ip":\s*")(\d+\.\d+\.\d+\.\d+)
- The replacement value is:
$1***$3$4***
First part of the RegEx pattern: matching the uuid value
("uuid":\s*")([a-f0-9\-]+)("|,"|})
This part of the pattern matches the values of the uuid identifier. For example, it finds a string like the following in the log and masks its value:
"uuid": "4f936b03-7856-4550-b75e-37f8adffd841"
After replacement, the uuid value is shown as follows:
"uuid": "***"
Second part of the RegEx pattern: matching the server_ip value
("server_ip":\s*")(\d+\.\d+\.\d+\.\d+)
This part of the pattern matches the server IP in the server_ip field. For example, it finds the following string and masks the IP value:
"server_ip": "185.143.1.1"
After replacement, the server_ip value is also shown as follows:
"server_ip": "***"
Result after applying the mask
After applying this pattern and replacement value, the final log looks like this:
{
"domain": "example.ir",
"uuid": "***",
"timestamp": 1741423411,
"iso_timestamp": "2025-03-08T08:43:31Z",
"method": "GET",
"scheme": "https",
"ip": "157.245.1.1",
"country": "IN",
"status": 429,
"server_ip": "***",
"server_port": 443,
"uri": "/about",
"query_string": "",
"tls_fingerprint": "",
"firewall": {
"action": "allow",
"rule_matched_id": "default"
},
"proxy": {
"error_page": "ratelimit",
"error_page_status": 429
},
"ddos": {
"final_challenge_decision": "ignore"
},
"ratelimit": {
"running_check_phase": true,
"rule_matched_id": "1c30bab5-3ab6-41b1-b643-52e5a6afabfc",
"action": "block"
}
}
Choosing a Destination
In the next step, choose the destination where you want to receive your logs. In this example, we use Arvancloud Object Storage.
In this step, first enter a name for your log forwarding profile, then set the log forwarding interval and the sampling rate according to your needs.
- The sampling rate specifies how much of the logs is sent to you. For example, if the sampling rate for HTTP requests is set to 50 percent, only the logs of 500 out of every 1000 requests are sent to you.
In the settings section, enter the API access information for Arvancloud Object Storage, and finally the buffer value according to your needs.
- The buffer value specifies how many forwarded logs are stored for you in the Object Storage service. For example, suppose you set the buffer value to 100. If request number 101 is logged, the first request is removed and request 101 takes its place so the buffer size is kept, and in the end your log contains requests 2 to 101.
Finally, click Save.
Creating a Log Forwarder via API
- HTTP Requests with all parameters on Arvan S3
curl --location --request POST 'https://napi.arvancloud.ir/cdn/4.0/domains/example.com/log-forwarders' \ --header 'authority: napi.arvancloud.ir' \ --header 'accept: application/json, text/plain, */*' \ --header 'authorization: APIKEY 1 2 3 4' \ --header 'cache-control: no-cache' \ --header 'content-type: application/json;charset=UTF-8' \ --header 'pragma: no-cache' \ --data-raw '{"name":"API Log","description":"","type":"access","connection_type":"arvan_s3","data_format":{"method":true,"scheme":true,"domain":true,"referer":true,"ip":true,"ua":true,"country":true,"asn":true,"content_type":true,"status":true,"server_port":true,"bytes_sent":true,"bytes_received":true,"upstream_time":true,"cache":true,"request_id":true,"uri":true,"query_string":true},"settings":{"sample_rate":"100","s3_endpoint":"https://s3.ir-thr-at1.arvanstorage.ir","access_key":"Arvan_Access_KEY","secret_key":"Arvan_Secret_KEY","bucket_name":"exampleBucket","object_size":"100000","flush_interval":"60"},"status":true}'
- WAF Events with all parameters on Arvan S3
curl --location --request POST 'https://napi.arvancloud.ir/cdn/4.0/domains/example.com/log-forwarders' \ --header 'authority: napi.arvancloud.ir' \ --header 'accept: application/json, text/plain, */*' \ --header 'authorization: APIKEY 1 2 3 4' \ --header 'cache-control: no-cache' \ --header 'content-type: application/json;charset=UTF-8' \ --header 'dnt: 1' \ --header 'pragma: no-cache' \ --data-raw '{"name":"WAF Events Test","description":"","type":"waf","connection_type":"arvan_s3","data_format":{"product":true,"timestamp":true,"remote_address":true,"domain":true,"data":true},"settings":{"sample_rate":"100","s3_endpoint":"https://s3.ir-thr-at1.arvanstorage.ir","access_key":"Arvan_Access_KEY","secret_key":"Arvan_Secret_KEY","bucket_name":"arvanpro","object_size":"100000","flush_interval":"60"},"status":true}'
- DNS Requests with all parameters on Arvan S3
curl --location --request POST 'https://napi.arvancloud.ir/cdn/4.0/domains/example.com/log-forwarders' \ --header 'authority: napi.arvancloud.ir' \ --header 'accept: application/json, text/plain, */*' \ --header 'accept-language: fa' \ --header 'authorization: APIKEY 1 2 3 4' \ --header 'cache-control: no-cache' \ --header 'content-type: application/json;charset=UTF-8' \ --header 'dnt: 1' \ --header 'pragma: no-cache' \ --data-raw '{"name":"DNS Request Test","description":"","type":"dns","connection_type":"arvan_s3","data_format":{"timestamp":true,"uuid":true,"record":true,"type":true,"ip":true,"country":true,"asn":true,"response_code":true,"process_time":true},"settings":{"sample_rate":"100","s3_endpoint":"https://s3.ir-thr-at1.arvanstorage.ir ","access_key":"Arvan_Access_KEY","secret_key":"Arvan_Secret_KEY","bucket_name",object_size":"100000","flush_interval":"60"},"status":true}'
Origin Web Server Settings
To dynamically receive, transform, and transfer log data on your web server, you can use tools such as Logstash and Rsyslog. Also note that Arvancloud's log forwarding servers must be allowed to access your log servers and be whitelisted. To do so, simply whitelist the following IPs in your firewall:
94.101.182.128/28
94.101.190.224/28
Installing Logstash
This is the best-known log analysis platform in the world. With it, you can collect and process data from various sources. Depending on your operating system, there are different ways to install Logstash. In this article, we install it on Ubuntu 16.04 using the apt package manager.
Before installing, make sure Java 8 or 11 is installed.
To install Java, use the following command:
sudo apt-get update
sudo apt-get install default-jre
You need Elastic's signing key to verify the downloaded package (skip this step if you have already installed packages from Elastic):
wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key
add -
Now define the repository for the system:
echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" | sudo
tee -a /etc/apt/sources.list.d/elastic-7.x.list
At this step, update the repository and install Logstash:
sudo apt-get update
sudo apt-get install logstash
Configuring Logstash
Your configuration generally has three parts: inputs, filters, and outputs. The Logstash configuration structure is as follows:
#/etc/logstash/conf.d/
- apache.conf
- haproxy.conf
- syslog.conf
You can have a separate configuration file for each part. Each of these files contains the required inputs, filters, and outputs:
input {
tcp {
port => 5140
codec => json
}
}
filter {
grok {
match => { "message" => "%{TIMESTAMP_ISO8601:timestamp} %{GREEDYDATA:Junk}: %{GREEDYDATA:request}"}
}
json { source => "request" }
}
output {
stdout { codec => rubydebug }
elasticsearch {
hosts => ["localhost:9200"]
manage_template => false
index => "logs-%{[@metadata][beat]}-%{[@metadata][version]}-%{+YYYY.MM.dd}"
}
}
Forwarding Logs to Loggly
The Arvancloud CDN lets you send your domain's log output to third-party tools such as Loggly.