declare "loki_send" {
	argument "job" {
		optional = false
	}

	loki.write "default" {
		endpoint {
			url = "https://loki.kaareskovgaard.net/loki/api/v1/push"
			tls_config {
				cert_file = sys.env("LOKI_CLIENT_CERT")
				key_file = sys.env("LOKI_CLIENT_KEY")
			}
			batch_wait = "1m"
		}
		external_labels = {
			job = argument.job.value,
			instance = constants.hostname,
		}
	}

	export "receiver" {
		value = loki.write.default.receiver
	}
}
