TINE Docs
GitHub
  • Highlights
  • TINE
    • Install
  • GETTING STARTED
    • Quick start
    • Concept
      • Multiple Inlets and Outlets
      • Merge Records
      • Pipeline as Http Handler
    • Log config
  • Embedding TINE in Go
    • Use Recipe
    • Use API
  • Plugins
    • Inlets
    • Flows
    • Outlets
    • Extras
  • RECIPES
    • QRCode Generator
    • OLLAMA
    • OLLAMA Telegram Bot
    • Web Page Snapshot
    • Syslog Receiver
    • SQLite
    • RRD
Powered by GitBook
On this page
Edit on GitHub
  1. GETTING STARTED
  2. Concept

Merge Records

Generally, we want to observe the CPU usage and load average in a record at the same time. The following example demonstrates each inlet yielding its records, and the outlet printing them out individually in order.

[[inlets.cpu]]
    percpu = false
    interval = "1s"
    count = 3
[[inlets.load]]
    loads = [1, 5]
    interval = "1s"
    count = 2
[[outlets.file]]
    path = "-"
    format = "json"
    decimal = 2
{"load1":2.14,"load5":2.11}
{"total_percent":8.16}
{"total_percent":11.97}
{"load1":2.05,"load5":2.09}
{"total_percent":12.26}

Let's enhance the pipeline by introducing the [[flows.merge]]. This flow allows us to merge multiple records into a single record based on their _ts tag. The resulting record will be a combination of the merged records.

[[inlets.cpu]]
    percpu = false
    interval = "1s"
    count = 3
[[inlets.load]]
    loads = [1, 5]
    interval = "1s"
    count = 2
[[flows.merge]]
    wait_limit = "1s"
    name_infix = "_"
[[outlets.file]]
    path = "-"
    format = "json"
    decimal = 2
{"_ts":1723255081,"cpu_total_percent":8.16,"load.load1":1.80,"load.load5":2.00}
{"_ts":1723255082,"cpu_total_percent":17.14,"load.load1":1.81,"load.load5":2.00}
{"_ts":1723255083,"cpu_total_percent":13.33}

[[flows.merge]] promotes the _ts tag to a field that has same name _ts and renames all other fields with the origin _in tag value followed by a underscore and the original name. This operation is conceptually similar to joining tables in a relational database management system (RDBMS). It can be thought of as performing a query:

SELECT
    _ts, cpu.total_usage, load.load1, load.load5
FROM
    cpu,
    load
WHERE
    cpu._ts = load._ts
PreviousMultiple Inlets and OutletsNextPipeline as Http Handler

Last updated 9 months ago

A pipeline with multiple inlets and merge