input {
  file {
    path => "/var/log/apache2/access.log"
    start_position => "beginning"
    sincedb_path => "/dev/null"
    tags => "apache_access"
  }

  file {
    path => "/var/log/apache2/error.log"
    start_position => "beginning"
    sincedb_path => "/dev/null"
    tags => "apache_error"
  }
}

filter {
  if "apache_access" in [tags] {
    grok {
        match => { "message" => "%{HTTPD_COMBINEDLOG}" }
    }
    mutate {
        remove_field => [ "message","[log][file][path]","[event][original]" ]
      }
   } else {
   grok {
        match => { "message" => "%{HTTPD24_ERRORLOG}" }
    }
   }
}

output {
  if "apache_access" in [tags] {
  opensearch {
    hosts       => "https://os.closebee.com:9200"
    user        => "admin"
    password    => "sUbaru#126U"
    index       => "apache_access"
    ssl_certificate_verification => false
  }

  } else {
  opensearch {
    hosts       => "https://os.closebee.com:9200"
    user        => "admin"
    password    => "sUbaru#126U"
    index       => "apache_error"
    ssl_certificate_verification => false
  }
  }
}