Commit graph

284 commits

Author SHA1 Message Date
Tim Wojtulewicz
39814816af Tag truncated values with a flag, plus pack threading::Value better 2025-08-12 17:31:29 -07:00
Tim Wojtulewicz
29425688da Make total_size counter a member in logging::Manager 2025-08-12 17:31:29 -07:00
Tim Wojtulewicz
98a77b5f25 Remove using numeric_limits and just check for zero instead 2025-08-12 17:31:29 -07:00
Tim Wojtulewicz
0ec2161b04 Add options to filter at the stream level as well as globally 2025-08-12 17:31:28 -07:00
Tim Wojtulewicz
339d46ae26 Add a weird that gets emitted when strings/containers are over the limits 2025-08-12 17:31:28 -07:00
Tim Wojtulewicz
837fde1a08 Add metrics to track string and container fields limited by length 2025-08-12 17:31:28 -07:00
Tim Wojtulewicz
cd74a4e138 Replace unused stream argument from RecordToLogRecord with WriterInfo
This also adds a WriterInfo argument to ValToLogVal and passes the one from
RecordToLogRecord into it.
2025-08-12 17:31:28 -07:00
Tim Wojtulewicz
e2e7ab28da Implement string- and container-length filtering at the log record level 2025-08-12 17:31:28 -07:00
Tim Wojtulewicz
e458da944f Return weird if a log line is over a configurable size limit 2025-07-21 09:14:52 -07:00
Tim Wojtulewicz
2f0e3a5e23 Fix clang-tidy modernize-use-override findings 2025-06-06 11:43:06 -07:00
Tim Wojtulewicz
5930d2f944 Fix clang-tidy modernize-pass-by-value findings 2025-06-06 11:43:06 -07:00
Tim Wojtulewicz
f3588657bf Fix clang-tidy modernize-loop-convert findings 2025-06-06 11:43:06 -07:00
Tim Wojtulewicz
c609d5c90a Fix clang-tidy performance-inefficient-string-concatenation warnings 2025-05-30 08:12:29 -07:00
Tim Wojtulewicz
e4ab1a3b1d Add a few std::moves to fix Coverity warnings 2025-05-27 12:03:45 -07:00
Tim Wojtulewicz
d0bbc61bd4 Fix clang-tidy bugprone-multi-level-implicit-pointer-conversion warnings 2025-05-27 11:58:27 -07:00
Tim Wojtulewicz
dbecfb5a2a Fix clang-tidy bugprone-branch-clone warnings 2025-05-27 11:58:27 -07:00
Tim Wojtulewicz
17101da6b3 Remove unnecessary #includes in zeekygen and base plugin files 2025-05-19 10:25:05 -07:00
Tim Wojtulewicz
e3c4b1fd58 Remove unnecessary #includes in input/logging/threading 2025-05-19 10:25:05 -07:00
Tim Wojtulewicz
ca3002d745 Include StmtBase/StmtEnums in Func.h instead of Stmt.h
This requires changes in lots of other files that were depending on Func.h
to provide that include for them.
2025-05-16 10:14:36 -07:00
Arne Welzel
fd2229e7bb logging: Fix reporter message 2025-01-14 10:46:37 +01:00
Arne Welzel
345c4ca28a logging: Avoid repeated writer name lookups for plugin hooks
If a plugin provides a write hook, the invocation for HookLogWrite() would
redo looking up the writer's name from the enum value and instantiating
a new std::string instance for every write. Avoid doing this.
2025-01-14 10:45:34 +01:00
Arne Welzel
927a06b9ab logging: Fix HookLogInit() and HookLogWrite() info usage
There's two instances of WriterBackend::WriterInfo for a given
writer. One in Manager::WriterInfo that's accessible via
stream.writers and a copy within WriterFrontend.

Commit 78999d147d switched to use the
address of the frontend's info instance for HookLogWrite() invocations,
breaking users using the address for identification purposes.
2025-01-14 10:44:50 +01:00
Arne Welzel
ab1d48c95a logging/Manager: Implement new WriteBatchFromRemote() 2024-12-04 12:40:35 +01:00
Arne Welzel
3dd1f8d38a logging/WriterFrontend: Add LogWriteHeader as member
The header captures the enum values as well as the fields
2024-12-04 12:37:22 +01:00
Arne Welzel
f5d4526eac logging: Add filter_name to WriterInfo
...with this change, it'll be possible to identify WriterFrontend's
based on (stream, filter_name, path) pairs in addition to (stream,
writer, path) pairs.
2024-12-04 12:37:22 +01:00
Arne Welzel
65037fa822 logging/Manager: Fix using filename from input.h in debug log
...and remove network_time, it's always included.
2024-11-15 15:46:24 +01:00
Arne Welzel
78999d147d logging/Manager: Extract another CreateWriter() helper
For other cluster backends, CreateWriter() will use a logger's filter
configuration rather than receiving all configuration through CreateLog.
Extract a helper out from WriteToFilters() for reuse.
2024-09-27 15:32:09 +02:00
Arne Welzel
16cca62292 logging/Manager: Extract path_func invocation into helper 2024-09-27 15:32:09 +02:00
Arne Welzel
0d925e935e logging: Dedicated log flush timer
Log flushing is currently triggered based on the threading heartbeat timer
of WriterBackends and the hard-coded WRITE_BUFFER_SIZE 1000.

This change introduces a separate timer that is managed by the logger
manager instead of piggy-backing on the heartbeat timer, as well as a
const &redef for the buffer size.

This allows to modify the log flush frequency and batch size independently
of the threading heartbeat interval. Later, this will allow to re-use the
buffering and flushing logic of writer frontends for non-Broker cluster
backends, too.

