Log Delivery Service (LDS) collects log data from CDN services and delivers it to your destination. This data can be used for traffic analysis, event monitoring, performance tuning, troubleshooting, and more.
At present, LDS captures logs from the following CDN services:
- Content Delivery (HTTP): Provides detailed insights into the content delivery via the CDN.
- MMD Live Ingest (MMD_LIVE_INGEST): Captures information about the transcoding of ingested media streams into various bitrates and formats for further playback.
LDS Workflow
- You start by setting up your Log Delivery Service (LDS) configuration using either the LDS UI or LDS API. This configuration determines what logs data is collected, how it is processed, and delivered.
- LDS picks up configuration and begins processing based on new settings.
- As users interact with your CDN services, their requests are logged.
- LDS collects and processes these logs from the CDN, extracting and organizing the data based on the configuration you set. This step involves parsing the logs and preparing them for delivery.
- After processing, LDS delivers the logs to the specified destination, which could be cloud storage, a custom HTTP endpoint, or another location of your choice.
- Once delivered, the logs are ready for you to analyze.
View and Manage LDS Configurations
The Log Delivery Service page under the Configure menu displays a list of configurations for the selected account, allowing users to view and manage them. It provides the following details about each configuration:
- NAME: The name you provided for the configuration.
- SHORTNAME: The account name for which the LDS configuration collects log data.
- SERVICE TYPE: CDN service from which the logs are collected by the LDS configuration.
- DESTINATION: The target storage system where the LDS configuration sends the collected logs.
- DATA COMPRESSION: Indicates the algorithm used to compress log data.
- STATE: Shows the current state of the configuration.
- Active: The configuration is active and processing log data.
- Suspended: The configuration is paused and not processing log data.
- LAST UPDATED: Shows the date and time when the LDS configuration was last modified.
- STATUS: Includes controls to activate or deactivate the configuration, as well as to delete it.
Create an LDS Configuration
- Navigate to Configure > Log Delivery Service and click the ”+” button.
- Enter a NAME for the configuration.
- Select a SHORTNAME that you want the LDS to collect logs for.
- From the list of available services, select the CDN SERVICE from which you want LDS to collect log data. The supported services include:
- Content Delivery (HTTP)
- MMD Live Ingest (MMD_LIVE_INGEST)
- In Available Log Fields, select the fields to collect, move them to Selected Log Fields by dragging or double-clicking. Arrange the fields in the desired order. For details on the available fields for each service, refer to the following links:
- Optionally, can rename selected fields by assigning aliases. To do this, click the square brackets next to the field name, and enter the alias. For details refer to Field Aliases.
- Additionally, you can add static fields by clicking the Add Static Field button. This opens a popup where you can enter a field name and a static value. For details refer to Static Fields.
- In the DESTINATION dropdown, select the storage type where you want the logs to be delivered.
Each account can have only one LDS configuration per destination. For additional configurations to the same destination, please contact your account manager.
- Enter the details for your chosen destination.
- For Amazon S3 see Configure logs delivery to Amazon S3
- For Custom HTTPS endpoint see Configure logs delivery to Custom HTTPS endpoint
- For Datadog see Configure logs delivery to Datadog (Streaming)
- For Origin Storage see Configure logs delivery to Edgio Origin Storage
- For Google Cloud Storage see Configure logs delivery to Google Cloud Storage
- For Hydrolix see Configure logs delivery to Hydrolix (Streaming)
- For Microsoft Azure Blob Storage see Configure logs delivery to Microsoft Azure Blob Storage
- For New Relic see Configure logs delivery to New Relic (Streaming)
- For Splunk see Configure logs delivery to Splunk (Streaming)
- For Sumo Logic see Configure logs delivery to Sumo Logic (Streaming)
- In the Delivery Options section, customize the log data format and compression, and set file naming and storage paths.
- Use DIRECTORY LAYOUT dropdown to choose the folder path within the destination. Available for file-based destinations (Amazon S3, Azure Blob Storage, Edgio Origin Storage and Google Cloud Storage). For further details refer to Changing Log Data Location.
- The FILENAME TEMPLATE dropdown determines the naming convention for log files uploaded to your destination storage. The filename template is fixed and cannot be edited through the UI. Available for file-based destinations (Amazon S3, Azure Blob Storage, Edgio Origin Storage and Google Cloud Storage). For details refer, see Changing Log Data Location.
- In the DATA FORMAT dropdown, you can select the format for the uploaded log data. Available formats may vary depending on the selected destination type. See Log Data Formats.
- In the DATA COMPRESSION dropdown, select the compression format for the log data. The available options may vary based on the selected destination type. Refer to Log Data Compression for more information.
- In the Data Sampling section, configure the volume of delivered log data. For more information, see Data Sampling.
- Click Save to apply your updates.
It can take 15 to 40 minutes for changes to take effect.
Edit an LDS Configuration
- Go to Configure > Log Delivery Service page.
- Find the configuration you want to edit, and click on it to open the configuration in edit mode.
- Update the following settings as needed:
- Name: Modify the name of the configuration for easier identification.
- Available Log Fields: Change the fields to be collected by dragging them between the Available and Selected sections, or add static fields using the Add Static Field button. Additionally, you can assign aliases to selected fields by clicking the square brackets next to the field name and entering an alias in the input box that appears. For details refer to Static Fields and Field Aliases
- In the Delivery Destination section, modify the destination details for log delivery as necessary.
- For Amazon S3 see Configure logs delivery to Amazon S3
- For Custom HTTPS endpoint see Configure logs delivery to Custom HTTPS endpoint
- For Datadog see Configure logs delivery to Datadog (Streaming)
- For Origin Storage see Configure logs delivery to Edgio Origin Storage
- For Google Cloud Storage see Configure logs delivery to Google Cloud Storage
- For Hydrolix see Configure logs delivery to Hydrolix (Streaming)
- For Microsoft Azure Blob Storage see Configure logs delivery to Microsoft Azure Blob Storage
- For New Relic see Configure logs delivery to New Relic (Streaming)
- For Splunk see Configure logs delivery to Splunk (Streaming)
- For Sumo Logic see Configure logs delivery to Sumo Logic (Streaming)
- Under the Delivery Options section:
- Use DIRECTORY LAYOUT dropdown to configure the folder structure within the destination for file-based storage (Amazon S3, Azure Blob Storage, Edgio Origin Storage and Google Cloud Storage). For more information, see Changing Log Data Location.
- In the DATA FORMAT dropdown choose the format for the log data. The available options may depend on your selected destination. Refer to Log Data Formats for more information.
- In the DATA COMPRESSION dropdown select the compression method for the log data. The available choices vary by destination type. See Log Data Compression for details.
- In the Data Sampling section, adjust the volume of log data being delivered. For more information, see Data Sampling.
- Click Save to apply your updates.
It can take 15 to 40 minutes for changes to take effect.
Activate or Deactivate LDS Configuration
You can activate or deactivate a configuration from two locations:
- Configuration Grid: On the Configure > Log Delivery Service page, check the Status column:
- The icon means the configuration is active. Clicking it will deactivate the configuration.
- The icon means the configuration is inactive. Clicking it will activate the configuration.
- While Editing the Configuration: When editing a configuration, use the button at the bottom to activate or deactivate it.
It may take 5 to 10 minutes for changes to activation status to take effect.
Log Fields
When configuring LDS, you must select the log fields to be collected and delivered. Each service provides a different set of log fields.
Content Delivery Log Fields
LDS currently supports only log fields related to egress traffic. Midgress or ingress information is not available at this time.
Date/Time-Related Metrics
Field | Details | Sample Data |
---|---|---|
date | (string) The request end time (date part) in yyyy-MM-dd format (UTC time zone). | 2017-10-01 |
datetime | (string) The request end time in yyyyMMddHHmmss format (UTC time zone). | 20210324151931 |
time | (string) The request end time (time part) in HH:mm:ss.SSS format (UTC time zone). | 22:27:41.123 |
timestamp | (int64) The request end time in milliseconds since the epoch | 1727095993023 |
timestamp-sec | (double) The request end time since the epoch, formatted as {seconds}.{milliseconds} | 1727095993.023 |
Client-Server Communication Metrics
Field | Details | Sample Data |
---|---|---|
cs-accept-language | (string) The value of the Accept-Language request header. | fr-MH;q=1.0 |
cs-cmcd | (string) The CMCD metric sent by a compatible chunk streaming media player as specified by CTA-5004 saved in query term URL-encoded format, regardless of methods used to ingest by player. | bl%3D11700%2Cbr%3D1254 |
cs-cookie | (string) The URL-encoded Cookie HTTP request header. GDPR Personally Identifiable information is included. | InfoSG=2080446124.14348.0000 |
cs-custom-header1 | (string) The value of the request header specified in the log_request_header rewrite option. You can include the value of up to five custom headers as defined as log_request_header* fields in Caching and Delivery. | sample-header-value |
cs-custom-header2 | (string) The value of the request header specified in the log_request_header2 rewrite option. You can include the value of up to five custom headers as defined as log_request_header* fields in Caching and Delivery. | sample-header-value |
cs-custom-header3 | (string) The value of the request header specified in the log_request_header3 rewrite option. You can include the value of up to five custom headers as defined as log_request_header* fields in Caching and Delivery. | sample-header-value |
cs-custom-header4 | (string) The value of the request header specified in the log_request_header4 rewrite option. You can include the value of up to five custom headers as defined as log_request_header* fields in Caching and Delivery. | sample-header-value |
cs-custom-header5 | (string) The value of the request header specified in the log_request_header5 rewrite option. You can include the value of up to five custom headers as defined as log_request_header* fields in Caching and Delivery. | sample-header-value |
cs-headers | (string) The value of the HTTP request headers specified in the log_req_header rewrite option. These headers are logged as key-value pairs in this field. If multiple headers are specified to be logged, each key-value pair is separated by a comma. The maximum size of this field is 2048 bytes. If the maximum size is exceeded, error=toolarge is logged. | hdr1=val_1,hdr2=val%20_2 |
cs-http-proto | (string) The version of the HTTP protocol sent from the client to the server. | HTTP/2.0 |
cs-method | (string) The HTTP request method (GET, POST, and so on) sent from the client to the server | GET |
cs-range | (string) The value of the Range header sent from the client to the server. URL-encoded. | bytes=2015-2642 |
cs-referer | (string) The value of the Referrer header sent from the client to the server. URL-encoded. | https://site.com/page |
cs-ssl-cipher | (string) The version that the client supports, sent from the client to the server. | AES256-SHA |
cs-ssl-proto | (string) The version that the client supports, sent from the client to the server. | TLSv1.2 |
cs-uri | (string) The URL-encoded published URL that includes query strings. Includes GDPR Personally identifiable information. | http://dtvcdn11.dtvcdn.com/B003109030M3.ats?cid=003261089464&ct=1588467344 |
cs-uri-host | (string) The domain part of the published URL. | dtvcdn11.dtvcdn.com |
cs-uri-noquery | (string) The URL-encoded published URL (query part excluded). | http://dtvcdn11.dtvcdn.com/B003109030M3.ats |
cs-uri-path | (string) The URL path from the published URL, excluding the query string, starting after the hostname. | B003109030M3.ats |
cs-uri-query | (string) The portion of the published URL that contains the query parameters, reported without the leading question mark | cid=003261089464&ct=1588467344 |
cs-uri-scheme | (string) The published URL scheme. Valid values: http, https . | http |
cs-user-agent | (string) The value of the User-Agent header in the request from the client to the server. URL-encoded. | Microsoft%20BITS/7.5%20 |
Server-Client Communication-Related Metrics
Field | Details | Sample Data |
---|---|---|
sc-bytes | (int64) The number of response bytes, modified to include the packet and retransmit overhead. | 52431246 |
sc-content-length | (int64) The value of the Content-Length header in the response from the server to the client. | 4881818612 |
sc-content-type | (string) The value of the Content-Type header in the response from the server to the client. | application/octetstream, video/x-m4v |
sc-headers | (string) The value of HTTP response headers specified in the log_resp_header rewrite option.These headers are logged as key-value pairs in this field. If multiple headers are specified to be logged, each key-value pair is separated by a comma. The maximum size of this field is 2048 bytes. If the maximum size is exceeded, error=toolarge is logged. | hdr1=val_1,hdr2=val%20_2U |
sc-request-id | (string) The unique ID that identifies a request (generated by the server and sent to the client in the X-LLNW-Dbg-Request-Id response debug header) | 49ae542085bb 1d5b0c62a9b3 0c25cb7d |
sc-response-write-time-sec | (double) The time taken by the edge server to write the response formatted as {seconds}.{milliseconds} | 0.023 |
sc-rexb | (int64) The number of bytes retransmitted in the response from the server to the client. | 45645 |
sc-rtt | (int64) The client socket smoothed round-trip time in microseconds. | 11812 |
sc-rttv | (int64) The client socket smoothed round-trip time variance in microseconds. | 250000 |
sc-status | (string) The HTTP status code in the response from the server to the client. In addition to standard Content Delivery status codes, the sc-status field may contain non-standard status codes: 000 A Edgio-specific status code returned when the origin sends no response, so there is no status code to log (for example when the client disconnects before the origin delivers the response). 600 A Edgio-specific status code indicating the origin returned a non-HTTP-compliant response so a status code could not be obtained. For a list of standard status codes, see Response Codes in the Content Delivery User Guide | 200, 206, 400 |
sc-status-code | (int32) The HTTP response status code, provided as an integer. | 200 |
sc-status-msg | (string) The response HTTP status message generated by the edge server | OK |
duration | (int32) The request duration in milliseconds. | 29298749 |
duration-sec | (int32) The request duration formatted as {seconds}.{milliseconds} | 29298.749 |
Client-Related Metrics
Field | Details | Sample Data |
---|---|---|
c-as-org | (string) The organization associated with the client’s ASN | compaia de circuitos cerrados s.a. |
c-asn | (int64) The autonomous system number calculated based on client IP address. | 22822 |
c-city | (string) The City name derived from the client IP address using the IPGeo DB. | phoenix |
c-continent-code | (string) Two-letter uppercase continent code derived from the client’s IP address | SA |
c-country | (string) The Country name derived from the client IP address using the IPGeo DB. | united states |
c-country-code | (string) The two-letter ISO 3166-1 alpha-2 country code derived from client IP address. | UK |
c-geo-latitude | (double) The approximate latitude associated with the client’s IP address | -26.81 |
c-geo-longitude | (double) The approximate longitude associated with the client’s IP address | -65.22 |
c-ip | (string) The Client IP Address (end-user). | 66.249.69.88, 2001:0db8: 85a3:0000:0000:8a2e:0370: 7334 |
c-ip-ver | (string) The client’s IP version number. Valid values: INET (IPv4), INET6 (IPv6). | INET |
c-port | (string) The client remote port number used for a connection. | 80832 |
c-state | (string) The State name derived from the client IP address using the IPGeo DB. | arizona |
Server-Related Metrics
Field | Details | Sample Data |
---|---|---|
s-cache-code | (string) The cache status code for the request, showing how it was processed by the CDN in terms of caching | TCP_HIT |
s-dest-addr | (string) The IP address that the end user connects to. It is most often a virtual IP associated with a request router. In rare cases, when alternative request routing is configured, this IP address corresponds directly to a caching server. | 69.164.9.82 |
s-host | (string) The hostname of the server that received the request. | cds103.man.llnw.net |
s-ip | (string) The IP address of the edge-most server that received the request. | 69.164.9.82 |
s-pop | (string) The Edgio PoP name of the server that received the request. | mia |
s-port | (int32) The port number on the edge server receiving the client request. Valid values: 80, 443 | 443 |
s-ttfb | (int32) The number of milliseconds between the CDN receiving the end-user request and writing the first byte of the response, as measured on the server. A value of 0 (zero) means the time was less than 1ms. | 56 |
s-ttfb-sec | (double) The time between the CDN receiving the request and writing the first byte of the response, formatted as {seconds}.{milliseconds} | 0.056 |
Server-Origin Communication-Related Metrics
Field | Details | Sample Data |
---|---|---|
so-src-uri | (string) The URL-encoded source/origin URL that the published URL has been mapped to (query part excluded). | http://cmdist.dtvce.com/content/B003109030M3.ats?cid=003261089464&ct=1588467344 |
so-src-uri-noquery | (string) The URL-encoded source/ origin URL that the published URL has been mapped to (query part excluded). | http://cmdist.dtvce.com/content/B003109030M3.ats |
so-src-uri-path | (string) The URL path from the source/origin URL, excluding the query string, starting after the hostname | /geo-health.txt |
Origin-Related Metrics
Field | Details | Sample Data |
---|---|---|
o-ip | (string) The IP address of the origin server that supplied the first byte of the response. Enable via the log_origin_ip_address option. | 69.164.9.82 |
Application (Edgio)-Specific Metrics
Field | Details | Sample Data |
---|---|---|
x-account | (string) The account number is represented as a string | 23 |
x-first-node-cached | (int32) Integer value indicating whether a cache hit occurred on the server that received the request Possible values: 0 - a cache miss occurred 1 - a cache hit occurred Customers can use the field to calculate cache efficiency in terms of requests. This field reflects a hit or miss on only the first cache node involved. It does not reflect cache hits and misses for the entire CDN. | 0 |
x-log-key-value | (string) The string representation of the key value pairs configured via the log_keyval rewrite option, the Arc Light llnw.log_keyval() builtin , and the log_keyval_header global option. This column is limited to 1024 bytes. configures the EdgePrism key-value pairs on behalf of customers. Please contact your Accouont Manager if you are interested in this feature. | dscp=34, partner=eg, proto=ssl, arclight=arc2, policyid=724 |
MMD Live Ingest Log Fields
The following fields are available for you to include when you select MMD_LIVE_INGEST as the SERVICE TYPE.
Field | Details | Sample Data |
---|---|---|
audio-bytes | (int64) The number of ingested audio bytes. | 15833 |
egress-bytes | (int64) The number of total possible egress bytes for all output formats. | 17307 |
end-time-ms | (int64) The request end time (in milliseconds). | 1726020001361 |
frames | (int32) The number of transcoded frames. | 1 |
ingest-bytes | (int64) The number of ingested bytes. If is-transcode == 0 then total-bytes else 0. | 4605662 |
is-transcode | (int32) Indicates whether or not the stream is transcoded (1 - transcoding, 0 - transmuxing). | 1 |
num-output-formats | (int32) The number of output formats configured for the stream. | 2 |
slot-name | (string) The base name of the stream. | af993324aa9644789f4b97a9b68622b2 |
slot-profile | (string) The name of the stream profile. | 4000 |
start-time-ms | (int64) The request start time (in milliseconds). | 1726020001361 |
total-bytes | (int64) The total number of ingested bytes. | 245135 |
transcode-bytes | (int64) The number of transcoded bytes. | 4497211 |
transcode-pixels | *(int64)*The number of transcoded pixels. | 69580800 |
Static Fields
Static fields allow you to add a constant string value to every log line provided by LDS, which is useful for metadata or fixed identifiers. Static fields can be managed on the
Create/Update LDS Configuration
page.Create Static Field
- Click ADD STATIC FIELD below the Available Log Fields section in your configuration.
- Enter a field name (up to 50 characters, starting with a letter, using lowercase Latin letters, digits,
_
, or-
) and a value (up to 1024 characters). - After entering the field name and value, click the ADD STATIC FIELD button to create the field. The field will then appear in the Available Log Fields section.
- Static fields are shared across all LDS configurations for the same account and service type. For example, a static field created in an HTTP service configuration for the
test
account will be available in all other configurations for that service and account. - You can create up to 10 static fields per account and service type.
- You can add the static field to the Selected Log Fields by dragging it or double-clicking it.
Edit Static Field
- To change the value of a static field, click on its name in either the Available Log Fields or Selected Log Fields section. A popup will appear allowing you to modify the field value. The field name is fixed and can only be specified during creation.
Delete Static Field
- To delete a static field, first ensure it is removed from the Selected Log Fields section, as deletion is not permitted while it is in use in any LDS configuration. Click on the field name in the Available Log Fields section. A popup will appear with a Delete button for confirmation.
Field Aliases
Field aliases allow you to assign alternative names to log fields. Aliases can be managed on the
Create/Update LDS Configuration
page.Assigning an Alias to Log Field
- To assign an alias, click the square brackets next to the field name in the Selected Log Fields section. An input box will appear where you can enter the alias.
- Once done, press Enter or click outside the box to save. The alias will then display alongside the original log field name.
Edit Alias
- Click on the alias, modify the name, and press Enter or click outside the input box to save.
Delete Alias
- To delete an alias, click the alias, clear the name, and press Enter or click outside the input box to save.
Configure Destinations
LDS supports delivery to the following destinations: Amazon S3, Custom HTTPS endpoint, Datadog, Edgio Origin Storage, Google Cloud Storage, Hydrolix and Microsoft Azure Blob Storage.
Delivery to Amazon S3
Prerequisites
- Create an
S3 Identity and Access Management (IAM) user
in Amazon’s configuration screens. - Give the
IAM user
the following permissions for the bucket where you want to store logs:ListBucket
GetObject
PutObject
Configuration
- On the
Create/Update LDS Configuration
page in the Delivery Destination section, choose Amazon S3 from the dropdown. - Enter your bucket name in the BUCKET NAME field.
- Select the AWS region where the bucket is located from the REGION dropdown.
- Optionally, specify a path within the bucket for storing files in the PATH field.
Do not add a leading slash to the path. If you do, Amazon creates an object URL with a double slash. Example:
https:://bucket.s3.region.amazonaws.com//cdn_logs...
- In the ACCESS KEY field, enter the access key for your Amazon S3 bucket.
- In the SECRET KEY field, enter the secret key for your Amazon S3 bucket.
- Optionally, in the Delivery Options section:
- Change the DIRECTORY LAYOUT to customize how logs are organized within a bucket. For details, refer to Log Files Naming and Location.
- Choose the DATA COMPRESSION method for your log files. Supported options include: LZ4 (default), GZIP, LZF, SNAPPY, ZSTD.
- Select the log DATA FORMAT:: W3C (Tab-Separated)(default), TSV, JSON Lines, JSON Array, JSON.
- If you need fields with
null
values to be included in JSON format files, select the INCLUDE NULL VALUES IN JSON option, as they are excluded by default.
- Optionally, in the Data Sampling section, reduce the volume of delivered logs by applying sampling rules. Refer to the Data Sampling for additional details.
- Click Save to validate the connection to the destination and apply your settings.
During the validation process, LDS creates a test file in the specified S3 bucket using the provided credentials and settings. The file is named
_edgio_validation/validation_{timestamp}.txt
. The file will only appear if the validation is successful. Since these files are no longer necessary after validation, you can delete them as needed.Delivery to Custom HTTPS endpoint (Streaming)
LDS supports streaming log data to a custom HTTPS endpoint using POST requests. To configure this:
- On the
LDS Configuration
page, in the Delivery Destination section, select Custom HTTPS Endpoint (Streaming) from the dropdown. - Enter the
HTTPS URL
that acceptsPOST
requests in the URL field. - Optionally, in the AUTHORIZATION HEADER VALUE field, provide the value for the Authorization header to be used when sending logs (e.g.,
Basic <Base64 encoded username and password>
orBearer <Your API key>
). - Optionally, use the CUSTOM HEADER NAME and CUSTOM HEADER VALUE fields to specify additional HTTP headers. You can add multiple headers using the +(plus) button or remove them with the -(minus) button. Standard headers
Content-Type, Encoding, Authorization, and Host
are not supported. - Optionally, in the Delivery Options section:
- Choose the log DATA COMPRESSION method. Supported options include: ZSTD, GZIP.
- Select the log DATA FORMAT:: TSV, JSON Lines, JSON Array, JSON.
- If you need fields with
null
values to be included in JSON format messages, select the INCLUDE NULL VALUES IN JSON option, as they are excluded by default.
- Optionally, in the Data Sampling section, reduce the volume of delivered logs by applying sampling rules. Refer to the Data Sampling for additional details.
- Click Save to validate the connection to the destination and apply your settings.
During validation, LDS sends a sample POST request to the provided endpoint to verify access. The request body contains sample data formatted according to the selected data format and compressed using the chosen data compression algorithm. A response with any 2xx status code indicates that the validation is successful.
Delivery to Datadog (Streaming)
Prerequisites
- A Datadog account: Use an existing account or create a new one.
- A Datadog API key: Generate via Datadog. (See Datadog’s documentation on API and Application Keys.)
Configuration
- On the
LDS Configuration
screen, in the Delivery Destination section, select Datadog (Streaming) from the dropdown. - Enter the following details:
- SITE: Select the Datadog site region that matches your Datadog environment.
- API KEY: Enter the API key associated with your Datadog account.
- SERVICE: (Optional) Specify the property to be used as the ‘service’ property in Datadog.
- TAGS: (Optional) Provide a comma-separated list of tags to include with the logs (e.g.,
cdn:edgio
).
- Optionally, in the Data Sampling section, reduce the volume of delivered logs by applying sampling rules. Refer to the Data Sampling for additional details.
- Click Save to validate the connection to the destination and apply your settings.
Delivery to Edgio Origin Storage
Standard fees apply for using Origin Storage.
- Ensure Origin Storage is enabled for the account where you want to store logs.
Configuration
- On the
LDS Configuration
screen, in the Delivery Destination section, select Origin Storage from the dropdown. - Optionally, specify the STORAGE ACCOUNT if you want to use a different Origin Storage account. By default, logs are stored under the same account that owns the LDS configuration.
Log files are stored in a directory named ‘_livelogs’ at the root of your space. You are responsible for managing and removing data; LDS does not handle data removal.
- Optionally, in the Delivery Options section:
- Change the DIRECTORY LAYOUT to customize how logs are organized within a bucket. For details, refer to Log Files Naming and Location.
- Choose the DATA COMPRESSION method for your log files. Supported options include: LZ4 (default), GZIP, LZF, SNAPPY, ZSTD.
- Select the log DATA FORMAT:: W3C (Tab-Separated)(default), TSV, JSON Lines, JSON Array, JSON.
- If you need fields with
null
values to be included in JSON format files, select the INCLUDE NULL VALUES IN JSON option, as they are excluded by default.
- Optionally, in the Data Sampling section, reduce the volume of delivered logs by applying sampling rules. Refer to the Data Sampling for additional details.
- Click Save to validate the connection to the destination and apply your settings.
Delivery to Google Cloud Storage
Prerequisites
- Create a Google Cloud Project (GCP) or use an existing project. See Google’s Google’s guide for instructions.
- Set up a GCP bucket to store your logs. You can create a new bucket or use an existing one. See Google’s Create Storage Buckets Guide for instructions.
- Create a Google service account that will use to access your bucket. See Google’s Service accounts guide for instructions.
- Using Google’s IAM roles for Cloud Storage, guide, grant the following roles on the bucket:
- Storage Object Creator (
storage.objectCreate
) - Storage Object Viewer (
storage.objectViewer
)
- Storage Object Creator (
- Add the service account as a member of the bucket you created in step 2.
- Generate JSON access keys for the service account. See Google’s Creating service account keys guide for instructions.
Configuration
- On the LDS Configuration screen, in the Delivery Destination section, select Google Cloud Storage from the dropdown.
- In the CLIENT EMAIL field, enter the value of the
client_email
field from the JSON key file associated with your Google service account. - In the SECRET KEY field, enter the value of the
private_key
field from the JSON key file associated with your Google service account.- Note: The secret key is sensitive information. After saving the configuration, the key will not be visible. However, you can enter a new key and save the configuration if needed.
- In the BUCKET NAME field, enter the name of the storage bucket you created in your Google Cloud account.
- Optionally, specify the PATH within the bucket where logs will be stored. By default, logs are stored in the root of the bucket.
- Optionally, in the Delivery Options section:
- Change the DIRECTORY LAYOUT to customize how logs are organized within a bucket. For details, refer to Log Files Naming and Location.
- Choose the DATA COMPRESSION method for your log files. Supported options include: LZ4 (default), GZIP, LZF, SNAPPY, ZSTD.
- Select the log DATA FORMAT:: W3C (Tab-Separated)(default), TSV, JSON Lines, JSON Array, JSON.
- If you need fields with
null
values to be included in JSON format files, select the INCLUDE NULL VALUES IN JSON option, as they are excluded by default.
- Optionally, in the Data Sampling section, reduce the volume of delivered logs by applying sampling rules. Refer to the Data Sampling for additional details.
- Click Save to validate the connection to the destination and apply your settings.
During the validation process, LDS creates a test file in the specified GCP bucket using the provided credentials and settings. The file is named
_edgio_validation/validation_{timestamp}.txt
. The file will only appear if the validation is successful. Since these files are no longer necessary after validation, you can delete them as needed.
Delivery to Hydrolix (Streaming)
Prerequisites
- Create a Project/Table
- Create a Transform
Configuration
- On the
LDS Configuration
screen, in the Delivery Destination section, select Hydrolix (Streaming) from the dropdown. - Enter the following details:
- STREAMING API HOSTNAME: Enter the hostname of your Hydrolix Streaming API. This value will be used in the URL
https://<hydrolix-streaming-api-hostname>/ingest/event
for log ingestion. - PROJECT NAME: Enter the Hydrolix project name to include in the
x-hdx-project
HTTP header. - TABLE NAME: Enter the Hydrolix table name to include in the
x-hdx-table
HTTP header. - TRANSFORM SCHEMA NAME: (Optional) Specify the Hydrolix transform schema to include in the
x-hdx-transform
HTTP header. - AUTHORIZATION HEADER VALUE: (Optional) Enter the authorization header value to use when sending logs (e.g.,
Basic <Base64 encoded username and password>
orBearer <API key>
). - STREAM TOKEN: (Optional) Provide a streaming token to include in the
x-hdx-token
HTTP header.
- STREAMING API HOSTNAME: Enter the hostname of your Hydrolix Streaming API. This value will be used in the URL
- Optionally, in the Data Sampling section, reduce the volume of delivered logs by applying sampling rules. Refer to the Data Sampling for additional details.
- Click Save to validate the connection to the destination and apply your settings.
During validation, LDS sends a sample POST request with a JSON payload and GZIP compression to the provided Hydrolix endpoint to verify access. A response with any 2xx status code indicates that the validation is successful.
Delivery to Microsoft Azure Blob Storage
Prerequisites
- Create an Azure storage account. See Microsoft’s guide for instructions.
- Create a container to which log data will be uploaded. Refer to Microsoft’s guide for instructions.
- Obtain SAS token or an access key for authorizing requests to upload content to your Azure Blob Storage account.
Configuration
- On the
Create/Update LDS Configuration
page in the Delivery Destination section, choose Microsoft Azure from the dropdown. - Enter the name of your storage account in the ACCOUNT NAME field.
- Specify the name of Azure conatiner to which log data will be uploaded in the CONTAINER NAME field.
- From the ACCESS METHOD dropdown, select your preferred authorization method. Then, enter the access key or SAS token in the input field that appears next to it.
- Optionally, in the Delivery Options section:
- Change the DIRECTORY LAYOUT to customize how logs are organized within a bucket. For details, refer to Log Files Naming and Location.
- Choose the DATA COMPRESSION method for your log files. Supported options include: LZ4 (default), GZIP, LZF, SNAPPY, ZSTD.
- Select the log DATA FORMAT:: W3C (Tab-Separated)(default), TSV, JSON Lines, JSON Array, JSON.
- If you need fields with
null
values to be included in JSON format files, select the INCLUDE NULL VALUES IN JSON option, as they are excluded by default.
- Optionally, in the Data Sampling section, reduce the volume of delivered logs by applying sampling rules. Refer to the Data Sampling for additional details.
- Click Save to validate the connection to the destination and apply your settings.
During the validation process, LDS creates a test file in the specified container using the provided credentials and settings. The file is named
_edgio_validation/validation_{timestamp}.txt
. The file will only appear if the validation is successful. Since these files are no longer necessary after validation, you can delete them as needed.Delivery to New Relic (Streaming)
Prerequisites
- Register a New Relic account or use existing one.
- Obtain your license ingest key.
Configuration
- On the
LDS Configuration
screen, in the Delivery Destination section, select New Relic (streaming) from the dropdown. - In the DOMAIN field, enter the New Relic API domain. This value will be used in the URL
https://<new-relic-domain>/log/v1
for log ingestion. - In the API KEY field, enter your account licence ingest key you created earlier .
- Optionally, in the Data Sampling section, reduce the volume of delivered logs by applying sampling rules. Refer to the Data Sampling for additional details.
- Click Save to validate the connection to the destination and apply your settings.
During validation, LDS sends a sample POST request with a JSON payload and GZIP compression to the provided New Relic endpoint to verify access. A response with any 2xx status code indicates that the validation is successful.
Delivery to Splunk (Streaming)
Prerequisites
LDS supports sending log data to Splunk over HTTPS, requiring the HTTP Event Collector (HEC) to be configured and enabled on your Splunk instance.
- Follow this guide to set up and enable the HEC.
- Ensure that indexer acknowledgment is disabled in your HEC configuration.
- Save the HEC token and the URL pointing to your Splunk HTTP Event Collector.
Configuration
- On the
LDS Configuration
screen, in the Delivery Destination section, select Splunk (Streaming) from the dropdown. - In the DOMAIN field, enter the Splunk HEC API domain. This value will be used in the URL
https://<splunk-domain>/services/collector/event
for log ingestion. - In the EVENT COLLECTOR TOKEN field, enter the HEC token you created and enabled in Splunk.
- Optionally, in the INDEX field, specify the index name by which the event data is to be indexed. The index you specify here must be within the list of allowed indexes if the HEC token has the indexes parameter set.
- Optionally, in the FIELDS input, provide a JSON object with custom fields to include in log events. These fields will be sent as metadata and indexed by Splunk. Example:
{"env":"production", "region":"us-west"}
. - Optionally, in the SOURCE Type field, specify the source type value to assign to the event data.
- Optionally, in the Data Sampling section, reduce the volume of delivered logs by applying sampling rules. Refer to the Data Sampling for additional details.
- Click Save to validate the connection to the destination and apply your settings.
During validation, LDS sends a sample POST request with a JSON payload and GZIP compression to the HEC endpoint to verify access. A response with any 2xx status code indicates that the validation is successful.
Delivery to Sumo Logic (Streaming)
Prerequisites
To configure Sumo Logic as a logging endpoint, start by creating a Sumo Logic account. Next, add an HTTP Logs and Metrics Source and save the HTTP Source URL. For setup instructions, refer to the Sumo Logic source configuration guide.
Configuration
- On the
LDS Configuration
screen, in the Delivery Destination section, select Sumo Logic (streaming) from the dropdown. - In the ENDPOINT field, enter the domain name of the Sumo Logic HTTP source which will form the URL
https://<endpoint>/receiver/v1/http
for log ingestion. - In the HTTP COLLECTOR CODE field, enter the code from your Sumo Logic endpoint URL. This is the last part of the URL in the format
https://<SumoEndpoint>/receiver/v1/http/<HTTPCollectorCode>
. - Optionally, in the SOURCE CATEGORY field, specify acustom source category. This value will be sent in the
X-Sumo-Category
header. - Optionally, in the FIELDS input, provide key-value pairs to tag your logs for easier searching. These tags will be sent in the
X-Sumo-Fields
header. Example: environment=dev,cluster=k8s. - Optionally, in the Data Sampling section, reduce the volume of delivered logs by applying sampling rules. Refer to the Data Sampling for additional details.
- Click Save to validate the connection to the destination and apply your settings.
During validation, LDS sends a sample POST request with a JSON payload and GZIP compression to the Sumo Logic HTTP Source endpoint to verify access. A response with any 2xx status code indicates that the validation is successful.
Data Formats
Depending on the destination, LDS can send logs data in one of the following formats: W3C (tab-separated), TSV, JSON Lines, JSON Array or JSON. Below are descriptions and sample log lines for each format to help you understand how your data will appear.
W3C (Tab-Separated)
Includes a W3C header and uses tabs to separate data fields.
null
values are represented by a hyphen (-
).Sample log entries:
1#Version: 1.02#Date: 2024-09-06 11:42:073#Software: Log Delivery Service4#Start-Date: 2024-09-05 01:00:005#End-Date: 2024-09-05 02:00:006#Fields: date time s-host c-ip c-country c-city sc-bytes s-ttfb duration72024-09-05 01:10:51.706 cds102.jed.llnw.net 10.252.49.10 - - 259 0 082024-09-05 01:12:18.018 cds102.sabf.llnw.net 185.76.48.149 united kingdom southampton 455 262 262
TSV
Log data is tab-separated with a header row for field names. null values are represented by hyphens (-).
Sample log entries:
1date time s-host c-ip c-country c-city sc-bytes s-ttfb duration22024-09-05 01:10:51.706 cds102.jed.llnw.net 10.252.49.10 - - 259 0 032024-09-05 01:12:18.018 cds102.sabf.llnw.net 185.76.48.149 united kingdom southampton 455 262 262
Log files delivered to Amazon S3, Azure Blob Storage, Edgio Origin Storage and Google Cloud Storage include TSV headers, while messages sent to Custom HTTPS Endpoints do not.
JSON Lines
Each log entry is a separate JSON object, with each object represented on a single line.
Sample log entries:
1{"date":"2024-09-05","time":"01:10:51.706","s-host":"cds102.jed.llnw.net","c-ip":"10.252.49.10","sc-bytes":259,"s-ttfb":0,"duration":0}2{"date":"2024-09-05","time":"01:12:18.018","s-host":"cds102.sabf.llnw.net","c-ip":"185.76.48.149","c-country":"united kingdom","c-city":"southampton","sc-bytes":259,"s-ttfb":0,"duration":0}
JSON Array
JSON array where each object corresponds to a log entry.
Sample log entries:`
1[2 {"date":"2024-09-05","time":"01:10:51.706","s-host":"cds102.jed.llnw.net","c-ip":"10.252.49.10","sc-bytes":259,"s-ttfb":0,"duration":0},3 {"date":"2024-09-05","time":"01:12:18.018","s-host":"cds102.sabf.llnw.net","c-ip":"185.76.48.149","c-country":"united kingdom","c-city":"southampton","sc-bytes":259,"s-ttfb":0,"duration":0}4]
JSON
A single JSON document that contains top-level metadata fields along with an array of log entries. Each log entry is represented as an individual object within the logs array.
Top-Level Fields:
agent_id
: Always an empty string ("").seq_num
: Always set to 0.platform
: Always “delivery”.account_number
: The Edgio account number as a string, identifying the account associated with the logs.datestamp
: Indicates the date when the log data was prepared for delivery in YYYYMMDD formatlogs
: array contains individual log entries.
Sample log ebtries
1{2 "agent_id": "",3 "seq_num": 0,4 "platform": "adn",5 "account_number": "0001",6 "datestamp": "20180416",7 "logs": [8 {"date":"2024-09-05","time":"01:10:51.706","s-host":"cds102.jed.llnw.net","c-ip":"10.252.49.10","sc-bytes":259,"s-ttfb":0,"duration":0},9 {"date":"2024-09-05","time":"01:12:18.018","s-host":"cds102.sabf.llnw.net","c-ip":"185.76.48.149","c-country":"united kingdom","c-city":"southampton","sc-bytes":259,"s-ttfb":0,"duration":0}10 ]11}
When using
JSON, JSON Array, and JSON Lines
formats, fields with null
values are excluded from log lines by default. To include these fields, enable the INCLUDE NULL VALUES IN JSON option in the Delivery Options
section during LDS configuration.Configuration
To configure data format:
- Go to the Delivery Options section on the
Create/Update LDS Configuration
page. - Select the desired format from the
DATA FORMAT
dropdown.
Log Files Naming and Location
For file delivery destinations, LDS allows you to manage where logs are placed and how they’re named.
Folder Path
The log file location is determined by the following properties:
-
PATH: This is an optional static root path within the storage which can be specified in the
Delivery Destination
section on theCreate/Edit LDS configuration page
only whenAmazon S3
,Google Cloud Storage
orMicrosoft Azure Blob Storage
is selected. -
DIRECTORY LAYOUT: Defines the folder structure within the path. It supports these dynamic placeholders that are replaced with relevant information during file upload:
{service_type}
: Type of service for which logs are collected.{config_uuid}
: UUID of the LDS configuration.{yyyy}
,{MM}
,{dd}
: Resolves to year, month, and day respectively based on the start of the time period of the log entries covered in the file, all in UTC timezone.{yyyy_proc}
,{MM_proc}
,{dd_proc}
: Resolves to year, month, and day respectively using the timestamp that represents the time when the file was prepared by LDS for delivery, all in UTC timezone.
It is not possible to combine
{yyyy_proc}
, {MM_proc}
, {dd_proc}
with {yyyy}
, {MM}
, {dd}
in the directory layout. Mixing these variables in the directory structure is invalid.To configure the Directory Layout, go to the
Delivery Options
section on the Create/Update LDS Configuration
screen and pick one of the following:{service_type}/{config_uuid}/{yyyy_proc}/{MM_proc}/{dd_proc}
(default): Organizes directories by service type, configuration UUID, and the date when the file was processed by LDS.{service_type}/{config_uuid}/{yyyy}/{MM}/{dd}
: Organizes directories by service type, configuration UUID, and the date range of the log entries.No Subdirectories
: Places all log files in the root directory of the storage, without any subdirectory structure. This option is available for Amazon S3, Google Cloud Storage and Microsoft Azure Blob Storage.
Log File Naming
FILENAME TEMPLATE: Determines the naming convention for log files uploaded to your destination storage. The default template is:
{shortname}{request_end_date_time_from}-{request_end_date_time_to}.{process_window_date_time}{split_id}.{format}.{compression}
Supported dynamic placeholders:
{shortname}
: The account name for which the log entries have been collected.{config_uuid}
: UUID of the LDS configuration.{request_end_date_time_from}
: The start timestamp of the time period covered by log entries in the file, formatted as{year}{month}{day}{hour}{minute}{second}
in UTC.{request_end_date_time_to}
: The end timestamp of the time period covered by log entries in the file, formatted as{year}{month}{day}{hour}{minute}{second}
in UTC.{process_window_date_time}
: The timestamp when the file was prepared for delivery, formatted as{year}{month}{day}{hour}{minute}{second}
in UTC.{split_id}
: ID assigned to the file for splitting large log files. Files are split to avoid exceeding the 1GB size limit. The first split file is labeled 000, with subsequent parts numbered sequentially (001, 002, etc.). If no splitting is needed, the split_id is 000.{format}
: Reflects the selected Data Format. Options includew3c
,json_lines
,json_array
,json
ortsv
.{compression}
: File compression format.
- The placeholder
{config_uuid}
must be included in either the directory layout or the filename template. This restriction ensures the uniqueness of the file path, preventing conflicts and overwrites when multiple configurations write data to the same bucket. - The time period covered by log entries in the file is not fixed and may vary based on LDS setup and processing requirements. Currently, LDS supports 10-minute and hourly time periods, with potential for future support of additional time periods.
- Log file size is measured before compression, so a log file may be split even if its compressed size is smaller than 1GB.
- The filename template is fixed and cannot be edited in the UI. It is displayed in the
Delivery Options
section on theCreate/Update LDS Configuration
page. For adjustments, contact your account manager.
Data Compression
LDS supports the following data compression algorithms to reduce log file sizes:
- GZIP
- LZF
- LZ4 (Frame Format)
- SNAPPY
- ZSTD
Configuration
To configure data format:
- Go to the Delivery Options section on the
Create/Edit LDS configuration page
. - Select the desired format from the
DATA COMPRESSION
dropdown.
Data Sampling
The
Data Sampling
feature allows you to control the volume of log data delivered by specifying the percentage of log lines to be included for each status code group (e.g., 1xx
, 2xx
, 3xx
). By default, data sampling is set to 100%, meaning all log data is delivered without any filtering.To configure data sampling:
- Go to the
Data Sampling
section on theCreate/Update LDS Configuration
screen. - Use the slider to select the percentage of log lines you wish to deliver for each status code group. The valid range for sampling rates is
0
to100
:0
means all data is filtered out (no logs are delivered).100
means no filtering is applied (all logs are delivered).- Any value between
0
and100
represents the percentage of log lines that will be included.
Personally Identifiable Information
Edgio’s Log Delivery Service conforms to General Data Protection Regulations (GDPR) requirements. You can configure logs to include the following fields, which contain Personally Identifiable Information (PII):
cs-cookie
cs-uri
so-src-uri
Sign PII Agreements
Per GDPR, you must explicitly indicate that you understand the risks associated with the PII fields. When you access Log Delivery Service, you will see a message that describes the risks involved. Click the
Agree
button to indicate you agree.- Non-Company Admin users can sign agreements only for the company to which they belong.
- Company Admin users can sign agreements for child companies as well.
Permissions
To access and control LDS configurations, you need the following permissions:
Configure > Log Delivery Service > View
: Allows you to view the list of LDS configurations and their details.Configure > Log Delivery Service > Manage
: Grants you full access to view and manage LDS configurations. This includes the ability to create, edit, activate, deactivate, and delete configurations.
Downloading LDS Files from Origin Storage
You have two options for downloading LDS files from Origin Storage:
Origin Storage Management Console
- Open the
Origin Storage Console
under theManage
menu. - In the bottom-right corner, select your
Account
andUsername
from the dropdowns. - Navigate to the folder containing the file.
- Click the
Download
icon next to the file, and your browser will download it automatically.
Downloading Files via Origin Storage API
This section outlines the methods you need to download files using the Origin Storage JSON-RPC API. While essential information is provided here, for detailed documentation on each method, refer to the Origin Storage API Reference Guide.
Prerequisites
- API Username and Password: You need credentials to authenticate your API requests. You can manage these on the
Manage > Origin Storage Users
page.It is not possible to view an existing user’s password, but you can set a new one if needed. - URL to the Storage API: Your Edgio account name is a part of the JSON-RPC API URL. The API URL follows this format:
http://{Account name}-l.upload.llnw.net/jsonrpc2
- Example:
http://supercustomer.upload.llnw.net/jsonrpc2
- Your Edgio account name is included in the Welcome letter you received when you purchased Origin Storage. If you have any questions or issues, please contact your Edgio representative.
- If you are a long-standing customer and the preceding endpoints fail to resolve, use the following endpoints with the suffix
-l
after{Account name}
:- Example:
http://supercustomer-l.upload.llnw.net/jsonrpc2
- Example:
- Example:
Step 1: Authenticate using the login
Method
First, you need to get an authentication token by calling the
login
method. This token is required for subsequent calls.
Method Signature:1login(username, password, detail)
Parameters:
username
: Origin Storage API username.password
: Origin Storage API password.detail
: (optional) A boolean (true/false) indicating whether to return detailed data or a simpler response. Defaults to False.
Step 2: List Log Files using the listFile
Method
Once authenticated, you can list log files from a specific directory by calling the
listFile
method.
Method Signature:1listFile( token, dir, pageSize, cookie, stat)
Parameters:
token
: The authentication token obtained from the login method.dir
: A string representing the directory path from which you want to list files.pageSize
: The number of files to return in each response (useful for limiting the size of results).cookie
: A number used for paginating results across multiple listFile calls.stat
: A boolean (true/false) indicating whether to return detailed file information (such as file size, creation time, etc.).
Step 3: Obtain a Protected Download URL
To securely download log files, you can obtain a time-limited download URL by calling the mediaVaultUrl method from the Origin Storage JSON-RPC interface. This URL ensures that your file downloads are protected with an expiration time.
Method Signature:
1mediaVaultUrl(token, path, expiry)
Parameters:
token
: The authentication token obtained from the login method.path
: The file path for which you want to generate a secure download URL.expiry
: (optional) The number of seconds for which the download URL should remain valid. Must be in the range 1 to 2147483648. If set to 0 or omitted, it defaults to 3600 seconds (1 hour).
Method Response: The method returns an object containing the following:
code
: The return code, where 0 indicates success.download_url
: The URL to download the specified file.message
: A description of the return code.preview_url
: The URL to preview the file, if applicable.
Example of response:
JSON
1{2 "code": 0,3 "download_url": "http://cs-download.limelight.com/<path to file>",4 "message": "success",5 "preview_url": "http://cs-download.limelight.com/<path to file>",6}
Step 4: Download the File
Once you receive the download_url, you can make an HTTP GET request to the URL to download the log file
Python Script for Downloading Files from Origin Storage
This script is provided as a sample and does not come with official support. Be sure to test it in a development environment before using it in production.
python
1#!/usr/bin/env python2import logging, sys3from multiprocessing import Pool4import requests5import time6import json78# Configuration9API_USERNAME = ''10API_PASSWORD = ''11API_URL = 'http://{Account Name}.upload.llnw.net/jsonrpc2'12STORAGE_LOG_DIR = '/_livelogs/http/'1314MAX_FILES_TO_DOWNLOAD = 515DELETE_FILE_AFTER_DOWNLOAD = False16DELETE_EMPTY_DIRECTORY = False17'''18Author: spandey19Unofficial Sample. Provided AS IS. WITHOUT ANY WARRANTY OR CONDITIONS.20Uses Python 321'''22LOG_FILENAME = 'LDSDownloadSession.log'23FileList = 'DLFiles.log'24logging.basicConfig(filename = LOG_FILENAME, level = logging.DEBUG, format='%(asctime)s %(levelname)s-%(filename)s:%(message)s')25logger = logging.getLogger(__name__)2627class StatError(RuntimeError):28 def __init__(self, arg):29 self.args = arg3031class ListPathError(RuntimeError):32 def __init__(self, arg):33 self.args = arg3435jsonRPC_Endpoint=''36token=''37cookie = ''38numFiles = 03940numDirs = 041totalBytes = 042oldFileList = []43theFileList = []44dirList = []45threads = []46'''47User-defined variables48'''49pageSize = 10000 # page size for listing log files50files_to_download = [] # log files to download51media_vault_expiry = 60 # expiry time for mediaVaultUrl request52mv_errors = { -1: "Internal error", -2: "Path exists and is a directory", -8: "Invalid path",53 -34: "Invalid expiry", -60: "Service is disabled or unavailable", -10001: "Invalid token"}54'''55Function to examine files returned from calls to listFile56Based on a condition that you determine, you write file names to a list57of files that will later be downloaded.58This simple example looks for file names that contain the number 2.59need to add {"method":"deleteFile","id":39,"jsonrpc":"2.0","params":{"token":"a4660cbde39c4dceb2cf796d494db3da","path":"/lll/1.mp4"}}60'''6162def parse_list(file_list):63 for log_file in file_list:64 name = log_file['name']65 if name.find('2') > -1:66 files_to_download.append(name)67 print(log_file['name'])6869def getFileListing(token, _dirname_, res):70 numDirs = len(res['dirs'])71 numFiles = len(res['files'])72 _directories_ = res['dirs']73 print ("Total directory count: " + str(numDirs))74 print ("Total file count: " + str(numFiles))75 #Delete the dir in case is empty and is not the base path76 if numDirs == 0 and numFiles == 0 and _dirname_.count('/') > 3 and DELETE_EMPTY_DIRECTORY:77 delp = '{"method":"deleteDir","id":1,"jsonrpc":"2.0","params":{"token":"'+ token +'","path":"'+ _dirname_ +'"}}'78 print("\nDeleting Directory : "+ delp)79 delpRes = requests.post(jsonRPC_Endpoint, data=delp)80 delpRes = json.loads(delpRes.text)81 delpCode = delpRes['result']82 #print("\n\n-------------- Code: " + str(delpCode) )83 if delpCode != 0:84 print("Error attempting to call del url.\nCode: " + str(delpCode))8586 for _dir_ in _directories_:87 #print ("Scanning Directory: " + _dir_['name'] + " for dirs")88 dirName = _dirname_ + '/' + _dir_['name']89 listPath(token, dirName)90 # Listing Files91 file_listing = res['files']92 conteggio = 093 for file in file_listing:94 '''95 Download file. This is a single-threaded approach for simple use & demonstration purposes.96 Customers might want to try a multi-threaded approach for a large number of files to download.97 '''98 conteggio += 199 log_path = _dirname_ + file['name']100 print("\nDownloading file: "+ log_path)101 mvu = '{"method": "mediaVaultUrl", "id": 1, "params": {"token":"'+ token +'", "path": "'+ log_path +'", "expiry": '+str(media_vault_expiry)+'}, "jsonrpc": "2.0"}'102 mvuRes = requests.post(jsonRPC_Endpoint, data=mvu)103 mvuRes = json.loads(mvuRes.text)104 #print("==== Printing mediaVaultUrl response ====\n")105 #print(mvuRes)106 code = mvuRes['result']['code']107 if code !=0:108 print("Error attempting to call 'mediaVaultUrl.\nCode: " + str(code) + ": " + mv_errors[code])109 else:110 mv_download_url = mvuRes['result']['download_url']111 # grab the name of the file to write from mv url112 lds_file_name = mv_download_url.rsplit("/",1)[1].split("?")[0]113 #print(mv_download_url, '\nFilename:'+lds_file_name)114 with open(lds_file_name, "wb") as f:115 # Use the requests library to make the download116 response = requests.get(mv_download_url, stream=True)117 # check & show download progress118 total_length = response.headers.get('content-length')119 if total_length is None: # no content length header120 print("no content-length header found")121 f.write(response.content)122 else:123 dl = 0124 total_length = int(total_length)125 for data in response.iter_content(chunk_size=4096):126 dl += len(data)127 f.write(data)128 done = int(50 * dl / total_length)129 sys.stdout.write("\r[%s%s]" % ('|' * done, ' ' * (50-done)) )130 sys.stdout.flush()131 if DELETE_FILE_AFTER_DOWNLOAD:132 #Delete the file just downloaded133 delu = '{"method":"deleteFile","id":1,"jsonrpc":"2.0","params":{"token":"'+ token +'","path":"'+ log_path +'"}}'134 print("\nDeleting file: "+ log_path)135 deluRes = requests.post(jsonRPC_Endpoint, data=delu)136 deluRes = json.loads(deluRes.text)137 delcode = deluRes['result']138 if delcode !=0:139 print("Error attempting to call del url.\nCode: " + str(delcode) + ": " + mv_errors[delcode])140 # Upon non-success write a line to your errors file141 if response.status_code != 200:142 print("Unable to download " + file['name'] + ". Status code: " + response.status_code)143 if conteggio == MAX_FILES_TO_DOWNLOAD:144 break # break here145146147148def listPath(token, _dirname_):149 '''150 Listing path recursively151 '''152 try:153 # Scan through parent directory for the files and sub-dirs154 listpathdata='{"method": "listPath","id": 1,"params": {"token": "'+token+'","path": "'+_dirname_+'","pageSize": '+str(pageSize)+',"cookie": "'+cookie+'","stat": true},"jsonrpc": "2.0"}'155 # print('===List Path Data - Parent==\n', listpathdata)156 res = requests.post(jsonRPC_Endpoint, data=listpathdata)157 res = json.loads(res.text)158 print ('====== Listing Path: '+_dirname_)159 code = res['result']['code']160161 if code !=0:162 msg = 'Error issuing listPath command on directory: ' + _dirname_163 msg += '\n Return code: ' + str( code )164 msg += '\n See API documentation for details.'165 logger.error('ListPathError' + msg)166 raise ListPathError( msg )167168 theFileList = getFileListing(token,_dirname_,res['result'])169170 except ListPathError as e:171 print (''.join( e.args ))172173 except StatError as e:174 print (''.join( e.args ))175176def main(host, username, password):177 global jsonRPC_Endpoint178 jsonRPC_Endpoint = host179 try:180 # Obtain token181 loginData='{"method": "login","id": 0,"params": {"username": "'+username+'","password":"'+password+'","detail": true},"jsonrpc": "2.0"}'182 login = requests.post(jsonRPC_Endpoint, data=loginData)183 #print (login.reason, login.headers)184 resp = json.loads(login.text)185 token = resp['result'][0]186 print ('====== Successfully Logged In.')187 #print ('Token: '+token)188 logger.debug('Logged In. Token Is: '+ token)189 # Persist Token for the session until the logout or the end of time defined by 'expire'190 persistData='{"method": "updateSession","id": 4,"params": {"token": "'+token+'", "expire": 0},"jsonrpc": "2.0"}'191 persist = requests.post(jsonRPC_Endpoint, data=persistData)192 persist = json.loads(persist.text)193 #print('=======Updated Token======\n',persist)194 if persist['result'] == 0:195 # print('Token Persisted!')196 logger.debug('Token Persisted!. Token Is: '+ token)197198 # call listPath method on storage199 listPath(token, STORAGE_LOG_DIR)200 except Exception as e:201 print(''.join( e.args ))202 logger.error('Error Occured While Logging')203 finally:204 #print ('\nLogging out...\n')205 logoutData = '{"method": "logout","id": 1,"params": {"token": "'+token+'"},"jsonrpc": "2.0"}'206 logoutRes = requests.post(jsonRPC_Endpoint, data=logoutData)207 logoutRes = json.loads(logoutRes.text)208 #print ('Logout results: ', logoutRes)209 if logoutRes['result'] == 0:210 logger.debug('Logged Out!')211212if __name__ == "__main__":213 main(API_URL, API_USERNAME,API_PASSWORD)
Script Configuration
API_USERNAME
: Your API username.API_PASSWORD
: Your API password.API_URL
: The URL of your Origin Storage API.STORAGE_LOG_DIR
: The directory path where the script will look for files to download.MAX_FILES_TO_DOWNLOAD
: Limit the number of files to download. Set to 0 for unlimited downloads.DELETE_FILE_AFTER_DOWNLOAD
: Set to True if you want to delete files after downloading.DELETE_EMPTY_DIRECTORY
: Set to True to delete any empty directories after the files are removed.
How to Run the Script
- Install the necessary dependencies if not already installed:
requests, logging, and multiprocessing
.
1pip install requests
- Configure the script by setting your
API_USERNAME
,API_PASSWORD
,API_URL
, andSTORAGE_LOG_DIR
variables. - Adjust other optional settings like
MAX_FILES_TO_DOWNLOAD
,DELETE_FILE_AFTER_DOWNLOAD
, andDELETE_EMPTY_DIRECTORY
based on your needs. - Run the script:
1python download_files.py