All Products
Search
Document Center

Simple Log Service:Build dictionaries and tables for data enrichment

Last Updated:Sep 14, 2026

Dictionaries and tables are the two main data structures for data enrichment. This topic describes common methods for building these data structures and compares the advantages and disadvantages of the different methods.

Dictionary building

  • Direct Build

    e_dict_map({"400": "error", "200": "ok", "*": "other"}, "status", "message")
  • Building resources from a task configuration

    e_dict_map(res_local("http_code_map"), "status", "message")

    http_code_map is an advanced task configuration item with the following value:

    {"400": "error", "200": "ok", "*": "other"}
  • Build from a Table

    Use the tab_to_dict function to build a dictionary from a table. For more information about how to build a table, see the Build tables section in this topic.

    e_dict_map(tab_to_dict(tab_parse_csv("status_code,status_info\n400,error\n200,ok\n*,other"), "status_code", "status_info"), "status", "message")
  • Build a dictionary from a dictionary function

    e_dict_map(dct_make("400", "error", "200",  "ok", "*",  "other"), "status", "message")
  • Building on other expressions

    e_dict_map(json_parse(v("http_code_map")), "status", "message")

    The mapping relationship is obtained from the http_code_map field in the source log.

The following table compares the different methods for building dictionaries.

Method

Advantages

Disadvantages

Direct build

Intuitive, simple, and convenient.

The rules are static and inflexible, and can become lengthy if the content is extensive.

You can build resources based on the task configuration.

This method is recommended when the dictionary contains a large amount of data that is frequently modified. It is easy to maintain.

It is not easily extensible or reusable across tasks, nor does it support auto-refresh.

Build from a table

Used in advanced scenarios. This method provides a more flexible maintenance mechanism.

This method requires you to build and maintain the corresponding table, which is a complex process.

Build a dictionary from a dictionary function

Dynamically builds a dictionary based on logic. Suitable for specific scenarios.

This method is advanced and difficult to maintain.

Building from other expressions

Dynamically extracts mapping relationships from fields in log events. Suitable for specific scenarios.

This method is advanced and difficult to maintain.

Table building

  • Build from text

    e_table_map(tab_parse_csv("city,name,age\nshanghai,aliyun,10\ncity:nanjing,Maki,18"), "name",["city", "age"])
  • Build a table from an ApsaraDB RDS resource

    e_table_map(tab_parse_csv(res_rds_mysql(...database="db", table="city")), "name",["city", "age"])

    The content of the city table in ApsaraDB RDS is as follows:

    content,name,age
    shanghai,aliyun,10
    nanjing,Maki,18
  • Build a table from another Logstore resource

    e_table_map(res_log_logstore_pull(..., project="project_name", logstore="logstore_name", fields=["city","name","age"]),, "name",["city", "age"])

    The corresponding log events in the Logstore are as follows:

    "Log 1"
    {
      "city": "shanghai",
      "name": "aliyun",
      "age": "10"
    }
    "Log 2"
    {
      "city": "city:nanjing and data > 100",
      "name": "Maki",
      "age": "18"
    }

The following table compares the different methods for building tables:

Method

Advantages

Disadvantages

Create from text

Intuitive, simple, and convenient.

Extensive content can result in lengthy rules that are difficult to maintain, extend, or reuse.

Create from RDS resources

  • Recommended when the table contains a large amount of data that is frequently modified. It is easy to maintain.

  • Supports auto-refresh.

  • Supports reuse across tasks.

Requires a connection to an external ApsaraDB RDS resource. The configuration process is complex.

Build a table from another Logstore resource

Supports real-time reads and provides a flexible maintenance mechanism. Used in advanced scenarios.

Requires a connection to another Logstore. The configuration process is complex.