in share/config.py [0:0]
def add_output(self, output_type: str, **kwargs: Any) -> None:
"""
Output setter.
Set an output given its type and init kwargs
"""
if output_type not in _available_output_types:
raise ValueError(f"Type {output_type} is not included in the supported types: {_available_output_types}")
output_dest = ""
if output_type == "elasticsearch":
if "cloud_id" not in kwargs and "elasticsearch_url" not in kwargs:
raise ValueError("Either `elasticsearch_url` or `cloud_id` must be set")
# elasticsearch_url takes precedence over cloud_id
if "elasticsearch_url" not in kwargs:
output_dest = kwargs["cloud_id"]
else:
output_dest = kwargs["elasticsearch_url"]
elif output_type == "logstash":
if "logstash_url" not in kwargs:
raise ValueError(f"Output type {output_type} requires logstash_url to be set")
output_dest = kwargs["logstash_url"]
if output_dest in self._outputs:
# Since logstash destination can only be set as logstash_url, we do not have to account
# for the same url/cloud_id for both types logstash or elasticsearch
raise ValueError(f"Duplicated output destination {output_dest} for type {output_type}")
output: Optional[Output] = None
if output_type == "elasticsearch":
output = ElasticsearchOutput(**kwargs)
elif output_type == "logstash":
output = LogstashOutput(**kwargs)
else:
output = Output(output_type=output_type)
self._outputs[output_dest] = output