Tags are fields in Simple Log Service that identify data, such as source IP addresses and file paths. LoongCollector automatically adds tags when it collects data. This topic describes how to add, delete, and rename these tags.
Limits
This feature is supported only in LoongCollector 3.0.10 and later. If you use Logtail or an earlier version of LoongCollector, upgrade to the latest version of LoongCollector.
This feature modifies the names and storage locations of tags. If your log consumption process depends on the modified tag fields, compatibility issues may occur.
Tag classification
A tag field is similar to a field index and contains a key and a value. For example, in __tag__:__inode__:263554, __tag__:__inode__ is the tag name (key), and 263554 is the tag value.

Tags are classified into two main types based on their source:
Agent-related: These tags are related to the collection agent itself and do not depend on plugins. Examples include IP addresses and hostnames.
Input plugin-related: These tags depend on input plugins. The plugins provide and enrich the logs with relevant information, such as file inodes, read offsets, pod names, namespaces, and image names.
Billing
Tag fields are not charged. However, fees are incurred if you set them as index fields. For more information about billing standards, see Billing. For more information about how to set and delete field indexes, see Create an index.
Create or modify a tag name
LoongCollector standardizes tags and provides a tag processing feature. You can configure advanced parameters to add, delete, and rename tags.
Agent-related tags
These tags do not depend on any input plugins and are global parameters. You can add configuration parameters when you create or modify a collection configuration. This topic uses modifying a collection configuration as an example. For more information about how to create a collection configuration, see Create a collection configuration.
Log on to the Simple Log Service console. In the Projects section, click the one you want.

Find your logstore, and select . Click Integrate Now. In this example, Regular Expression - Text Log is used, which means text logs will be parsed using regular expression matching.

In the Logtail Configuration list, click the target Logtail configuration.
On the Logtail Configuration page, click Edit.
In the Global Configurations section, click Other Global Configurations. Click
next to Advanced Parameters to configure agent-related tags.{ "PipelineMetaTagKey": { "HOST_NAME": "sourceName", "AGENT_TAG": "__default__", "HOST_ID": "__default__", "CLOUD_PROVIDER": "__default__" } }
Parameter
Type
Required
Default
Example
Description
PipelineMetaTagKey
object
No
empty
{"HOST_NAME":"__hostname__"}
The key is the tag parameter name, and the value is the tag's field name in the log. If the value is __default__, the default value is used. If the value is an empty string, the tag is deleted. The configurable tags are as follows:
HOST_NAME: The hostname. Added by default. The default value is "__hostname__".
AGENT_TAG: The custom identifier. Added by default. The default value is "__user_defined_id__". This parameter applies only to machine groups with custom identifiers and not to machine groups with IP addresses.
HOST_ID: The host ID. Not added by default. The default value is "__host_id__".
CLOUD_PROVIDER: The cloud provider. Not added by default. The default value is "__cloud_provider__".
Input plugin-related tags
These tags are closely related to input plugins and are part of the input plugin configuration. You can set them using the advanced parameters of the input configuration. You can add configuration parameters when you create or modify a collection configuration. This topic uses modifying a collection configuration as an example. For more information about how to create a collection configuration, see Create a collection configuration.
Currently, this feature applies only to the file collection and the new standard output collection plugins.
Log on to the Simple Log Service console. In the Projects section, click the one you want.

Find your logstore, and select . Click Integrate Now. In this example, Regular Expression - Text Log is used, which means text logs will be parsed using regular expression matching.

