Counter Group Monitor
BACKEND SCRIPT
Monitor counter group activity.
Get called when metrics related to a counter group are computed and stored.
Structure
Counter Group Monitor skeleton script
Table cg_monitor
The table consists the following
counter_guid | String or function returning string | Counter Group to attach to for monitoring |
---|---|---|
onbeginflush | engine , timestamp | Before starting to flush all metrics to db |
onflush | engine, timestamp, key, arrayofmetrics | Called for each key as they are being flushed |
onendflush | engine | After all keys have been flushed for this interval |
onbegintopperflush | engine, timestamp, meter | Before flushing toppers for this meter |
ontopperflush | engine , key, metric | Called for each topper item |
onendtopperflush | engine , meter | After topper flush |
onupdate | engine, timestamp, key, arrayofmetrics | As each update happens (1sec resolution) |
onnewkey | engine, timestamp, key | A new key was discovered within the stream window. |
onmetronome | engine , timestamp, tick_count, tick_interval | called every second ( Tick Interval) |
Functions Reference
Function onbeginflush
Purpose
Before a counter group is flushed to the Trisul database on the Hub node. Trisul is a streaming analytics system. By default every 60 seconds the analytics are snapshotted and sent to the database node (hub). The onbeginflush function is therefore called every 60 seconds.
When called
When an flush operation is about to start. The sequence goes
-- operation is invoked every 60 seconds by default
--
onbeginflush(..)
onflush(..)
onflush(..)
onflush(..)
..
..
onendflush(..)
Parameters
engine | An engine object | use this object to add metrics, counter items, or counter items into the Trisul framework |
---|---|---|
timestamp | Timestamp | Timestamps seconds tv_sec |
Return value
Ignored
Example
Purpose
Custom processing before each counter item is flushed. Perhaps write to your own tools or logfiles.
When called
Just before each counter item is flushed to the database. The maximum delay between getting a onnewcounter item
and a corresponding onflush(..)
for that counter item is 60 seconds.
Parameters
engine | An engine object | use this object to add metrics, counter items, or counter items into the Trisul framework |
---|---|---|
timestamp | Timestamp | Timestamps seconds tv_sec |
key | string | the key identifying the counter item |
arrayofmetrics | array of numbers | array of metrics. array item 0 refers to meter 0 and so forth |
Return value
Ignored
Example
Function onflush
Purpose
Custom processing before each counter item is flushed. Perhaps write to your own tools or logfiles.
When called
Just before each counter item is flushed to the database. The maximum delay between getting a onnewcounter item
and a corresponding onflush(..)
for that counter item is 60 seconds.
Parameters
engine | An engine object | use this object to add metrics, counter items, or counter items into the Trisul framework |
---|---|---|
timestamp | Timestamp | Timestamps seconds tv_sec |
key | string | the key identifying the counter item |
arrayofmetrics | array of numbers | array of metrics. array item 0 refers to meter 0 and so forth |
Return value
Ignored