Skip to content

config

Configuration wrappers for the main Kibana configuration file.

To import...

from dynamite_nsm.services.kibana import config as kibana_config

ConfigManager

__init__(self, configuration_directory, verbose=False, stdout=True) special

Manage Kibana Configuration

Parameters:

Name Type Description Default
configuration_directory str

Path to the configuration directory (E.G /etc/dynamite/kibana/)

required
stdout Optional[bool]

Print output to console

True
verbose Optional[bool]

Include detailed debug messages

False

Returns:

Type Description

None

Source code in dynamite_nsm/services/kibana/config.py
def __init__(self, configuration_directory: str, verbose: Optional[bool] = False, stdout: Optional[bool] = True):
    """Manage Kibana Configuration
    Args:
        configuration_directory: Path to the configuration directory (E.G /etc/dynamite/kibana/)
        stdout: Print output to console
        verbose: Include detailed debug messages
    Returns:
        None
    """
    extract_tokens = {
        'host': ('server.host',),
        'port': ('server.port',),
        'elasticsearch_targets': ('elasticsearch.hosts',),
        'elasticsearch_username': ('elasticsearch.username',),
        'elasticsearch_password': ('elasticsearch.password',),
    }
    self.host = None
    self.port = None
    self.elasticsearch_targets = None
    self.elasticsearch_username = None
    self.elasticsearch_password = None
    self.configuration_directory = configuration_directory
    self.kibana_config_path = f'{self.configuration_directory}/kibana.yml'
    with open(self.kibana_config_path) as configyaml:
        self.config_data_raw = load(configyaml, Loader=Loader)
    super().__init__(self.config_data_raw, name='KIBANACFG', verbose=verbose, stdout=stdout, **extract_tokens)
    self.parse_yaml_file()

commit(self, out_file_path=None, backup_directory=None, top_text=None)

Write out an updated configuration file, and optionally backup the old one.

Parameters:

Name Type Description Default
out_file_path Optional[str]

The path to the output file; if none given overwrites existing

None
backup_directory Optional[str]

The path to the backup directory

None
top_text Optional[str]

The text to be appended at the top of the config file (typically used for YAML version header)

None

Returns:

Type Description
None

None

Source code in dynamite_nsm/services/kibana/config.py
def commit(self, out_file_path: Optional[str] = None, backup_directory: Optional[str] = None,
           top_text: Optional[str] = None) -> None:
    """Write out an updated configuration file, and optionally backup the old one.
    Args:
        out_file_path: The path to the output file; if none given overwrites existing
        backup_directory: The path to the backup directory
        top_text: The text to be appended at the top of the config file (typically used for YAML version header)
    Returns:
        None
    """
    if not out_file_path:
        out_file_path = self.kibana_config_path

    super(ConfigManager, self).commit(out_file_path, backup_directory)