﻿apiVersion: v1
kind: ConfigMap
metadata:
  name: sample-logstash-configmap
  namespace: default
data:
    
  logstash.yml: |
    xpack.monitoring.elasticsearch.url: https://sample-elasticsearch:9200
    dead_letter_queue.enable: true
    xpack.monitoring.enabled: true
    xpack.monitoring.elasticsearch.username: logstash_system 
    xpack.monitoring.elasticsearch.password: Password1$
    xpack.monitoring.elasticsearch.ssl.ca: "/usr/share/logstash/config/elastic-stack-ca.pem"

  pipelines.yml: |
    - pipeline.id: azureeventhubs
      path.config: "/usr/share/logstash/azureeventhubs.cfg"
    - pipeline.id: azureredis
      path.config: "/usr/share/logstash/azureredis.cfg"
    
  azureeventhubs.cfg: |
    input {
      azure_event_hubs {
        event_hub_connections => ["{AZURE_EVENT_HUB_CONNECTION_STRING};EntityPath=logstash"]
        threads => 2
        decorate_events => true
        consumer_group => "$Default"
        storage_connection => "{STORAGE_ACCOUNT_CONNECTION_STRING}"
        storage_container => "logstash"
        }
    }
    filter {
    }
    
    output {
      elasticsearch {
        hosts => ["sample-elasticsearch:9200" ]
        user => "elastic"
        password => "Password1$"
        index => "azureeventhub-%{+YYYY.MM.dd}"
        ssl => true
        cacert => "/usr/share/logstash/config/elastic-stack-ca.pem"
      }
    }
  
  azureredis.cfg: |
    input {
      redis {
        host => "{YOUR_REDIS_HOST_NAME}"
        key => "messages"
        data_type => "channel"
        password => "{YOUR_REDIS_SECONDARY_KEY}"
        port => 6380
        ssl => true
     }
    }
    
    filter {
    }
    
    output {
      elasticsearch {
        hosts => ["sample-elasticsearch:9200" ]
        user => "elastic"
        password => "Password1$"
        index => "azureredis-%{+YYYY.MM.dd}"
        ssl => true
        cacert => "/usr/share/logstash/config/elastic-stack-ca.pem"
      }
    }  
    
  logstash.conf: |