One change here is that even frontends that do not have a backend will
be flushed regularly. This is wanted for non-Broker backends and should be
very cheap. Possibly, Broker can piggy back on this timer down the road, too,
rather than using its own script-level timer (see Broker::log_flush()).
2024-09-27 15:30:35 +02:00
Arne Welzel
77b9510c8a all: Change to use Func::GetName() 2024-09-27 15:11:17 +02:00
Arne Welzel
a9290cc031 logging: Switch index-assignment of raw pointers to emplace_back() 2024-08-30 10:59:55 +02:00
Arne Welzel
245fd0c94f broker/logging: Change threading::Value** usage std::vector instead
This allows to leverage automatic memory management, less allocations
and using move semantics for expressing ownership.

This breaks the existing logging and broker API, but keeps the plugin
DoWrite() and HookLogWrite() methods functioning.

It further changes ValToLogVal to return a threading::Value rather than
a threading::Value*. The vector_val and set_val fields unfortunately
use the same pointer-to-array-of-pointers approach. this can'tbe changed
as it'd break backwards compatibility for plugin provided input readers
and log writers.
2024-08-30 10:58:57 +02:00
Tim Wojtulewicz
93717ca8f8 Remove is_sum arguments from counters and gauges 2024-05-31 13:36:37 -07:00
Tim Wojtulewicz
46ff48c29a Change all instruments to only handle doubles 2024-05-31 13:36:37 -07:00
Tim Wojtulewicz
84aa308527 Rework everything to access the prometheus-cpp objects more directly 2024-05-31 13:30:31 -07:00
Tim Wojtulewicz
a0ae06b3cd Convert telemetry code to use prometheus-cpp 2024-05-31 13:30:31 -07:00
Dominik Charousset
bd3e5bedbb Integrate review feedback 2024-01-06 13:48:14 +01:00
Dominik Charousset
1bc5fda591 Backward compatibility for OpaqueVal serialization
External plugins depend on the API for `OpaqueVal`. This set of changes
brings back the previous signature for the `Serialize` and `Unserialize`
member functions. The new set of functions that operate on the recently
added `BrokerData` API were renamed accordingly and use a `Data` suffix to
distinguish between the old and new interface.

For the transition period, `OpaqueVal` now has two "sets" of
serialization functions: old and new (using the suffix). By default, the
new functions call the old API and then convert to the new types. Hence,
plugins that override the old set of member functions will continue to
work. New code should only override the new set of functions.

Since the macro `DECLARE_OPAQUE_VALUE` (a convenience macro for adding a
default set of member functions to a subtype of `OpaqueVal`) might be
used by 3rd parties, the macro has been "restored" to its previous
behavior, i.e., it will override the old set of member functions. The
new macro `DECLARE_OPAQUE_VALUE_V2` is similar but overrides the new set
of functions instead.

The class `BloomFilter` uses the same member function signatures as
`OpaqueVal` for serialization. Hence, the same old/new split was
implemented to keep the APIs consistent.
2024-01-06 10:52:06 +01:00
Vern Paxson
ead4b681aa bug fix for delayed logging 2023-12-12 09:45:19 +01:00
Christian Kreibich
0aef842f05 Merge branch 'topic/neverlord/broker-data'
* topic/neverlord/broker-data:
  Integrate review feedback
  Add facade types to avoid using raw Broker types
2023-12-04 12:32:35 -08:00
Arne Welzel
30314dd940 logging: Fix coverity std::move suggestions 2023-12-04 18:27:57 +01:00
Arne Welzel
52fba4aacf logging/Manager: Fix coverity null-deref
Prior code assumed non-null stream given the active_write_ctx matches,
but please coverity.
2023-12-04 18:27:57 +01:00
Dominik Charousset
647fdf7737 Add facade types to avoid using raw Broker types
By avoiding to use `broker::data` directly, we gain a degree of freedom
that allows us to swap out `broker::data` for something else (e.g.,
`broker::variant`) in the future. Furthermore, it also helps us to keep
Broker types "local" to the Broker manager and gives us a nicer
interface.

Also replaces uses of `broker::expected` with `std::optional`. While an
`expected `can carry additional information as to why a value is not
present, nothing in Zeek ever cared about that. Hence, using
`std::optional` removes an unnecessary dependency on a Broker detail
while also being more efficient (no extra heap allocation when no value
is present).
2023-12-04 15:23:28 +01:00
Tim Wojtulewicz
4fa06cef75 Fix some compiler warnings in logging::Manager 2023-12-01 11:49:26 -07:00
Arne Welzel
3c99b7ae9c logging/Manager: Fix token_val->AsCount() in debug logging
Second UBSAN error triggered from log delay merge.
2023-12-01 16:01:45 +01:00
Arne Welzel
acf4ed9c6c logging/Manager: Fix AsTime() to AsInterval()
Found by UBSAN after merge of log delay branch.
2023-12-01 13:26:40 +01:00
Arne Welzel
9956d96824 logging: Fix typos from review 2023-11-30 12:26:08 +01:00
Arne Welzel
ee65623600 logging/Manager: Make LogDelayExpiredTimer an implementation detail
The only reason this was a private component of Manager was to access
the Stream's function. Use a generic callback and a lambda to avoid
that exposure.
2023-11-30 12:25:49 +01:00
Arne Welzel
dfa8bac273 logging/WriteToFilters: Use range-based for loop 2023-11-30 11:37:10 +01:00
Arne Welzel
e3796894c6 logging: Do not keep delay state persistent
If Log::remove_stream() and Log::create_stream() is called for a stream,
do not restore the previously used max delay or max queue size.
2023-11-29 11:53:11 +01:00