In the Logtail Configuration list, click the target Logtail configuration.
On the Logtail Configuration page, click Edit.
In the Input Configurations section, click Other Input Configurations. Click
next to Advanced Parameters to configure input plugin-related tags.ImportantIf you set
FileOffsetKeyin the input configuration, the Auto Generate Index feature of the collection configuration sets this tag field (__file_offset__) as an index field. For more information about billing, see Billing. If you do not need to create an index for this field, you can delete the index but keep the tag field. For more information, see Update an index.This tag is not displayed at the top of the query analysis page. It has unique properties and features, and its name is
__file_offset__. The following figure shows an example:
{ "Tags": { "FileInodeTagKey": "__default__", "FilePathTagKey": "__default__" }, "FileOffsetKey":"__default__" }
Parameter
Type
Required
Default
Example
Description
Tags
object
No
empty
{"FileInodeTagKey":"__inode__"}
The key is the tag parameter name, and the value is the tag's field name in the log. If the value is __default__, the default value is used. If the value is an empty string, the tag is deleted. The configurable tags are as follows:
FileInodeTagKey: The file inode. Not added by default. The default value is "__inode__".
FilePathTagKey: The file path. Added by default. The default value is "__path__".
The following parameters are valid only when the EnableContainerDiscovery parameter is set to true.
K8sNamespaceTagKey: The namespace of the container where the file is located. Added by default. The default value is "_namespace_".
K8sPodNameTagKey: The name of the pod where the file is located. Added by default. The default value is "_pod_name_".
K8sPodUidTagKey: The UID of the pod where the file is located. Added by default. The default value is "_pod_uid_".
ContainerNameTagKey: The name of the container where the file is located. Added by default. The default value is "_container_name_".
ContainerIpTagKey: The IP address of the container where the file is located. Added by default. The default value is "_container_ip_".
ContainerImageNameTagKey: The image of the container where the file is located. Added by default. The default value is "_image_name_".
FileOffsetKey
string
No
empty
__file_offset__
The tag for the log's position in the file. Not added by default. The default value is __file_offset__. If the value is __default__, the default value is used. If the value is an empty string, the tag is deleted.
ImportantIf the EnableLogPositionMeta parameter exists at the same time as the Tags.FileInodeTagKey or FileOffsetKey parameter, the EnableLogPositionMeta parameter is ignored.
Delete a tag
To delete a tag, set its value to an empty string in the advanced parameter configuration.
In the following example, the value of AGENT_TAG is set to an empty string, so the tag is not displayed. For more information, see Create or modify a tag name.
{
"PipelineMetaTagKey": {
"HOST_NAME": "sourceName",
"AGENT_TAG": "",
"HOST_ID": "__default__",
"CLOUD_PROVIDER": "__default__"
}
}View tags
In the Projects section, click the one you want.

To the right of the target Logstore, click the
icon and select Search & Analysis to view the logs of the current Logstore.
As shown in the following figure, the tag fields are displayed in the top row of the log page.

__tag__:sourceName: The tag key is set to
PipelineMetaTagKey.HOST_NAME. The default value is__tag__:__hostname__. In this example, the value is set to__tag__:sourceName, which represents the source hostname.__tag__:__host_id__: The tag key is set toPipelineMetaTagKey.HOST_ID. The default value__host_id__is used for this parameter.__tag__:__cloud_provider__: The tag key is set toPipelineMetaTagKey.CLOUD_PROVIDER. The default value__cloud_provider__is used for this parameter.__tag__:__user_defined_id__: The tag key is set toAGENT_TAG. This parameter applies only to machine groups with custom identifiers and not to machine groups with IP addresses.
__tag__:__inode__: The tag key is set toTags.FileInodeTagKey. The default value__inode__is used for this parameter.__tag__:__path__: The tag key is set toTags.FilePathTagKey. The default value__path__is used for this parameter.__file_offset__: The tag key is set toFileOffsetKey. The default value__file_offset__is used for this parameter.ImportantIf you set
FileOffsetKeyin the input configuration, the Auto Generate Index feature of the collection configuration sets this tag field (__file_offset__) as an index field. For more information about billing, see Billing. If you do not need to create an index for this field, you can delete the index but keep the tag field. For more information, see Update an index.This tag is not displayed at the top of the query analysis page. It has unique properties and features, and its name is
__file_offset__. The following figure shows an example:
Modify a tag value
Currently, this feature applies only to the file collection and the new standard output collection plugins.
You can use the Structured Process Language (SPL) processing plugin to manage tag fields and modify tag values. When you use SPL to process tag fields, follow these rules:
SPL uses the
__tag__:prefix to identify tags and automatically adds this prefix to all tag fields during processing. Therefore, when you write an SPL statement, make sure that the field name includes this prefix to correctly reference tag-related data.In the SPL output, all fields with the tag prefix are identified as tags. You can use this method to add tags.
This topic describes how to add an SPL statement when you modify a collection configuration, using __tag__ :sourceName as an example. To query logs more easily, you can change the value to user_module in the log collection configuration to distinguish different logs by application name. For more information about how to add an SPL statement when you create a collection configuration, see Add an SPL statement when you create a collection configuration.
In the Projects section, click the one you want.

On the tab, click the > icon next to the logstore you want, and then choose .

In the Logtail Configuration list, find the required Logtail configuration and click Manage Logtail Configuration in the Actions column.
Click Edit at the top of the page. In the Processing Configurations section at the bottom of the page, set Processing Method in Processing Configurations to SPL, and then click Save.
Set the SPL statement to the following:
* | extend "__tag__:sourceName"='user_module'To the right of the target Logstore, click the
icon and select Search & Analysis to view the logs of the current Logstore.The value of the
__tag__:sourceNamefield isuser_module.
References
You can set a normal index field as a tag field. Tag fields can be shown or hidden. For more information, see Tag fields.