{"id":243,"date":"2012-03-16T18:22:17","date_gmt":"2012-03-17T01:22:17","guid":{"rendered":"http:\/\/www.dreness.com\/blog\/?p=243"},"modified":"2012-03-16T18:22:17","modified_gmt":"2012-03-17T01:22:17","slug":"gnuplot-time-series-buckets-quickie","status":"publish","type":"post","link":"https:\/\/dreness.com\/blog\/archives\/243","title":{"rendered":"Gnuplot time-series buckets quickie"},"content":{"rendered":"<p>Let&#8217;s say you&#8217;ve got a log file of events with time stamps; the nature of the events isn&#8217;t relevant, and let&#8217;s say the stamps look like this:<\/p>\n<pre>14\/Mar\/2012:17:49:34\r\n14\/Mar\/2012:17:49:34\r\n14\/Mar\/2012:17:49:39\r\n14\/Mar\/2012:17:49:40\r\n14\/Mar\/2012:17:49:41\r\n14\/Mar\/2012:17:49:58\r\n14\/Mar\/2012:17:51:46\r\n14\/Mar\/2012:17:51:46\r\n14\/Mar\/2012:17:52:56\r\n14\/Mar\/2012:17:52:56\r\n14\/Mar\/2012:17:52:57\r\n14\/Mar\/2012:17:52:57\r\n14\/Mar\/2012:17:53:16\r\n14\/Mar\/2012:17:53:17\r\n14\/Mar\/2012:17:53:17<\/pre>\n<p>You want to create a graph of the frequency of events in the log file, with time on the x and frequency on the y. An easy tactic here is to put the events into buckets, and then find the count of items in each bucket. If we use a bucket size of one minute, we can simply lop off the seconds field, and then use &#8216;uniq -c&#8217; to produce our frequency count for each minute:<\/p>\n<pre>cat test | cut -d: -f 1-3 | uniq -c\r\n 6 14\/Mar\/2012:17:49\r\n 2 14\/Mar\/2012:17:51\r\n 4 14\/Mar\/2012:17:52\r\n 3 14\/Mar\/2012:17:53<\/pre>\n<p>Then with gnuplot:<\/p>\n<pre>set xdata time\r\nset timefmt \"%d\/%b\/%Y:%H:%M\"\r\nplot 'events_per_minute.txt' using 2:1 title \"events per minute\" with impulses<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Let&#8217;s say you&#8217;ve got a log file of events with time stamps; the nature of the events isn&#8217;t relevant, and let&#8217;s say the stamps look like this: 14\/Mar\/2012:17:49:34 14\/Mar\/2012:17:49:34 14\/Mar\/2012:17:49:39 14\/Mar\/2012:17:49:40 14\/Mar\/2012:17:49:41 14\/Mar\/2012:17:49:58 14\/Mar\/2012:17:51:46 14\/Mar\/2012:17:51:46 14\/Mar\/2012:17:52:56 14\/Mar\/2012:17:52:56 14\/Mar\/2012:17:52:57 14\/Mar\/2012:17:52:57 14\/Mar\/2012:17:53:16 &hellip; <a href=\"https:\/\/dreness.com\/blog\/archives\/243\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-243","post","type-post","status-publish","format-standard","hentry","category-scripts"],"_links":{"self":[{"href":"https:\/\/dreness.com\/blog\/wp-json\/wp\/v2\/posts\/243","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dreness.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dreness.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dreness.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dreness.com\/blog\/wp-json\/wp\/v2\/comments?post=243"}],"version-history":[{"count":1,"href":"https:\/\/dreness.com\/blog\/wp-json\/wp\/v2\/posts\/243\/revisions"}],"predecessor-version":[{"id":244,"href":"https:\/\/dreness.com\/blog\/wp-json\/wp\/v2\/posts\/243\/revisions\/244"}],"wp:attachment":[{"href":"https:\/\/dreness.com\/blog\/wp-json\/wp\/v2\/media?parent=243"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dreness.com\/blog\/wp-json\/wp\/v2\/categories?post=243"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dreness.com\/blog\/wp-json\/wp\/v2\/tags?post=243"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}