# Copyright (c) HashiCorp, Inc.# SPDX-License-Identifier: MPL-2.0"""Grove processor to filter (delete) fields from log entries based on provided paths.This processor is intended to allow removal of superfluous or duplicated data fromlog entries. This may be used after a processing stage to remove the original sourcedata, or used to prune down a log entry from a particularly verbose vendor."""fromtypingimportAny,Dict,ListfrompydanticimportExtrafromgrove.helpersimportparsingfromgrove.modelsimportProcessorConfigfromgrove.processorsimportBaseProcessor
[docs]classHandler(BaseProcessor):"""Filter (delete) fields from log entries based on provided paths."""
[docs]classConfiguration(ProcessorConfig,extra=Extra.forbid):"""Expresses the configuration and associated validators for the processor."""# Source defines a list of paths to field to drop (delete). These should be# defined as a JMESPaths.sources:List[str]
[docs]defprocess(self,entry:Dict[str,Any])->List[Dict[str,Any]]:"""Attempt to drop a configured field from the log entry. :param entry: A collected log entry. :return: The processed log entry, with fields dropped. """forsourceinself.configuration.sources:entry=parsing.update_path(entry,parsing.quote_aware_split(source),None,)return[entry]