input {
  file {
    path => "/var/log/httpd/copr-frontend.access_log"
    type => "httpd-access"
  }
  # file {
  #  path => "/var/log/httpd/copr-frontend.error_log"
  #  type => "httpd-error"
  # }
}

filter {
  mutate {  add_tag => "frontend" }
  if [type] == "httpd-access" {
    if "POST /stats_rcv/from_logstash HTTP" in [message] {
      drop{}
    }
    grok {
      type => "httpd-access"
      pattern => "%{COMBINEDAPACHELOG}"
    }

    # ignore requests generated by search engine crawlers
    useragent {
      source => "agent"
      target => "ua_parsed"
    }
    if [ua_parsed][device] == "Spider" {
      drop {}
    }


    if [request] =~ ".repo$" {
      mutate {  add_tag => "repo_dl" }
      grok {
        match => ["request", "/coprs/%{USERNAME:copr_user}/%{USERNAME:copr_project_name}/repo/%{USERNAME:copr_name_release}/%{USERNAME:copr_repo_file}"]
      }
    }

  }
}

output {
  if [type] == "httpd-access" {
    if "repo_dl" in [tags]  {
       http {
         url => "http://127.0.0.1/stats_rcv/from_logstash"
         format => "json"
         http_method => "post"
       }
    }
  }

}
