23 Mar 2024
	
		
		06:09 PM
	
	
	
	
	
	
	
	
	
	
	
	
	
	
 - last edited on 
    
	
		
		
		10 May 2024
	
		
		03:23 PM
	
	
	
	
	
	
	
	
	
	
	
	
	
	
 by 
				
		
		
			Michal_Gebacki
		
		
		
		
		
		
		
		
	
			
		
In EF2, typically I have seen that when there is a need to convert the value of a metric, it is done with a "key: func" definition.
Is it safe to do the calculation with the metric. And if so, how is it done, as I have found no example?
Solved! Go to Solution.
23 Mar 2024 06:52 PM - edited 23 Mar 2024 11:04 PM
Hi Antonio,
Which data source are you using? They do not all have the same functionality.
In general, using a metric selector in the dashboard/alert/UA section is always possible.
23 Mar 2024 08:36 PM
It's WMI. Value is a multiple of 100, so I would like to ingest the real value, dividing it by 100 first...
23 Mar 2024 11:04 PM
For that data source you can't do anything in the data source (with SQL you can handle it by adjusting your query). You'd have to handle it in the metric metadata section, such as this:
metrics:
  - key: my_old_metric
    metadata:
      displayName: My Old Metric
      description: My Old metric, it is large
      unit: Count
  - key: func:my_new_metric
    metadata:
      displayName: My New Metric
      description: My Old metric, but divided by 100
      unit: Count
    query:
      metricSelector: (my_old_metric)/(100)
24 Mar 2024 02:31 PM
Thanks @Mike_L ,
It was the "key: func" I was referring to...
I believe it consumes 0.002 DDUs, because it's two data points, right? Because I'll be ingesting a lot of them, I'll maybe have to go with the value and then do calculations in the UI...
25 Mar 2024 06:46 PM
Key function metrics only provide an easy way to do metric selectors. They don’t actually store any data, so they don’t consume DDUs.
25 Mar 2024 07:25 PM
That's very good to know. Didn't know. Thanks @Mike_L !