This package provides helper methods to create mackerel agent plugin easily.
Example of graph definition.
Graphs
is a type represents one graph and Metrics
is a type represents each line.
var graphdef = map[string]mackerelplugin.Graphs{
"memcached.connections": {
Label: "Memcached Connections",
Unit: "integer",
Metrics: []mackerelplugin.Metrics{
{Key: "curr_connections", Label: "Connections", Diff: false},
},
},
}
- FetchData
- fetch status data
- GetGraphDefinition
- output graph definition.
- GetTempfilename
- output temporally filename.
Many status values of popular middlewares are provided as counter. But current Mackerel API can accept only absolute values, so differential values must be caculated beside agent plugins.
Diff
of Metrics
is a flag wheather values must be treated as counter or not.
If this flag is set, this package calculate differential values automatically with current values and previous values, which are saved to a temporally file.
Some status values such as jstat
memory usage are provided as scaled values.
For example, OGC
value are provided KB scale.
Scale
of Metrics
is a multiplier for adjustment of the scale values.
var graphdef = map[string]mackerelplugin.Graphs{
"jvm.old_space": {
Label: "JVM Old Space memory",
Unit: "float",
Metrics: []mackerelplugin.Metrics{
{Name: "OGCMX", Label: "Old max", Diff: false, Scale: 1024},
{Name: "OGC", Label: "Old current", Diff: false, Scale: 1024},
{Name: "OU", Label: "Old used", Diff: false, Scale: 1024},
},
},
}