Meta Data

Request metadata fields from the server by adding add-meta = true setting to the widget configuration.

Use these fields for several common use cases:

  • Embed extended entity or metric information in series legend labels.
  • Calculate derived metrics based on entity tags.
  • Set [threshold] value or treemap sizes based on entity tags.

Metadata Object

If add-meta is set to true, the response contains metadata for the requested metric and entity.

Sample metadata object:

{
  "metric": {
    "name": "docker.cpu.avg.usage.total.percent",
    "enabled": true,
    "dataType": "FLOAT",
    "label": "Docker Cpu Avg Usage Total %",
    "persistent": true,
    "tags": {
      "table": "Docker Container Summary"
    },
    "retentionDays": 0,
    "seriesRetentionDays": 0,
    "invalidAction": "NONE",
    "versioned": false,
    "interpolate": "LINEAR"
  },
  "entity": {
    "name": "dfab04daa838e9795f6246c5ba9f37412213ca897bfe056baf3b71a11d456370",
    "enabled": true,
    "label": "db-test-mysql-5.7",
    "tags": {
      "env.mysql_version": "5.7.18-1debian8",
      "image-name": "mysql",
    }
  }
}

The loaded object can be subsequently accessed in label settings and value expressions.

Label Settings

The metric and entity metadata object properties can be accessed in the following settings:

label-format = meta.entity.tags.app

Available placeholders:

  • meta.metric.field_name
    Metric fields such as label, dataType.
  • meta.entity.field_name
    Entity fields such as label, timeZone.
  • meta.metric.tags.tag_name
    Metric tag with name tag_name.
  • meta.entity.tags.tag_name
    Entity tag with name tag_name.

If the tag name contains special characters, use meta.entity.tags['tag_name'] syntax, for example meta.entity.tags['image-name'].

Metadata Functions

Function Description
meta('alias') Returns meta object for series with the specified alias.
meta() Returns meta object for the current series.
entityTag('alias', 'tag_name') Returns entity tag value for series with the specified alias.
entityTag('tag_name') Returns entity tag value for the current series.
metricTag('alias', 'tag_name') Returns metric tag value for series with the specified alias.
metricTag('tag_name') Returns metric tag value for the current series.

The functions can be invoked within the following settings:

  • value
  • series-value
  • display
  • enabled
  • alert-expression
  • size
  • color
  • node-value (graph widget)
  • link-value (graph widget)
  • link-alert-expression (graph widget)
  • node-alert-expression (graph widget)

The metadata object can be accessed by specifying the path to the property.

meta().metric.label        -> Docker Cpu Avg Usage Total %
meta().metric.tags.table   -> Docker Container Summary
meta().entity.label        -> db-test-mysql-5.7

If the tag name contains special characters, such as 'image-name', enquote the tag name and use brackets to access its value.

meta().entity.tags['image-name']    -> mysql

Note

In label settings use meta., in functions, use meta(). syntax.

Function Examples

alert-expression = value >= meta().metric.maxValue
series-value= meta().entity.tags.stream
alert-expression = (1 - (meta().entity.tags.elevation_ft - value)/meta().entity.tags.elevation_ft) > 0.97
color = ((1 - (meta().entity.tags.elevation_ft - value)/meta().entity.tags.elevation_ft)*100 >= 100) ? 'black': (((1 - (meta().entity.tags.elevation_ft - value)/meta().entity.tags.elevation_ft)*100 >= 95))?'orange':'steelblue'
series-value = meta().entity.tags.crest_elevation_ft  - value
display = +meta().entity.tags["storage_capacity_ac-ft"] > 1000000
alert-expression = value >= meta().metric.maxValue
[series]
    entity = nurswgvml007
    metric = cpu_busy
    alert-style = fill: red
    alert-expression = value > metricTag('threshold_value')
[series]
    label = nomalized 502
    value = value('502') / entityTag('502', 'cpu_count')

Debugging

To print out the metadata object in the developer console, using the console.log() function.

enabled = console.log(meta()); return true;