Global Configuration

Directory Structure

|-- /
  |-- global_configs.yaml

The global_configs.yaml file must be located in the root of your configuration directory and must be named global_configs.yaml. It contains configurations for access log format, custom shared memory zones, global variables, and other configurations.

Access Log Format Configuration

In OpenResty Edge, you can configure multiple access log formats. For this purpose, access log formats are represented as an array.

Parameter Description

ParameterData TypeRequiredDescription
namestringYesUnique identifier for the access log format
formatstringYesDefines the log format
escapestringNoSpecifies the escape method for log characters, possible values include: default, none, json
defaultboolNoSpecifies whether this log format is the default log format

The default parameter determines whether to set this log format as the default option. If set as default, applications that don’t specifically specify a log format will use this format. Note: There can and should be only one default log format in the configuration.

Configuration Example

access_log_formats:
- default: false
  name: example
  escape: json
  format: |-
    {
        "time_local": "$time_local",
        "method": "$request_method",
        "request": "$request",
        "transid": "$or_global_user_variable_uuid",
        "upstream_header_time": "$upstream_header_time"
    }

According to this example configuration, an access log format named example will be created. The log format list will include two log formats: example and main. In the format parameter’s content, a global user variable named uuid is used, represented as $or_global_user_variable_uuid.

Custom Shared Memory Zone Configuration

You can define multiple shared memory zones, therefore these zones are represented as an array.

Parameter Description

ParameterData TypeRequiredDescription
namestringYesUnique identifier for the shared memory zone
sizestringNoDefines the capacity size of the shared memory zone
size_unitstringYesSpecifies the unit of the shared memory zone size, possible values are k, m, g

Configuration Example

custom_shared_zone:
- size_unit: m
  name: cache_shared_dict
  size: 1
- size_unit: m
  name: rec_cache_shared_dict
  size: 1

Global User Variables

You can define multiple global variables, therefore variables are represented as an array.

Parameter Description

ParameterData TypeRequiredDescription
namestringYesUnique identifier for the variable
typestringYesData type of the variable, possible values are string, num, int, bool
defaultstringYesDefault value of the variable

Configuration Example

user_variables:
- name: uuid
  type: string
  default: '-'

In this example, a global user variable named uuid is defined.

Global user variables can be used in access logs or Edgelang scripts, in the format $or_global_user_variable_<variable_name>. For example:

$or_global_user_variable_uuid