evalMetrics each seconds


I have a cronJob which trigger a function to generate a value for each second in the last 10 minutes.
I want to check the value of this data and for each second I try to run an evalMetrics:

var value;
var x=myType.evalMetrics({

         start: inputTimestamp,



         interval: "SECOND",

         expressions: [val.my_metric]

var result=x.result.get(val.id).my_metric.m_data[0];

Where my_metric.json :

  "expression":"costomSimpleMetric > 0"

If I run manually the code to generate value for a specific timerange I obtain the correct value but if I use the cronJob don’t work.

If I remove all the code (the eval metric)and I set statically var value=1; also with cronJob it works.


  1. Your snippet indicates that you are using the same start and end, so the result (if any) isn’t meaningful. Keep in mind that throughout C3 timeRanges are always end-exclusive (only way to capture the very last instant before a given date)
  2. Why do you need to run this evalMetrics every second, why not run it for the entire period?
  3. I don’t understand what your cronjob does: it evaluates a metric, then what happens?


I used the same value for start and end in order to retrive a value for inputTimestamp second.
I need to run for every second because I need to validate value for each second with if condition, in a timerange I can have different value for my_metric .
The cronJob call a function which get value a priori. After I need to validate it (the function for validation is called by the function to get value)

  1. Not entirely sure why it works, I suspect it should not: if you want 1 second of data, evaluate between start and start.plusSeconds(1)
  2. I recommend you do a single evalMetrics for the entire period, and then iterate on the .data() array, it will be much much (much) more efficient
  3. I still don’t understand the cronJob function, but that’s not the point of your message


I change my code, actually I run the evalMetric only once for a specific timerange.
For each second I get the value from it and check it.

//code executed only once for a validTimeRange
var flame = my_type.evalMetrics({
    start: validTimeRange.start,
    end: validTimeRange.end,
    interval: "SECOND",
    expressions: [val.my_metric]


//code executed for each value in values/flame (length is the same)
_.each(_.zip(values.data,flame.data), function (tuple) {
      var value= (tuple[1] > 0) ? tuple[0]: -0.1 ;

The problem persist.

EDIT: I fixed the index (copy&paste problem


Ok looks fine now, anything else?