Parse user agent details
authorTom Hughes <tom@compton.nu>
Tue, 28 Jul 2015 09:33:15 +0000 (10:33 +0100)
committerTom Hughes <tom@compton.nu>
Tue, 28 Jul 2015 09:43:30 +0000 (10:43 +0100)
cookbooks/logstash/templates/default/logstash.conf.erb

index 0ddab7b..c036c1f 100644 (file)
@@ -14,6 +14,19 @@ filter {
     date {
       match => [ "timestamp", "dd/MMM/yyyy:HH:mm:ss Z" ]
     }
+    if [agent] == "-" {
+      mutate {
+        remove_field => [ "agent" ]
+      }
+    } else {
+      useragent {
+        source => "agent"
+        target => "useragent"
+      }
+      mutate {
+        rename => { "agent" => "[useragent][raw]" }
+      }
+    }
   } else if [type] == "rails" {
     json {
       source => "message"