Logs uploader

Create logs uploader policy.

post/cdn/logs_uploader/policies

Request

  • Base URL
    https://api.gcore.com
  • URL
    https://api.gcore.com/cdn/logs_uploader/policies
  • Auth
    HTTP apikey

Request body

include_empty_logsboolean

Include empty logs in the upload.

include_shield_logsboolean

Include logs from origin shielding in the upload.

namestring

Name of the policy.

descriptionstring

Description of the policy.

retry_interval_minutesinteger

Interval in minutes to retry failed uploads.

rotate_interval_minutesinteger

Interval in minutes to rotate logs.

rotate_threshold_mbinteger nullable

Threshold in MB to rotate logs.

rotate_threshold_linesinteger

Threshold in lines to rotate logs.

date_formatstring

Date format for logs.

field_delimiterstring

Field delimiter for logs.

field_separatorstring

Field separator for logs.

fieldsstring[]

List of fields to include in logs. Duplicate names are allowed for plain text output, but rejected when format_type is json or a field_remap is set (each field becomes a distinct output key).

file_name_templatestring

Template for log file name.

format_type'json' | ''

Format type for logs.

Possible values:

  • "" - empty, it means it will apply the format configurations from the policy.
  • "json" - output the logs as json lines.
tagsobject

Tags allow for dynamic decoration of logs by adding predefined fields to the log format. These tags serve as customizable key-value pairs that can be included in log entries to enhance context and readability.

field_remapobject

Per-field output-name remap for exported logs. Maps a canonical Gcore field name (from /cdn/logs_uploader/policies/fields, and must be present in fields) to the field name it should have in the exported logs. Unmapped fields keep their canonical name. Output names (after remapping) must be unique.

field_conversionsFieldConversions

Per-field value conversions for exported logs. Maps a canonical Gcore field name to the pipeline applied to its values. Field names are limited to 255 characters and must not be empty. Each key must be present in fields, and each conversion type must be listed in that field's allowed_conversions from /cdn/v2/logs_uploader/policies/fields. Conversions in a pipeline are applied in array order. Values are converted independently of field_remap, which renames the exported field: both are keyed on the canonical field name.

escape_special_charactersboolean

When set to true, the service sanitizes string values by escaping characters that may be unsafe for transport, logging, or downstream processing.

The following categories of characters are escaped:

  • Control and non-printable characters
  • Quotation marks and escape characters
  • Characters outside the standard ASCII range

The resulting output contains only printable ASCII characters.

log_sample_ratenumber float

Sampling rate for logs. A value between 0 and 1 that determines the fraction of log entries to collect.

  • 1 - collect all logs (default).
  • 0.5 - collect approximately 50% of logs.
  • 0 - collect no logs (effectively disables logging without removing the policy).

Example request

{
  "include_empty_logs": true,
  "include_shield_logs": true,
  "name": "Policy",
  "description": "New policy",
  "retry_interval_minutes": 32,
  "rotate_interval_minutes": 32,
  "rotate_threshold_mb": 252,
  "rotate_threshold_lines": 5000,
  "date_format": "[02/Jan/2006:15:04:05 -0700]",
  "field_delimiter": ",",
  "field_separator": ";",
  "fields": [
    "remote_addr",
    "request_time",
    "upstream_cache_status"
  ],
  "file_name_template": "{{YYYY}}_{{MM}}_{{DD}}_{{HH}}_{{mm}}_{{ss}}_access.log.gz",
  "format_type": "json",
  "tags": {},
  "field_remap": {},
  "field_conversions": {
    "request_time": {
      "conversions": [
        {
          "type": "scale",
          "config": {
            "factor": 1000,
            "precision": 0,
            "rounding": "nearest"
          }
        }
      ]
    },
    "upstream_cache_status": {
      "conversions": [
        {
          "type": "replace",
          "config": {
            "values": {
              "HIT": "cached",
              "MISS": "uncached"
            },
            "default": "other"
          }
        }
      ]
    }
  },
  "log_sample_rate": 1
}

