pub struct Variable<'a> {
pub scope: Option<Scope>,
pub name: &'a str,
pub value: f64,
}
Expand description
Define and publish variables and constants.
VARIABLE [SCOPE] name = value
It defines a variable that can be used in alarms.
This is also used for setting constants (like the max connections
a server may accept).
Examples:
use netdata_plugin::{Variable, Scope};
let v = Variable {
scope: Some(Scope::GLOBAL),
name: "variable_name",
value: 3.14f64,
};
assert_eq!(v.to_string(), "VARIABLE GLOBAL variable_name = 3.14");
Variables support 2 Scopes:
- GLOBAL or HOST to define the variable at the host level.
- LOCAL or CHART to define the variable at the chart level. Use chart-local variables when the same variable may exist for different charts (i.e. Netdata monitors 2 mysql servers, and you need to set the max_connections each server accepts). Using chart-local variables is the ideal to build alarm templates.
The position of the VARIABLE line output, sets its default scope
(in case you do not specify a scope). So, defining a VARIABLE before
any CHART, or between END and
BEGIN (outside any chart), sets GLOBAL
scope, while defining a VARIABLE just after a CHART or
a DIMENSION,
or within the BEGIN - END block of a chart, sets LOCAL
scope.
These variables can be set and updated at any point.
Variable names should use alphanumeric characters, the .
and the _
.
The value is floating point (Netdata used long double).
Variables are transferred to upstream Netdata servers (streaming and database replication).
Fields§
§scope: Option<Scope>
§name: &'a str
§value: f64