base/frameworks/telemetry/main.zeek
- Telemetry
Module for recording and querying metrics. This modules wraps the lower-level telemetry.bif functions.
Metrics will be exposed through a Prometheus HTTP endpoint when
enabled by setting Telemetry::metrics_port
.
- Namespace:
Telemetry
- Imports:
base/bif/telemetry_functions.bif.zeek, base/misc/version.zeek
Summary
Runtime Options
Interval at which the |
Types
Type representing a counter metric with initialized label values. |
|
Type representing a family of counters with uninitialized label values. |
|
Type representing a gauge metric with initialized label values. |
|
Type representing a family of gauges with uninitialized label values. |
|
Type representing a histogram metric with initialized label values. |
|
Type representing a family of histograms with uninitialized label values. |
|
Alias for a vector of label values. |
Functions
Collect all histograms and their observations matching the given prefix and name. |
|
Collect all counter and gauge metrics matching the given name and prefix. |
|
Increment a |
|
Set a |
|
Increment a |
|
Helper to set a |
|
Get a |
|
Decrement a |
|
Decrement a |
|
Increment a |
|
Set a |
|
Increment a |
|
Helper to set a |
|
Get a |
|
Observe a measurement for a |
|
Observe a measurement for a |
|
Get a |
|
Register a counter family. |
|
Register a gauge family. |
|
Register a histogram family. |
Detailed Interface
Runtime Options
- Telemetry::sync_interval
- Type:
- Attributes:
&deprecated
= “Remove in 8.1. If you require regular sync invocation, do so explicitly in a scheduled event.”&redef
- Default:
0 secs
Interval at which the
Telemetry::sync
hook is invoked.By default, the hook is invoked on demand, setting this option to a positive interval allows to invoke it regularly, too. Regular invocations are relative to Zeek’s network time.
Note that on-demand hook invocation will happen even if this is set.
Types
- Telemetry::Counter
-
Type representing a counter metric with initialized label values.
Counter metrics only ever go up and reset when the process restarts. Use
Telemetry::counter_inc
orTelemetry::counter_set
to modify counters. An example for a counter is the number of log writes perLog::Stream
or number connections broken down by protocol and service.
- Telemetry::CounterFamily
-
Type representing a family of counters with uninitialized label values.
To create concrete
Telemetry::Counter
instances, useTelemetry::counter_with
. To modify counters directly useTelemetry::counter_family_inc
.
- Telemetry::Gauge
-
Type representing a gauge metric with initialized label values.
Use
Telemetry::gauge_inc
,Telemetry::gauge_dec
, orTelemetry::gauge_set
to modify the gauge. Example for gauges are process memory usage, table sizes or footprints of long-lived values as determined byval_footprint
.
- Telemetry::GaugeFamily
-
Type representing a family of gauges with uninitialized label values.
Create concrete
Telemetry::Gauge
instances withTelemetry::gauge_with
, or useTelemetry::gauge_family_inc
orTelemetry::gauge_family_set
directly.
- Telemetry::Histogram
-
Type representing a histogram metric with initialized label values. Use
Telemetry::histogram_observe
to make observations.
- Telemetry::HistogramFamily
-
Type representing a family of histograms with uninitialized label values. Create concrete
Telemetry::Histogram
instances withTelemetry::histogram_with
or useTelemetry::histogram_family_observe
directly.
- Telemetry::labels_vector
-
Alias for a vector of label values.
Functions
- Telemetry::collect_histogram_metrics
- Type:
function
(prefix:string
&default
="*"
&optional
, name:string
&default
="*"
&optional
) :vector
ofTelemetry::HistogramMetric
Collect all histograms and their observations matching the given prefix and name.
The prefix and name parameters support globbing. By default, all histogram metrics are returned.
- Telemetry::collect_metrics
- Type:
function
(prefix:string
&default
="*"
&optional
, name:string
&default
="*"
&optional
) :vector
ofTelemetry::Metric
Collect all counter and gauge metrics matching the given name and prefix.
For histogram metrics, use the
Telemetry::collect_histogram_metrics
.The prefix and name parameters support globbing. By default, all counters and gauges are returned.
- Telemetry::counter_family_inc
- Type:
function
(cf:Telemetry::CounterFamily
, label_values:Telemetry::labels_vector
&default
=[]
&optional
, amount:double
&default
=1.0
&optional
) :bool
Increment a
Telemetry::Counter
through theTelemetry::CounterFamily
. This is a short-cut forTelemetry::counter_inc
. Using a negative amount is an error.- Parameters:
cf – The counter family to use.
label_values – The label values to use for the counter.
amount – The amount by which to increment the counter.
- Returns:
True if the counter was incremented successfully.
- Telemetry::counter_family_set
- Type:
function
(cf:Telemetry::CounterFamily
, label_values:Telemetry::labels_vector
, value:double
) :bool
Set a
Telemetry::Counter
through theTelemetry::CounterFamily
. This is a short-cut forTelemetry::counter_set
. Setting a value that is less than the current value of the metric is an error and will be ignored.- Parameters:
cf – The counter family to use.
label_values – The label values to use for the counter.
value – The value to set the counter to.
- Returns:
True if the counter value was set successfully.
- Telemetry::counter_inc
-
Increment a
Telemetry::Counter
by amount. Using a negative amount is an error.- Parameters:
c – The counter instance.
amount – The amount by which to increment the counter.
- Returns:
True if the counter was incremented successfully.
- Telemetry::counter_set
- Type:
function
(c:Telemetry::Counter
, value:double
) :bool
Helper to set a
Telemetry::Counter
to the given value. This can be useful for mirroring counter metrics in anTelemetry::sync
hook implementation. Setting a value that is less than the current value of the metric is an error and will be ignored.- Parameters:
c – The counter instance.
value – The value to set the counter to.
- Returns:
True if the counter value was set successfully.
- Telemetry::counter_with
- Type:
function
(cf:Telemetry::CounterFamily
, label_values:Telemetry::labels_vector
&default
=[]
&optional
) :Telemetry::Counter
Get a
Telemetry::Counter
instance given family and label values.
- Telemetry::gauge_dec
-
Decrement a
Telemetry::Gauge
by amount.- Parameters:
g – The gauge instance.
amount – The amount by which to decrement the gauge.
- Returns:
True if the gauge was incremented successfully.
- Telemetry::gauge_family_dec
- Type:
function
(gf:Telemetry::GaugeFamily
, label_values:Telemetry::labels_vector
&default
=[]
&optional
, value:double
&default
=1.0
&optional
) :bool
Decrement a
Telemetry::Gauge
by the given amount through theTelemetry::GaugeFamily
. This is a short-cut forTelemetry::gauge_dec
.- Parameters:
gf – The gauge family to use.
label_values – The label values to use for the gauge.
amount – The amount by which to increment the gauge.
- Returns:
True if the gauge was incremented successfully.
- Telemetry::gauge_family_inc
- Type:
function
(gf:Telemetry::GaugeFamily
, label_values:Telemetry::labels_vector
&default
=[]
&optional
, value:double
&default
=1.0
&optional
) :bool
Increment a
Telemetry::Gauge
by the given amount through theTelemetry::GaugeFamily
. This is a short-cut forTelemetry::gauge_inc
. Using a negative amount is an error.- Parameters:
gf – The gauge family to use.
label_values – The label values to use for the gauge.
amount – The amount by which to increment the gauge.
- Returns:
True if the gauge was incremented successfully.
- Telemetry::gauge_family_set
- Type:
function
(gf:Telemetry::GaugeFamily
, label_values:Telemetry::labels_vector
, value:double
) :bool
Set a
Telemetry::Gauge
to the given value through theTelemetry::GaugeFamily
. This is a short-cut forTelemetry::gauge_set
.- Parameters:
gf – The gauge family to use.
label_values – The label values to use for the gauge.
value – The value to set the gauge to.
- Returns:
True if the gauge value was set successfully.
- Telemetry::gauge_inc
-
Increment a
Telemetry::Gauge
by amount.- Parameters:
g – The gauge instance.
amount – The amount by which to increment the gauge.
- Returns:
True if the gauge was incremented successfully.
- Telemetry::gauge_set
- Type:
function
(g:Telemetry::Gauge
, value:double
) :bool
Helper to set a
Telemetry::Gauge
to the given value.- Parameters:
g – The gauge instance.
value – The value to set the gauge to.
- Returns:
True if the gauge value was set successfully.
- Telemetry::gauge_with
- Type:
function
(gf:Telemetry::GaugeFamily
, label_values:Telemetry::labels_vector
&default
=[]
&optional
) :Telemetry::Gauge
Get a
Telemetry::Gauge
instance given family and label values.
- Telemetry::histogram_family_observe
- Type:
function
(hf:Telemetry::HistogramFamily
, label_values:Telemetry::labels_vector
, measurement:double
) :bool
Observe a measurement for a
Telemetry::Histogram
through theTelemetry::HistogramFamily
. This is a short-cut forTelemetry::histogram_observe
.- Parameters:
hf – The histogram family to use.
label_values – The label values to use for the histogram.
measurement – The value for this observations.
- Returns:
True if measurement was observed successfully.
- Telemetry::histogram_observe
- Type:
function
(h:Telemetry::Histogram
, measurement:double
) :bool
Observe a measurement for a
Telemetry::Histogram
.- Parameters:
h – The histogram instance.
measurement – The value for this observations.
- Returns:
True if measurement was observed successfully.
- Telemetry::histogram_with
- Type:
function
(hf:Telemetry::HistogramFamily
, label_values:Telemetry::labels_vector
&default
=[]
&optional
) :Telemetry::Histogram
Get a
Telemetry::Histogram
instance given family and label values.
- Telemetry::register_counter_family
- Type:
function
(opts:Telemetry::MetricOpts
) :Telemetry::CounterFamily
Register a counter family.
- Telemetry::register_gauge_family
- Type:
function
(opts:Telemetry::MetricOpts
) :Telemetry::GaugeFamily
Register a gauge family.
- Telemetry::register_histogram_family
- Type:
function
(opts:Telemetry::MetricOpts
) :Telemetry::HistogramFamily
Register a histogram family.