{"id":14260,"date":"2020-06-26T14:06:07","date_gmt":"2020-06-26T14:06:07","guid":{"rendered":"https:\/\/merikebi.warrenmyers.com\/?p=14260"},"modified":"2020-06-26T14:06:07","modified_gmt":"2020-06-26T14:06:07","slug":"new-comment-on-reddit-1371","status":"publish","type":"post","link":"https:\/\/merikebi.warrenmyers.com\/?p=14260","title":{"rendered":"New comment on reddit"},"content":{"rendered":"<div class=\"md\">\n<p>If you&#39;ve got normal* Apache logs, you can do this:<\/p>\n<pre><code>cd \/var\/log\/httpd cut -d &#39; &#39; -f1 access_log | sort -u | wc -l <\/code><\/pre>\n<p>This uses a space as a delimiter, grab the first field, which is the visiting IP address, pipe into <code>sort -u<\/code> to get unique values, pipe into <code>wc -l<\/code> to get a line count<\/p>\n<p>It&#39;s not a perfect count &#8211; this aggregates IP addresses across all the days of your log file (my <code>logrotate<\/code> configs ensure I never have more than a week&#39;s worth of data in a given log file), and doesn&#39;t differentiate between &quot;real&quot; visits and crawlers, but it&#39;s <strong><em>A<\/em><\/strong> metric that&#39;s quick and likely not more than an order of magnitude too large<\/p>\n<p>Here&#39;s a version that&#39;ll do the same &#8211; but on unique <code>GET<\/code> requests:<\/p>\n<pre><code>cut -d &#39;&quot;&#39; -f2 access_log | grep GET | sort -u | wc -l <\/code><\/pre>\n<p>This one uses the double-quote mark as a delimiter, and selects the second field (which should be the actual HTTP request (<code>GET<\/code> or <code>POST<\/code>))<\/p>\n<p><em>Personally<\/em>, I&#39;d recommend running Splunk in free mode, ingest your web server logs, and see what you can do with them \ud83d\ude42<\/p>\n<hr\/>\n<p>* by &quot;normal&quot;, I mean your log lines look something like this:<\/p>\n<pre><code> 62.210.215.113 - - [21\/Jun\/2020:03:20:17 +0000] &quot;GET \/2011\/08\/11\/connexions\/feed\/ HTTP\/1.1&quot; 200 812 &quot;-&quot; &quot;Mozilla\/5.0 (X11; Linux i686) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/30.0.1599.66 Safari\/537.36&quot; <\/code><\/pre>\n<\/p><\/div>\n<p>June 26, 2020 at 09:58AM<br \/>\nvia reddit https:\/\/www.reddit.com\/r\/selfhosted\/comments\/hfrbx6\/best_way_to_get_a_view_count_on_a_selfhosted_blog\/fw29r2k?utm_source=ifttt<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you&#39;ve got normal* Apache logs, you can do this: cd \/var\/log\/httpd cut -d &#39; &#39; -f1 access_log | sort -u | wc -l This uses a space as a delimiter, grab the first field, which is the visiting IP address, pipe into sort -u to get unique values, pipe into wc -l to get &hellip;<br \/><a href=\"https:\/\/merikebi.warrenmyers.com\/?p=14260\" class=\"more-link pen_button pen_element_default pen_icon_arrow_double\">Continue reading <span class=\"screen-reader-text\">New comment on reddit<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_hide_featured_image":false,"_jetpack_featured_image_duplicate_dismissed":0,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[4],"tags":[972],"keyring_services":[],"class_list":["post-14260","post","type-post","status-publish","format-standard","hentry","category-blih","tag-reddit"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=\/wp\/v2\/posts\/14260","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=14260"}],"version-history":[{"count":1,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=\/wp\/v2\/posts\/14260\/revisions"}],"predecessor-version":[{"id":14261,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=\/wp\/v2\/posts\/14260\/revisions\/14261"}],"wp:attachment":[{"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=14260"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=14260"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=14260"},{"taxonomy":"keyring_services","embeddable":true,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Fkeyring_services&post=14260"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}