{"id":6240,"date":"2017-04-18T14:47:50","date_gmt":"2017-04-18T19:47:50","guid":{"rendered":"http:\/\/appcrawler.com\/wordpress\/?p=6240"},"modified":"2017-04-19T09:22:01","modified_gmt":"2017-04-19T14:22:01","slug":"splunk-query-for-custom-apache-access-log-format","status":"publish","type":"post","link":"http:\/\/appcrawler.com\/wordpress\/2017\/04\/18\/splunk-query-for-custom-apache-access-log-format\/","title":{"rendered":"Splunk query for custom Apache access log format"},"content":{"rendered":"<p>We have a kludgy access log format.  It certainly isn&#8217;t standard.  At any rate, the out of the box transforms.conf can&#8217;t handle it.  Rather than change that, I elected to split the lines on the fly; not as fast, but it&#8217;s an option.  This splits the line, delimited by tab, into an array that is then filtered only on an HTTP response code of 404.<\/p>\n<pre>\r\nimport splunklib.client as client\r\nimport splunklib.results as results\r\n\r\nservice = client.connect(host=\"*******\",port=\"8089\",username=\"*****\",password=\"******\")\r\n\r\nrr = results.ResultsReader(service.jobs.oneshot(\"\"\"\r\nsearch host=\\\"cmhlpecomweb*\\\" sourcetype=access_combined | \r\n  fields _raw | \r\n  eval temp=split(_raw,\\\"\\t\\\") | \r\n  eval response_code=mvindex(temp,7) | \r\n  where response_code = 404\r\n\"\"\",\r\n  **{\"earliest_time\":\"2017-04-16T03:18:00.000-04:00\",\r\n     \"latest_time\":\"2017-04-16T03:22:00.000-04:00\",\r\n     \"count\": 0}))\r\n\r\nfor result in rr:\r\n  print result['_raw']\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>We have a kludgy access log format. It certainly isn&#8217;t standard. At any rate, the out of the box transforms.conf can&#8217;t handle it. Rather than change that, I elected to split the lines on the fly; not as fast, but&hellip;<\/p>\n<p class=\"more-link-p\"><a class=\"more-link\" href=\"http:\/\/appcrawler.com\/wordpress\/2017\/04\/18\/splunk-query-for-custom-apache-access-log-format\/\">Read more &rarr;<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"footnotes":""},"categories":[81],"tags":[],"_links":{"self":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts\/6240"}],"collection":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/comments?post=6240"}],"version-history":[{"count":5,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts\/6240\/revisions"}],"predecessor-version":[{"id":6256,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts\/6240\/revisions\/6256"}],"wp:attachment":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/media?parent=6240"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/categories?post=6240"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/tags?post=6240"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}