Skip to content

misc.py

Miscellaneous configuration objects for Filebeat

To import...

from dynamite_nsm.services.base.config_objects.filebeat import misc as filebeat_config_misc

FieldProcessors

__init__(self, originating_agent_tag) special

Add/remove/manipulate fields parsed by Filebeat

Parameters:

Name Type Description Default
originating_agent_tag str

The name for the Dynamite Agent which will be added to all events sent downstream

required
Source code in dynamite_nsm/services/base/config_objects/filebeat/misc.py
def __init__(self, originating_agent_tag: str):
    """Add/remove/manipulate fields parsed by Filebeat
    Args:
        originating_agent_tag: The name for the Dynamite Agent which will be **added** to all events sent downstream
    """
    self.originating_agent_tag = originating_agent_tag

get_raw(self)

Get the raw representation of this config object.

Returns:

Type Description
List[Dict]

A dictionary of Filebeat field processors

Source code in dynamite_nsm/services/base/config_objects/filebeat/misc.py
def get_raw(self) -> List[Dict]:
    """Get the raw representation of this config object.
    Returns:
        A dictionary of Filebeat field processors
    """
    return [dict(
        add_fields=dict(
            fields=dict(
                originating_agent_tag=self.originating_agent_tag
            )
        )
    )]

validate_agent_tag(agent_tag) staticmethod

Validate that the agent tag given is valid

Parameters:

Name Type Description Default
agent_tag str

The name of the agent

required

Returns:

Type Description
bool

True, if valid

Source code in dynamite_nsm/services/base/config_objects/filebeat/misc.py
@staticmethod
def validate_agent_tag(agent_tag: str) -> bool:
    """Validate that the agent tag given is valid
    Args:
        agent_tag: The name of the agent

    Returns:
        True, if valid
    """
    import re
    agent_tag = str(agent_tag)
    tag_length_ok = 30 > len(agent_tag) > 5
    tag_match_pattern = bool(re.findall(r"^[a-zA-Z0-9_]*$", agent_tag))
    return tag_length_ok and tag_match_pattern

IndexTemplateSettings

__init__(self, index_name, index_pattern=None, enabled=True, overwrite=True) special

Settings for index name and pattern for downstream Elasticsearch

Parameters:

Name Type Description Default
index_name str

The name of the index where to send logs (E.G dynamite-events-%{+yyyy.MM.dd})

required
index_pattern Optional[str]

The corresponding index pattern (E.G dynamite-events-*)

None
Source code in dynamite_nsm/services/base/config_objects/filebeat/misc.py
def __init__(self, index_name: str, index_pattern: Optional[str] = None, enabled: Optional[bool] = True,
             overwrite: Optional[bool] = True):
    """Settings for index name and pattern for downstream Elasticsearch
    Args:
        index_name: The name of the index where to send logs (E.G dynamite-events-%{+yyyy.MM.dd})
        index_pattern: The corresponding index pattern (E.G dynamite-events-*)
    """
    self.enabled = enabled
    self.overwrite = overwrite
    self.index_name = index_name
    if index_pattern:
        self.index_pattern = index_pattern
    else:
        if index_name:
            self.index_pattern = f'{index_name}-*'
        else:
            self.index_pattern = f'filebeat-*'

get_raw(self)

Get the raw representation of this config object.

Returns:

Type Description
Dict

A dictionary of index template settings

Source code in dynamite_nsm/services/base/config_objects/filebeat/misc.py
def get_raw(self) -> Dict:
    """Get the raw representation of this config object.
    Returns:
        A dictionary of index template settings
    """
    return dict(
        enabled=self.enabled,
        overwrite=self.overwrite,
        name=self.index_name,
        pattern=self.index_pattern
    )

InputLogs

__init__(self, monitor_log_paths) special

A set of logs to monitor on the filesystem

Parameters:

Name Type Description Default
monitor_log_paths List[str]

A list of logs to monitor

required
Source code in dynamite_nsm/services/base/config_objects/filebeat/misc.py
def __init__(self, monitor_log_paths: List[str]):
    """A set of logs to monitor on the filesystem
    Args:
        monitor_log_paths: A list of logs to monitor
    """
    self.enabled = False
    self.monitor_log_paths = monitor_log_paths

get_raw(self)

Get the raw representation of this config object.

Returns:

Type Description
List

A list of input log paths

Source code in dynamite_nsm/services/base/config_objects/filebeat/misc.py
def get_raw(self) -> List:
    """Get the raw representation of this config object.
    Returns:
        A list of input log paths
    """
    return [dict(
        enabled=self.enabled,
        paths=self.monitor_log_paths,
        type='log'
    )]

KibanaSettings

__init__(self, kibana_target_str, kibana_protocol, enabled=False) special

Settings for configuring an upstream Kibana instance

Parameters:

Name Type Description Default
kibana_target_str str

The URL to the Kibana instance w/o the protocol prefix (E.G 192.168.0.5:5601)

required
kibana_protocol str

http or https

required
Source code in dynamite_nsm/services/base/config_objects/filebeat/misc.py
def __init__(self, kibana_target_str: str, kibana_protocol: str, enabled: Optional[bool] = False):
    """Settings for configuring an upstream Kibana instance
    Args:
        kibana_target_str: The URL to the Kibana instance w/o the protocol prefix (E.G 192.168.0.5:5601)
        kibana_protocol: http or https
    """
    self.enabled = enabled
    self.kibana_target_str = kibana_target_str
    self.kibana_protocol = kibana_protocol

get_raw(self)

Get the raw representation of this config object.

Returns:

Type Description
Dict

A dictionary of Kibana endpoint settings

Source code in dynamite_nsm/services/base/config_objects/filebeat/misc.py
def get_raw(self) -> Dict:
    """Get the raw representation of this config object.
    Returns:
        A dictionary of Kibana endpoint settings
    """
    return dict(
        enabled=self.enabled,
        host=self.kibana_target_str,
        protocol=self.kibana_protocol
    )