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, dynamic metrics shared memory size, 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
| Parameter | Data Type | Required | Description |
|---|---|---|---|
| name | string | Yes | Unique identifier for the access log format |
| format | string | Yes | Defines the log format |
| escape | string | No | Specifies the escape method for log characters, possible values include: default, none, json |
| default | bool | No | Specifies 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
| Parameter | Data Type | Required | Description |
|---|---|---|---|
| name | string | Yes | Unique identifier for the shared memory zone |
| size | string | No | Defines the capacity size of the shared memory zone |
| size_unit | string | Yes | Specifies 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
custom_shared_zone follows the Synchronize automatically to other partitions option of the Global Config → Global Lua Modules page. When the option is disabled, it applies to the partition given with -p PARTITION_ID or -n PARTITION_NAME. When the option is enabled, edge2yaml imports the dictionaries into the default partition, where they replace the dictionaries of all other partitions, and an export reads them from the default partition.
On import, dictionaries are added or updated by name. Dictionaries that exist only in OpenResty Edge are kept.
Saving custom_shared_zone, dymetrics_size and dymetrics_size_unit per partition needs OpenResty Edge 26.12.1-1 or later and edge2yaml 1.2.84 or later. With an earlier OpenResty Edge, edge2yaml 1.2.84 saves and exports them through the global configuration, as earlier versions of edge2yaml do. Earlier versions of edge2yaml cannot save them in OpenResty Edge 26.12.1-1 or later, so upgrade edge2yaml together with OpenResty Edge.
Dynamic Metrics Shared Memory Size
The top-level keys dymetrics_size and dymetrics_size_unit set the dynamic metrics shared memory size (the Global Config → Dynamic Metrics Config page). They follow the Synchronize automatically to other partitions option of the Global Config → General page. When the option is disabled, they apply to the partition given with -p PARTITION_ID or -n PARTITION_NAME. When it is enabled, they are saved in the default partition and apply to all partitions.
Parameter Description
| Parameter | Data Type | Required | Description |
|---|---|---|---|
| dymetrics_size | number | No | Size of the dynamic metrics shared memory. null clears the value |
| dymetrics_size_unit | string | No | Unit of dymetrics_size, possible values are k, m, g |
A key that is absent from the file leaves the current value unchanged.
The general section of global_configs.yaml holds the settings of the General page and does not carry dymetrics_size, dymetrics_size_unit, or custom_shared_zone. If a file exported by an older version of edge2yaml still has these keys under general, they are ignored.
Configuration Example
dymetrics_size: 100
dymetrics_size_unit: m
Global User Variables
You can define multiple global variables, therefore variables are represented as an array.
Parameter Description
| Parameter | Data Type | Required | Description |
|---|---|---|---|
| name | string | Yes | Unique identifier for the variable |
| type | string | Yes | Data type of the variable, possible values are string, num, int, bool |
| default | string | Yes | Default 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