Compound metric get field from type


#1

Hi,
I have my_type in which there is a field simple_metric_name : string.
I have also a simple metric with same name simple_metric_name.
What I would like to know is how I can create a compound metric like this:

{
  "id": "my_compound_id",
  "name": "my_compound_name",
  "expression": "my_type.simple_metric_name > 0"
}

I don’t know how I can access to my_type.simple_metric_name.
How I can do it or something like this?

Thanks


#2

You can define one simple metric per value of your field simple_metric_name like this:

[
  {
    "id": "simple_metric_gt_0_1",
    "name": "simple_metric_gt_0_1",
    "srcType": "my_type",
    "expression": "expression for simple metric 1 > 0"
  },
  . . .
]

Then combine them in your Compound metric as follows:

{
  "id": "my_compound_id",
  "name": "my_compound_name",
  "expression": "simple_metric_gt_0_1 || simple_metric_gt_0_2 || simple_metric_gt_0_3 ..."
}

#3

This should be a good solution but in my case I can’t use it, there is a way to access a field of type defined in the same package from compound metric?


#4

no you have to expose your field in a simple metric that use this one the final compound metric.


#5

ok, could I create a simpleMetric with an actionDecl that call a function in which I pass the value of field in my_type?
E.g.

#my_type
name_value: string

#My_desidered_simple_metric
{
    "id": "my_id",
    "name": "my_name",
    "srcType": "my_type",
    "actionDecl": {
       "action": "do_something(my_type.name_value)"
     }
}

#6

yeah with actionDecl you can do what ever you wish, the down side is that it’s a js code thus very slow compared to pure metrics with expressions.