#############################################################################
# Copyright (c) 2015 Balabit
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 as published
# by the Free Software Foundation, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
#
# As an additional exemption you are allowed to compile & link against the
# OpenSSL libraries as published by the OpenSSL project. See the file
# COPYING for details.
#
#############################################################################

block destination elasticsearch(
  index("")
  type("")
  template("$(format-json --scope rfc5424 --exclude DATE --key ISODATE @timestamp=${ISODATE})")
  port("9300")
  server("localhost")
  flush_limit("5000")
  client_mode("node")
  cluster("")
  custom_id("")
  resource("")
  client_lib_dir("")
  concurrent_requests("1")
)
{
  java(
    class_path("`module-path`/java-modules/*.jar:`client_lib_dir`/*.jar")
    class_name("org.syslog_ng.elasticsearch.ElasticSearchDestination")
    option("index", `index`)
    option("type", `type`)
    option("server", `server`)
    option("port", `port`)
    option("message-template", `template`)
    option("cluster", `cluster`)
    option("flush_limit", `flush_limit`)
    option("client_mode", `client_mode`)
    option("resource", `resource`)
    option("custom_id", `custom_id`)
    option("concurrent_requests", `concurrent_requests`)
    `__VARARGS__`
  );
};

block destination elasticsearch2(
  index("")
  type("")
  template("$(format-json --scope rfc5424 --exclude DATE --key ISODATE @timestamp=${ISODATE})")
  port("")
  server("localhost")
  flush_limit("5000")
  client_mode("node")
  cluster("")
  custom_id("")
  resource("")
  client_lib_dir("")
  concurrent_requests("1")
  skip_cluster_health_check("")
  cluster_url("")
)
{
  java(
    class_path("`module-path`/java-modules/*.jar:`module-path`/java-modules/elastic-jest-client/*.jar:`client_lib_dir`/*.jar")
    class_name("org.syslog_ng.elasticsearch_v2.ElasticSearchDestination")
    option("index", `index`)
    option("type", `type`)
    option("server", `server`)
    option("port", `port`)
    option("message-template", `template`)
    option("cluster", `cluster`)
    option("flush_limit", `flush_limit`)
    option("client_mode", `client_mode`)
    option("resource", `resource`)
    option("custom_id", `custom_id`)
    option("concurrent_requests", `concurrent_requests`)
    option("skip_cluster_health_check", `skip_cluster_health_check`)
    option("cluster_url", `cluster_url`)
    `__VARARGS__`
  );
};
