What is the best way to get execution_duration?

alerting

(Dan Becker) #1

I'd like my watcher result context to contain execution_duration as well as the execution_time. Is there any way to extract that from the result? Or perhaps there is a way to grab it from the watcher watch stats?


(Alexander Reelsen) #2

Hey there,

you can use the watch history to find out more about this, see the Monitoring Watch Exection section in our documentation.

If you query the history, you will find a field called execution_duration, which is the duration in milliseconds. Looks like this in the _source

_source: {
          watch_id: "$WATCH_NAME",
          state: "executed",
          trigger_event: {
            type: "schedule",
            triggered_time: "2016-02-24T23:02:55.540Z",
            schedule: { scheduled_time: "2016-02-24T23:02:55.404Z" }
          },
          input: {
              ...
            }
          },
          result: {
            execution_time: "2016-02-24T23:02:55.540Z",
            execution_duration: 4,
...

Hope this helps.

--Alex


(Dan Becker) #3

Thanks Alex. This is not as good as having execution_duration in the watcher resul, as I will likely gave to add an action that queries the watch history, but it does provide a usable solution.

Thanks, beckerdo


(system) #4