// SPDX-FileCopyrightText: 2026 Icinga GmbH <https://icinga.com>
// SPDX-License-Identifier: GPL-3.0-or-later

#include "base/configobject.hpp"

library perfdata;

namespace icinga
{

class OTLPMetricsWriter : ConfigObject
{
	activation_priority 100;

	[config, required, no_user_modify] String host {
		default {{{ return "127.0.0.1"; }}}
	};
	[config, no_user_modify] int port {
		default {{{ return 4318; }}}
	};
	[config, required, no_user_modify] String metrics_endpoint {
		default {{{ return "/v1/metrics"; }}}
	};

	[config, required] String service_namespace {
		default {{{ return "icinga"; }}}
	};

	[config, no_user_view, no_user_modify] Dictionary::Ptr basic_auth;

	[config] Dictionary::Ptr host_resource_attributes;
	[config] Dictionary::Ptr service_resource_attributes;

	[config] int flush_interval {
		default {{{ return 15; }}}
	};
	[config] int64_t flush_threshold {
		default {{{ return 16 * 1024 * 1024; }}}
	};
	[config] bool enable_ha {
		default {{{ return true; }}}
	};
	[config] bool enable_send_thresholds {
		default {{{ return false; }}}
	};
	[config] int disconnect_timeout {
		default {{{ return 10; }}}
	};

	[config, no_user_modify] bool enable_tls {
		default {{{ return false; }}}
	};
	[config, no_user_modify] bool tls_insecure_noverify {
		default {{{ return false; }}}
	};
	[config, no_user_modify] String tls_ca_file;
	[config, no_user_modify] String tls_cert_file;
	[config, no_user_modify] String tls_key_file;
};

validator OTLPMetricsWriter
{
	Dictionary basic_auth {
		required username;
		String username;
		required password;
		String password;
	};

	Dictionary host_resource_attributes { String "*"; };
	Dictionary service_resource_attributes { String "*"; };
};

} // namespace icinga
