mirror of
https://github.com/zeek/zeek.git
synced 2025-10-03 07:08:19 +00:00
Introduce telemetry framework
Adds base/frameworks/telemetry with wrappers around telemetry.bif and updates telemetry/Manager to support collecting metrics from script land. Add policy/frameworks/telemetry/log for logging of metrics data into a new telemetry.log and telemetry_histogram.log and add into local.zeek by default.
This commit is contained in:
parent
95fba8fd29
commit
3fe930dbf2
32 changed files with 1950 additions and 27 deletions
|
@ -1,4 +1,3 @@
|
|||
|
||||
#include "Plugin.h"
|
||||
|
||||
#include <Conn.h>
|
||||
|
@ -8,6 +7,7 @@
|
|||
#include <RunState.h>
|
||||
#include <threading/Formatter.h>
|
||||
#include <cstring>
|
||||
#include <set>
|
||||
|
||||
namespace btest::plugin::Demo_Hooks
|
||||
{
|
||||
|
@ -16,6 +16,22 @@ Plugin plugin;
|
|||
|
||||
using namespace btest::plugin::Demo_Hooks;
|
||||
|
||||
// Sanitize arguments for the following functions with (...). These
|
||||
// receiving the current version string or parts of it and make the
|
||||
// baseline non-deterministic.
|
||||
static std::set<std::string> sanitized_functions = {
|
||||
"Version::parse",
|
||||
"gsub",
|
||||
"split_string1",
|
||||
"lstrip",
|
||||
"to_count",
|
||||
"cat",
|
||||
"Telemetry::__dbl_gauge_metric_get_or_add",
|
||||
"Telemetry::gauge_with",
|
||||
"Telemetry::make_labels",
|
||||
"Telemetry::gauge_family_set",
|
||||
};
|
||||
|
||||
zeek::plugin::Configuration Plugin::Configure()
|
||||
{
|
||||
EnableHook(zeek::plugin::HOOK_LOAD_FILE);
|
||||
|
@ -58,11 +74,7 @@ static void describe_hook_args(const zeek::plugin::HookArgumentList& args, zeek:
|
|||
// For function calls we remove args for unstable arguments
|
||||
// from parsing the version in `base/misc/version`.
|
||||
if ( i->GetType() == zeek::plugin::HookArgument::FUNC &&
|
||||
(::strcmp(d->Description(), "Version::parse") == 0 ||
|
||||
::strcmp(d->Description(), "gsub") == 0 ||
|
||||
::strcmp(d->Description(), "split_string1") == 0 ||
|
||||
::strcmp(d->Description(), "lstrip") == 0 ||
|
||||
::strcmp(d->Description(), "to_count") == 0) )
|
||||
sanitized_functions.count(d->Description()) != 0 )
|
||||
serialize_args = false;
|
||||
|
||||
continue;
|
||||
|
@ -105,10 +117,8 @@ std::pair<bool, zeek::ValPtr> Plugin::HookFunctionCall(const zeek::Func* func,
|
|||
|
||||
// For function calls we remove args for unstable arguments
|
||||
// from parsing the version in `base/misc/version`.
|
||||
if ( ::strcmp(d.Description(), "Version::parse") == 0 ||
|
||||
::strcmp(d.Description(), "gsub") == 0 ||
|
||||
::strcmp(d.Description(), "split_string1") == 0 ||
|
||||
::strcmp(d.Description(), "lstrip") == 0 || ::strcmp(d.Description(), "to_count") == 0 )
|
||||
//
|
||||
if ( sanitized_functions.count(d.Description()) != 0 )
|
||||
d.Add("(...)");
|
||||
else
|
||||
zeek::plugin::HookArgument(args).Describe(&d);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue