Skip to main content
Version: 2.3.x

Examples

Basic Scenarios

Scenario 1: Get the last value of tags every 60 seconds

  • Set sample and send parameters.

    Set pollingInterval < sendOut time to ensure that all uploads will be sampled at least once.

    mg-overview

  • Select tags.

    mg-overview

  • Update format.

    Format:

    {
    (.tagName): .dataValue
    }
    • because we only need last values of tags every 60 seconds, so you may not need array to buffer values of tags
    • Each tagName's value will be overwritten by the last value

    mg-overview

  • Check the result.

    The message group will send the following message to the target every 60 seconds.

    {
    "cpuUsage": 12,
    "memoryUsage": 51
    }

Scenario 2: Get all values of tags every 60 seconds

  • Set sample and send parameters.

    • Set pollingInterval = 0 to enable subscribe mode to subscribe to all tags published from origin.
    • Set send out time = 60 to publish the message every 60 seconds.

    mg-overview

  • Select tags.

    mg-overview

  • Update the format.

    default format already includes an array for each tag to store all values.

    Here is another format to reduce the message size.

    Format:

    {
    (.srcName+"_"+.tagName): [
    .dataValue
    ]
    }
  • Check the result.

    The message group will send the following message to the target every 60 seconds.

    {
    "status_cpuUsage": [
    11,
    9
    ],
    "status_memoryUsage": [
    51,
    51
    ]
    }

Advanced Scenarios

  • Calculating values from data

    • Example tag:
      {
      "dataType": "uint64",
      "dataValue": 11,
      "prvdName": "system",
      "srcName": "status",
      "tagName": "cpuUsage",
      "ts": 1581659603000000
      }
      format:
      {
      value: ( .dataValue + 1000 )
      }
      result:
      {
      "value": 1011
      }
  • Using conditionals

    • Example tag:
      {
      "dataType": "uint64",
      "dataValue": 11,
      "prvdName": "system",
      "srcName": "status",
      "tagName": "cpuUsage",
      "ts": 1581659603000000
      }
      format:
      {
      stable: ( if .dataValue > 80 then false else true end )
      }
      result:
      {
      "stable": true
      }

Last updated on 2022-07-22 by Cecilia Fernandes