apiVersion: v1
kind: ConfigMap
metadata:
  name: opentsdb-cm
  namespace: hpe-templates-data
data:
  opentsdb.conf: |
    # --------- NETWORK ----------
    # The TCP port TSD should use for communications
    # *** REQUIRED ***
    tsd.network.port = 4242

    # The IPv4 network address to bind to, defaults to all addresses
    # tsd.network.bind = 0.0.0.0

    # Enables Nagel's algorithm to reduce the number of packets sent over the
    # network, default is True
    #tsd.network.tcpnodelay = true

    # Determines whether or not to send keepalive packets to peers, default
    # is True
    #tsd.network.keepalive = true

    # Determines if the same socket should be used for new connections, default
    # is True
    #tsd.network.reuseaddress = true

    # Number of worker threads dedicated to Netty, defaults to # of CPUs * 2
    #tsd.network.worker_threads = 8

    # Whether or not to use NIO or tradditional blocking IO, defaults to True
    #tsd.network.async_io = true

    # ----------- HTTP -----------
    # The location of static files for the HTTP GUI interface.
    # *** REQUIRED ***
    tsd.http.staticroot = /opt/mapr/opentsdb/opentsdb-2.4.0/share/opentsdb/static/

    # Where TSD should write it's cache files to
    # *** REQUIRED ***
    tsd.http.cachedir = /opt/mapr/opentsdb/opentsdb-2.4.0/var/cache/opentsdb

    # --------- CORE ----------
    # Whether or not to automatically create UIDs for new metric types, default
    # is False
    tsd.core.enable_ui = false

    tsd.core.auto_create_metrics = true

    tsd.core.meta.enable_realtime_uid = true

    tsd.core.meta.enable_tsuid_tracking = true

    # Full path to a directory containing plugins for OpenTSDB
    tsd.core.plugin_path = /opt/mapr/opentsdb/opentsdb-2.4.0/share/opentsdb/plugins

    # --------- STORAGE ----------
    # Whether or not to enable data compaction in HBase, default is True
    #tsd.storage.enable_compaction = true

    tsd.storage.fix_duplicates = true
    # How often, in milliseconds, to flush the data point queue to storage,
    # default is 1,000
    # tsd.storage.flush_interval = 1000

    # Name of the HBase table where data points are stored, default is "tsdb"
    tsd.storage.hbase.data_table = /var/mapr/mapr.monitoring/tsdb

    # Name of the HBase table where UID information is stored, default is "tsdb-uid"
    tsd.storage.hbase.uid_table = /var/mapr/mapr.monitoring/tsdb-uid

    tsd.storage.hbase.meta_table = /var/mapr/mapr.monitoring/tsdb-meta

    # Path under which the znode for the -ROOT- region is located, default is "/hbase"
    #tsd.storage.hbase.zk_basedir = /hbase

    # A space separated list of Zookeeper hosts to connect to, with or without
    # port specifiers, default is "localhost"
    tsd.storage.hbase.zk_quorum = zk-0.zk-svc.dataplatform.svc.cluster.local:5181 zk-1.zk-svc.dataplatform.svc.cluster.local:5181 zk-2.zk-svc.dataplatform.svc.cluster.local:5181

    #Enable histograms
    tsd.core.histograms.config =  {\"net.opentsdb.core.SimpleHistogramDecoder\": 0}
    # Config to enable reading from streams
    tsd.default.usestreams = true
    tsd.default.consumergroup = metrics
    tsd.streams.path = /var/mapr/mapr.monitoring/streams
    tsd.streams.new.path = /var/mapr/mapr.monitoring/metricstreams
    tsd.streams.consumer.memory = 4194304
    tsd.streams.count = 3
    tsd.streams.autocommit.interval = 60000
    tsd.mode = ro
    tsd.http.request.enable_chunked=true
    tsd.http.request.max_chunk=65536
    tsd.core.tag.allow_specialchars = ' '

  logback.xml: |
    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
      <!--<jmxConfigurator/>-->
      <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
          <pattern>
            %d{ISO8601} %-5level [%thread] %logger{0}: %msg%n
          </pattern>
        </encoder>
      </appender>

      <!-- This appender is responsible for the /logs endpoint. It maintains MaxSize
           lines of the log file in memory. If you don't need the endpoint, disable
           this appender (by removing the line "<appender-ref ref="CYCLIC"/>" in
           the "root" section below) to save some cycles and memory. -->
      <appender name="CYCLIC" class="ch.qos.logback.core.read.CyclicBufferAppender">
        <MaxSize>1024</MaxSize>
      </appender>

      <!-- Appender to write OpenTSDB data to a set of rotating log files -->
      <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>${LOG_FILE}</file>
        <append>true</append>

        <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
          <fileNamePattern>${LOG_FILE}.%i</fileNamePattern>
          <minIndex>1</minIndex>
          <maxIndex>3</maxIndex>
        </rollingPolicy>

        <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
          <maxFileSize>128MB</maxFileSize>
        </triggeringPolicy>

        <encoder>
          <pattern>%d{yyyy-MM-dd} %d{HH:mm:ss.SSS} %-5level [%logger{0}.%M] - %msg%n</pattern>
        </encoder>
      </appender>

      <!-- Appender for writing full and completed queries to a log file. To use it, make
           sure to set the "level" to "INFO" in QueryLog below. -->
      <appender name="QUERY_LOG" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>${QUERY_LOG}</file>
        <append>true</append>

        <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
            <fileNamePattern>${QUERY_LOG}.%i</fileNamePattern>
            <minIndex>1</minIndex>
            <maxIndex>4</maxIndex>
        </rollingPolicy>

        <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
            <maxFileSize>128MB</maxFileSize>
        </triggeringPolicy>
        <encoder>
            <pattern>%date{ISO8601} [%logger.%M] %msg%n</pattern>
        </encoder>
      </appender>

      <!-- Per class logger levels -->
      <logger name="QueryLog" level="OFF" additivity="false">
        <appender-ref ref="QUERY_LOG"/>
      </logger>
      <logger name="org.apache.zookeeper" level="INFO"/>
      <logger name="org.hbase.async" level="INFO"/>
      <logger name="com.stumbleupon.async" level="INFO"/>

      <!-- Fallthrough root logger and router -->
      <root level="INFO">
        <!-- <appender-ref ref="STDOUT"/> -->
        <appender-ref ref="CYCLIC"/>
        <appender-ref ref="FILE"/>
      </root>
    </configuration>

  pre-startup.sh: |
    #!/usr/bin/env bash

  post-startup.sh: |
    #!/usr/bin/env bash
