Errors generated by OPTIONS requests

We were recently asked the question:

I changed from GET to POST requests from JS-tracker, and that has started making an OPTIONS http request which is generating some errors.

As this seems to be a common question I’m elaborating on it below.

Why enabling POST request results in an additional OPTIONS request?

The OPTIONS request is a pre-flight request, that is a CORS (Cross-Origin Resource Sharing) requirement. You can read more about it here: http://www.html5rocks.com/en/tutorials/cors/.

When the Javascript tracker wants to send a POST request, it has to send an OPTIONS request first to check that the collector will accept POST requests from any domain. The collector logs these OPTIONS requests which are then processed in Enrichment.

Why the OPTIONS requests end up in bad rows?

As the collector logs these OPTIONS requests, they are processed by Enrichment. However, they do not contain any meaningful data. Here’s an example of such a request taken from bad row logs.

{
  "_index": "snowplow",
  "_type": "bad_rows",
  "_id": "AVM7XuqOi4wlDuAN6icW",
  "_score": null,
  "_source": {
    "line": "2016-03-02\t19:00:47\t-\t-\t66.249.73.212\tOPTIONS\t66.249.73.212\t/com.snowplowanalytics.snowplow/tp2\t200\thttps://www.company.com/pet-boarding/nsw/kogarah\tMozilla%2F5.0+%28compatible%3B+Googlebot%2F2.1%3B+%2Bhttp%3A%2F%2Fwww.google.com%2Fbot.html%29\t&cv=clj-1.1.0-tom-0.2.0&nuid=-\t-\t-\t-\t-\t-",
    "errors": [
      {
        "level": "error",
        "message": "Unrecognized event [null]"
      }
    ],
    "failure_tstamp": "2016-03-03T07:02:46.465Z"
  },
  "fields": {
    "failure_tstamp": [
      1456988566465
    ]
  }
}

Note the message “Unrecognized event [null]”. They can safely be ignored as they don’t represent failed attempts to send data.

How can these be filtered out?

If you are logging bad row with Elasticsearch/Kibana you can filter these out using the following query in Kibana:

-errors.message:"does not match (/)vendor/version(/) pattern nor is a legacy /i(ce.png) request" AND -errors.message:"Unrecognized event [null]"

Regards,
Ihor

3 Likes