Search code examples
azure-monitor-workbooks

Is it possible to have calculated columns in metrics resource


I'm trying to divide one column from metrics by another to find percentage of used Azure files but can not figure out if it's possible to do. Example is below where I want to have a new calculated column which divides column called File capacity by column called File Share Capacity.

enter image description here


Solution

  • In the metrics directly no, as metrics itself doesn't have that (yet?)

    In workbooks, yes, you can do this, using a "merge" data source, which allows addition of custom calculated columns. (this is something we'd like to support directly on any metrics/query without using merge but hasn't worked its way up on to the todo list behind everything else)

    1. configure your metrics step (make sure the metric step is set to "grid" visualization)
    2. after your metrics step, add a new query step.
    3. choose data source "merge"
    4. click "add merge", and in the popup that appears choose "duplicate table" and choose the metric created in step 0
      • you should now see a grid of all of the fields in the table with their original name and what they'll be named after the merge
      • at this point, remove any columns you can remove any columns you don't need
      • and i'd suggest naming the rest of them nice easy names to use in steps later
    5. click "add new item" in the toolbar
    6. you'll get a new window for adding a new column and how to populate its rows
      • commonly this is used to if/then/else between values, but you'll just have one row here
      • in the row for conditions, click "edit" in the default row
      • a popup will appear, probably with a bunch of things disabled.
      • but one of the options there is "value from" and you can choose "expression"
    7. after choosing "expression" you can type in the expression you want

    for mine, i couldn't repro it on exactly your metrics, but i did this: adding the calculated column

    and got a grid (which i then set all the standard format options on to make it similar to the metrics grid (in group by settings group by sub, name by name, expand top level. in column settings, set the group by column renderer to resource, hide sub, name columns, set the error rate column to percent and 5 decimals) and i get this: result

    you can then go to the original metrics step in your workbook, and use conditional visibility settings to hide the metrics step.