<commit_before>input {
  
  kafka {
        bootstrap_servers => "kafka:{{.Values.monasca_kafka_port_internal}}"
        topics => ["transformed-log"]
        group_id => "logstash-persister"
        client_id => "monasca_log_persister"
        consumer_threads => 12
  }
}

filter {
    mutate {
        add_field => {
            olaf => "%{meta}"
            olaf1 => "%{tenantId}"
            message => "%{[log][message]}"
            log_level => "%{[log][level]}"
            tenant => "%{[meta][tenantId]}"
            region => "%{[meta][region]}"
        }
#        remove_field => ["@version" ,"_index_date", "meta", "log"]
    }

}

#output {
#    elasticsearch {
#        index => "%{[meta][tenantId]}-%{index_date}"
#        document_type => "logs"
#        hosts => ["{{.Values.monasca_elasticsearch_endpoint_host_internal}}:{{.Values.monasca_elasticsearch_port_internal}}"]
#        user => "{{.Values.monasca_elasticsearch_admin_user}}"
#        password => "{{.<PASSWORD>}}"
#        flush_size => 500
#    }
#}

output {
    kafka {
        bootstrap_servers => "kafka:{{.Values.monasca_kafka_port_internal}}"
        topic_id => "olaf-log"
        reconnect_backoff_ms => 1000
        retries => 10
        retry_backoff_ms => 1000
        }
}<commit_msg>switch logstash-persister back to elastic<commit_after>input {
  kafka {
        bootstrap_servers => "kafka:{{.Values.monasca_kafka_port_internal}}"
        topics => ["transformed-log"]
        group_id => "logstash-persister"
        client_id => "monasca_log_persister"
        consumer_threads => 12
  }
}

filter {

    json {
      source => "message"
    }

    if "dimensions" in [log]  {
      ruby {
        code => "
                fieldHash = event.get('[log][dimensions]')
                fieldHash.each do |key, value|
                event.set(key, value)
                end
                "
      }
    }

    date {
        match => ["[log][timestamp]", "UNIX"]
        target => "@timestamp"
    }

    date {
        match => ["creation_time", "UNIX"]
        target => "creation_time"
    }

    grok {
        match => {
            "[@timestamp]" => "^(?<index_date>\d{4}-\d{2}-\d{2})"
        }
    }


    mutate {
        add_field => { tenant => "%{[meta][tenantId]}"
                       region => "%{[meta][region]}"
        }
        replace => { message => "%{[log][message]}"
        }
       remove_field => [ "[log][message]", "creation_time", "meta", "log" ]
    }
}

output {
    elasticsearch {
        index => "%{tenant}-%{index_date}"
        document_type => "logs"
        hosts => ["{{.Values.monasca_elasticsearch_endpoint_host_internal}}:{{.Values.monasca_elasticsearch_port_internal}}"]
        user => "{{.Values.monasca_elasticsearch_admin_user}}"
        password => "{{.Values.<PASSWORD>}}"
        flush_size => 500
    }
}
{'fraction_non_alphanumeric': 0.1702873160476524, 'fraction_numerical': 0.008409250175192713, 'mean_word_length': 2.08982683982684, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 55, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3145545', 'n_tokens_mistral': 959, 'n_tokens_neox': 921, 'n_words': 137}