request-id

This Plugin can be used to track API requests.

note

The Plugin will not add a unique ID if the request already has a header with the configured header_name.

request-id - 图2caution
  • Please read this documentation before deciding to use the snowflake algorithm. Once it is configured, you cannot arbitrarily change the configuration. Failure to do so may result in duplicate IDs.
NameTypeRequiredDefaultDescription
enablebooleanFalsefalseWhen set to , enables the snowflake algorithm.
snowflake_epocintegerFalse1609459200000Starting timestamp in milliseconds. Default is 2021-01-01T00:00:00Z and supports to a 69 year time until 2090-09-0715:47:35Z.
data_machine_bitsintegerFalse12Maximum number of supported machines (processes) 1 << data_machine_bits. Corresponds the set of workIDs and in the snowflake definition. Each process is associated to a unique ID. The maximum number of supported processes is pow(2, data_machine_bits). So, for the default value of 12 bits, it is 4096.
sequence_bitsintegerFalse10Maximum number of generated ID per millisecond per node 1 << sequence_bits. Each process generates up to 1024 IDs per millisecond.
data_machine_ttlintegerFalse30Valid time in seconds of registration of data_machine in etcd.
data_machine_intervalintegerFalse10Time in seconds between data_machine renewals in etcd.

To use the snowflake algorithm, you have to enable it first on your configuration file :

conf/config.yaml

Once you have configured the Plugin as shown above, APISIX will create a unique ID for each request you make:

To disable the request-id Plugin, you can delete the corresponding JSON configuration from the Plugin configuration. APISIX will automatically reload and you do not have to restart for this to take effect.