DataScript: avi.vs.analytics.gauge

DataScript

Function avi.vs.analytics.gauge ( metric_name, [operation], [value] )
Description Increments, decrements, sets or clears the named gauge metric.

Refer to the User-defined Metrics article for important details.
Events HTTP_REQ
HTTP_RESP
RESP_FAILED
Parameter metric_name is a string value chosen by the user to identify the gauge metric.

operation is a numeric which may take on one of four values:

  1. avi.vs.analytics.INCR — Increments the gauge metric by value.
  2. avi.vs.analytics.DECR — Decrements the gauge metric by value. If the current value of the gauge metric is less than value, this operation resets the gauge metric to 0.
  3. avi.vs.analytics.SET — Sets the gauge metric to value.
  4. avi.vs.analytics.CLEAR — Clears the gauge metric to 0. The value parameter is ignored.
value is the increment/decrement amount or desired setting of the metric. If value is not specified for these operations, it defaults to 1.

Notes

  • If the operation is not specified, it defaults to avi.vs.analytics.INCR.

  • The following applies to all invocations of avi.vs.analytics.gauge.

    1. If metric_name has never been defined, the function will define it and set the metric_type to avi.vs.analytics.METRICTYPE_GAUGE. Thereafter, the function will perform the indicated operation as modified by value.
    2. If metric_name has been defined before, but has a metric_type other than avi.vs.analytics.METRICTYPE_GAUGE, the function will log an error and the request/response causing this function call will be ended prematurely.
Returns No value returned
Related avi.vs.analytics.get_metric()
Examples 1. Create a gauge-type metric with name “speedo” and add 42 to it. If the gauge-type metric is not present, then create it and initialize it with default value, 0.

avi.vs.analytics.gauge(“speedo”, avi.vs.analytics.INCR, 42)


2. Increment the gauge-type metric named "speedo." by 1.

avi.vs.analytics.gauge(“speedo”, avi.vs.analytics.INCR)