You can append specific data to an existing field or a field that does not exist by using the processor_appender plug-in. You can also add template variables to the value of a field. In most cases, this plug-in is used together with plug-ins that monitor time series data, such as input_prometheus and input_system_v2. This way, you can append specific data to Prometheus data that is pulled.

Notice Only Logtail V0.16.66 or later supports the processor_appender plug-in.

Parameters

The following table describes the parameters that you can specify in the detail parameter if you set the type parameter to processor_appender.

Table 1. Plug-in parameters
Parameter Type Required Description
Key string Yes The name of the field.
Value string Yes The data that you want to append to the field. Log Service allows you to add template variables to the value of a field. For more information, see Table 2.
SortLabels boolean No If you want to add the __labels__ field, you must set the Key parameter to __labels__. Then, you must set the SortLabels parameter to true to sort the appended labels in alphabetical order. Otherwise, disordered labels cause errors when queries are performed. Default value: false.
Table 2. Template variables
Template variable Description Configuration example Sample result
{{__ip__}} This variable is replaced by the IP address of the server where Logtail resides. "Value": "{{__ip__}}" "Value": "192.0.2.1"
{{__host__}} This variable is replaced by the hostname of the server where Logtail resides. "Value": "{{__host__}}" "Value": "logtail-ds-xdfaf"
{{$xxxx}} This variable is used to reference an environment variable and must start with a dollar sign ($). This variable is replaced by the value of the environment variable. "Value": "{{$WORKING_GROUP}}" "Value": "prod"

Example

The IP address of the server where Logtail resides is 192.0.2.1, the hostname is david, and the value of the environment variable WORKING_GROUP is prod. The following example shows how to append the preceding data to the __labels__ field:
  • Raw log entry
    "__labels__":"a#$#b"
  • Logtail plug-in configurations for data processing
    {
      "processors":[
        {
          "type":"processor_appender",
          "detail": {
            "Key": "__labels__",
            "Value": "|host#$#{{__host__}}|ip#$#{{__ip__}}|group#$#{{$WORKING_GROUP}}",
            "SortLabels": true
          }
        }
      ]
    }
  • Result
    "__labels__":"a#$#b|group#$#prod|host#$#david|ip#$#192.0.2.1"