Label Formatting
The label-format
setting can be used to customize series labels displayed in the widget legend as an alternative to specifying a custom label for each series.
The default label-format
pattern is:
entity: metric: tags: statistics: period: dataType - forecastName: rate
Supported keywords in the label-format pattern are:
- entity
- metric
- tags – semicolon-separated list of all tag=value pairs
- tagName – semicolon-separated list of all tag names
- tagValue – semicolon-separated list of all tag values
- tags.tagName – value of tag with name
tagName
- statistics
- period
- dataType
- forecastName
- rate
- label – value of the
label
setting in the current series
label-format = entity # Display only the entity name in the legend [series] entity = nurswgvml007 metric = cpu_busy [series] entity = nurswgvml006 metric = cpu_busy |
The label-format
setting can be used to replace entity and metric names with labels loaded in metadata.
add-meta = true label-format = javascript: (meta.entity.label ? meta.entity.label : entity) + ": " + (meta.metric.label ? meta.metric.label : metric) + (tags+"" != 'null' ? ": " + tags : "") + (statistics && statistics != 'detail' ? ": " + statistics : "") + (period ? " - " + period : "") + (dataType ? ": " + dataType : "") + (rate ? ": ∇ " + rate : "") |
The label-format
setting can invoke built-in string functions to format series fields.
label-format = javascript:keepAfterLast(tags.logger, '.') #returns AuthenticationFilter [series] [tags] logger = com.axibase.app.web.AuthenticationFilter |
for m in metrics [series] label = @{keepAfterLast(m, '.')} metric = @{m} endfor |
Functions can be nested to apply multiple formats.
label-format = javascript:capitalize(replace(metric, '_', ' ')) #replace underscores with whitespace and capitalize all words [series] metric = swap_space_used #swap_space_used -> Swap Space Used |
Built-in string format functions:
keepAfter | Removes part of the string before the first occurrence of the given substring. |
keepAfterLast | Removes part of the string before the last occurrence of the given substring. |
keepBefore | Removes part of the string that starts with the first occurrence of the given substring. |
keepBeforeLast | Removes part of the string that starts with the last occurrence of the given substring. |
replace | Replace all occurrences of the given string in the original string with another string. |
capFirst | Capitalize first word. |
capitalize | Capitalize all words. |
lowerCase | Convert to lower case. |
upperCase | Convert to upper case. |
removeBeginning | Removes the given substring from the beginning of the string. |
removeEnding | Removes the given substring from the end of the string. |