Rollbarでbotが出すエラーを無視する
botから既に削除されたURLへのアクセスがあり,Rollbarのエラーログのノイズがひどかったので,botからのアクセスで起こったActiveRecord::RecordNotFoundを無視する設定を書きました.
jsonでCustom Groupを定義します.
ボットからのアクセスで起こったActiveRecord::RecordNotFoundをグルーピングするには次のようなjsonで定義できます.
[ { "title": "Bot error", "fingerprint": "bot-error", "condition": { "all": [ { "path": "request.headers.User-Agent", "in": [ "Mozilla/5.0 (compatible; AhrefsBot/5.1; +http://ahrefs.com/robot/)", "Mozilla/5.0 (compatible; Yahoo! Slurp; http://help.yahoo.com/help/us/ysearch/slurp)", "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)", "Mozilla/5.0 (iPhone; CPU iPhone OS 7_0 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11A465 Safari/9537.53 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)", "Mozilla/5.0 (compatible; Exabot/3.0; +http://www.exabot.com/go/robot)" ] }, { "path": "body.trace.exception.class", "eq": "ActiveRecord::RecordNotFound" } ] } } ]
このpathはOccurrenceのRawJSONで出力されているログのパス。 リファレンスはこちら。 in以外にもeqやcontainなどがあります.
https://rollbar.com/docs/custom-grouping/
JSONが書けたら入力欄左下にあるボックスにoccurrence IDを入力してマッチさせたいエラーにマッチするか確認できます.
次にエラーが起こるとBot errorとしてグルーピングされるのでそれをmuteするとDashboardに表示されなくなります. 逆に特定のエラーグループのlevelをwarningからcriticalに上げることもできたりもします.