Response

Successful.

idinteger
client_idinteger

Client that owns the policy.

createdstring date-time

Time when logs uploader policy was created.

updatedstring date-time

Time when logs uploader policy was updated.

include_empty_logsboolean

Include empty logs in the upload.

include_shield_logsboolean

Include logs from origin shielding in the upload.

namestring

Name of the policy.

descriptionstring

Description of the policy.

retry_interval_minutesinteger

Interval in minutes to retry failed uploads.

rotate_interval_minutesinteger

Interval in minutes to rotate logs.

rotate_threshold_mbinteger nullable

Threshold in MB to rotate logs.

rotate_threshold_linesinteger

Threshold in lines to rotate logs.

date_formatstring

Date format for logs.

field_delimiterstring

Field delimiter for logs.

field_separatorstring

Field separator for logs.

fieldsstring[]

List of fields to include in logs. Duplicate names are allowed for plain text output, but rejected when format_type is json or a field_remap is set (each field becomes a distinct output key).

file_name_templatestring

Template for log file name.

format_type'json' | ''

Format type for logs.

Possible values:

  • "" - empty, it means it will apply the format configurations from the policy.
  • "json" - output the logs as json lines.
tagsobject

Tags allow for dynamic decoration of logs by adding predefined fields to the log format. These tags serve as customizable key-value pairs that can be included in log entries to enhance context and readability.

field_remapobject

Per-field output-name remap for exported logs. Maps a canonical Gcore field name (from /cdn/logs_uploader/policies/fields, and must be present in fields) to the field name it should have in the exported logs. Unmapped fields keep their canonical name. Output names (after remapping) must be unique.

field_conversionsFieldConversions

Per-field value conversions for exported logs. Maps a canonical Gcore field name to the pipeline applied to its values. Field names are limited to 255 characters and must not be empty. Each key must be present in fields, and each conversion type must be listed in that field's allowed_conversions from /cdn/v2/logs_uploader/policies/fields. Conversions in a pipeline are applied in array order. Values are converted independently of field_remap, which renames the exported field: both are keyed on the canonical field name.

escape_special_charactersboolean

When set to true, the service sanitizes string values by escaping characters that may be unsafe for transport, logging, or downstream processing.

The following categories of characters are escaped:

  • Control and non-printable characters
  • Quotation marks and escape characters
  • Characters outside the standard ASCII range

The resulting output contains only printable ASCII characters.

log_sample_ratenumber float

Sampling rate for logs. A value between 0 and 1 that determines the fraction of log entries to collect.

  • 1 - collect all logs (default).
  • 0.5 - collect approximately 50% of logs.
  • 0 - collect no logs (effectively disables logging without removing the policy).
related_uploader_configsinteger[]

List of logs uploader configs that use this policy.

Example response

{
  "id": 123,
  "client_id": 123,
  "created": "2023-11-07T05:31:56Z",
  "updated": "2023-11-07T05:31:56Z",
  "include_empty_logs": true,
  "include_shield_logs": true,
  "name": "Policy",
  "description": "New policy",
  "retry_interval_minutes": 32,
  "rotate_interval_minutes": 32,
  "rotate_threshold_mb": 252,
  "rotate_threshold_lines": 5000,
  "date_format": "[02/Jan/2006:15:04:05 -0700]",
  "field_delimiter": ",",
  "field_separator": ";",
  "fields": [
    "remote_addr",
    "status"
  ],
  "file_name_template": "{{YYYY}}_{{MM}}_{{DD}}_{{HH}}_{{mm}}_{{ss}}_access.log.gz",
  "format_type": "json",
  "tags": {},
  "field_remap": {},
  "field_conversions": {},
  "log_sample_rate": 1,
  "related_uploader_configs": [
    123
  ]
}

Changes

    • info

      added the new optional request property

    • info

      added the optional property to the response with the status

    • info

      added the new optional request property

    • info

      added the optional property to the response with the status