forked from ibmecod/bluemix-days-cloudtrader-java
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pipes.json.txt
43 lines (43 loc) · 30 KB
/
pipes.json.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# Auto Generated. Improper modifications to this data may hamper importing of pipes.
[
{
"code": "def message(index, configuration):\n import uuid\n msg_uniq_id = str((uuid.uuid4()).int)\n \n html_template = \"\"\"\n <html>\n <head>\n <script lang=\"javascript/text\">\n $(function() {\n\t$(\"input#msg_pipe_dosearch%(msg_uniq_id)s\").val('*');\n\t$(\"#msg_pipe_loading%(msg_uniq_id)s\").html('<img src=\"/iwap/images/busy.gif\"> loading...')\n\t$.ajax({\n type: \"GET\",\n url: \"/iwap/v1/insights/message_util\",\n data:\"searchquery=*&duration=Hour\",\n async: true,\t\t\t\t\n success: function (data) {\n $(\"#msg_pipe_searchbody%(msg_uniq_id)s\").html(data);\n\t\t $('#msg_pipe_loading%(msg_uniq_id)s').html(\"\");\n }\n });\n\t\n\t$(\"input#msg_pipe_dosearch%(msg_uniq_id)s\").on('keyup', function (e){\n\t\te.preventDefault(); \n\t\t\n\t\tif (e.which == 13 &&!e.shiftKey ) {\n e.stopPropagation();\n duration=$(\"#timeline%(msg_uniq_id)s .btn-primary\").attr(\"value\");\n var query = $(\"input#msg_pipe_dosearch%(msg_uniq_id)s\").val();\n\t\t $(\"#msg_pipe_loading%(msg_uniq_id)s\").html('<img src=\"/iwap/images/busy.gif\"> loading...')\n $.ajax({\n type: \"GET\",\n url: \"/iwap/v1/insights/message_util\",\n data:\"searchquery=\"+ query+\"&duration=\"+duration,\n async: true,\t\t\t\t\n success: function (data) {\n $(\"#msg_pipe_searchbody%(msg_uniq_id)s\").html(data);\n \t\t\t $('#msg_pipe_loading%(msg_uniq_id)s').html(\"\");\n }\n });\n \t}\n\t});\n \n \n\t$(\"#timeline%(msg_uniq_id)s button.btn\").live(\"click\", function() {\n\t\tvar duration1 = $(this).val();\n\t\t$(\"#timeline%(msg_uniq_id)s button.btn\").removeClass(\"btn-primary\");\n \t$(this).addClass(\"btn-primary\");\n\t\t$(\"input#msg_pipe_dosearch%(msg_uniq_id)s\").val('*');\n\t\t$(\"#msg_pipe_loading%(msg_uniq_id)s\").html('<img src=\"/iwap/images/busy.gif\"> loading...')\n\t\t\t\t\n \t$.ajax({\n type: \"GET\",\n url: \"/iwap/v1/insights/message_util\",\n data:\"searchquery=*&duration=\"+duration1,\n async: true,\t\t\t\t\n success: function (data) {\n $(\"#msg_pipe_searchbody%(msg_uniq_id)s\").html(data);\n\t\t $(\"#msg_pipe_loading%(msg_uniq_id)s\").html(\"\");\n }\n \t});\n \t});\n });\n </script>\n </head>\n \n <body>\n <div id=\"lib_msg_search_div_id%(msg_uniq_id)s\" style=\"margin-left:10px; margin-top:30px;\">\n \n\t<div class='float-left' id='msg_log_search%(msg_uniq_id)s'> \n <fieldset class='ui-helper-reset'> \n <input class='form-control searchbar' id=\"msg_pipe_dosearch%(msg_uniq_id)s\" style=\"margin-top: 0px; height: 1.4em\" type='text' placeholder='search ...' value=''> \n </fieldset> \n \n </div> \n\t\n\t<div class='float-right' id=\"msg_pipe_timeline%(msg_uniq_id)s\" >\n <span id=\"timeline%(msg_uniq_id)s\" class=\"btn-group btn-group-sm\">\n <!--<input type=\"radio\" id=\"msg_timelinehr%(msg_uniq_id)s\" name=\"msg_duration\" value=\"Hour\" checked=\"checked\"/><label for=\"msg_timelinehr%(msg_uniq_id)s\">1 Hour</label>\n <input type=\"radio\" id=\"msg_timelineday%(msg_uniq_id)s\" name=\"msg_duration\" value=\"Day\" /><label for=\"msg_timelineday%(msg_uniq_id)s\">1 Day</label>\n <input type=\"radio\" id=\"msg_timelineweek%(msg_uniq_id)s\" name=\"msg_duration\"value=\"Week\" /><label for=\"msg_timelineweek%(msg_uniq_id)s\" >1 Week</label>\n <input type=\"radio\" id=\"msg_timelinemonth%(msg_uniq_id)s\" name=\"msg_duration\"value=\"Month\" /><label for=\"msg_timelinemonth%(msg_uniq_id)s\" >1 Month</label>\n -->\n\t\t<button type=\"button\" class=\"btn btn-default btn-primary\" value=\"Hour\">1 Hour</button>\n\t\t<button type=\"button\" class=\"btn btn-default\" value=\"Day\">1 Day</button>\n\t\t<button type=\"button\" class=\"btn btn-default\" value=\"Week\">1 Week</button>\n\t\t<button type=\"button\" class=\"btn btn-default\" value=\"Month\">1 Month</button>\n </span>\n\t</div>\n\n </div>\n <div id=\"msg_pipe_loading%(msg_uniq_id)s\"><br></div>\n\n <div id=\"msg_pipe_searchbody%(msg_uniq_id)s\"></div>\n \n </body>\n\n</html>\n \"\"\"\n return html_template% { 'msg_uniq_id' : msg_uniq_id }",
"description": "Pipe description goes here",
"userID": "95e949a10fd8471390b966cbe9bb66f8",
"tenantID": "95e949a10fd8471390b966cbe9bb66f8",
"version": "v1",
"pipename": "message"
},
{
"code": "\ndef access(index, configuration):\n import uuid\n uniqueid = str((uuid.uuid4()).int)\n \n html_template = \"\"\"\n <html>\n <head>\n <script lang=\"javascript/text\">\n $(function() {\t\n\t$(\"input#dosearch%(uniqueid)s\").val('*');\n\t$(\"#acc_pipe_loading%(uniqueid)s\").html('<img src=\"/iwap/images/busy.gif\"> loading...');\n var initqry='*';\n var initduration='Hour';\n $.ajax({\n type: \"GET\",\n url: \"/iwap/v1/insights/access_util\",\n data:\"searchquery=\"+initqry+\"&duration=\"+initduration,\n async: true,\t\t\t\t\n success: function (data) {\n $(\"#acc_log_searchbody%(uniqueid)s\").html(data);\n $('#acc_pipe_loading%(uniqueid)s').html(\"\");\n }\n });\n\t\n\t$(\"input#dosearch%(uniqueid)s\").on('keyup', function (e) {\n\t e.preventDefault(); \n if (e.which == 13 &&!e.shiftKey ) { \n e.stopPropagation();\n\t var duration=null;\n\t duration=$(\"#timeline%(uniqueid)s .btn-primary\").attr(\"value\");\n var query = $(\"input#dosearch%(uniqueid)s\").val();\n $(\"#acc_pipe_loading%(uniqueid)s\").html('<img src=\"/iwap/images/busy.gif\"> loading...')\n $.ajax({\n type: \"GET\",\n url: \"/iwap/v1/insights/access_util\",\n data:\"searchquery=\"+ query+\"&duration=\"+duration,\n async: true,\t\t\t\t\n success: function (data) {\n $(\"#acc_log_searchbody%(uniqueid)s\").html(data);\n $('#acc_pipe_loading%(uniqueid)s').html(\"\");\n }\n });\t\t\n }\n });\n\n $(\"#timeline%(uniqueid)s button.btn\").live(\"click\", function() {\n\t console.log($(\".btn-group btn-group-sm > button.btn\").html());\n var duration1 = $(this).val();\n $(\"#timeline%(uniqueid)s button.btn\").removeClass(\"btn-primary\");\n $(this).addClass(\"btn-primary\");\n $(\"input#dosearch%(uniqueid)s\").val('*');\n $(\"#acc_pipe_loading%(uniqueid)s\").html('<img src=\"/iwap/images/busy.gif\"> loading...') \n $.ajax({\n type: \"GET\",\n url: \"/iwap/v1/insights/access_util\",\n data:\"searchquery=*&duration=\"+duration1,\n async: true,\t\t\t\t\n success: function (data) {\n $(\"#acc_log_searchbody%(uniqueid)s\").html(data);\n $('#acc_pipe_loading%(uniqueid)s').html(\"\");\n }\n });\n }); \n\n }); \n </script></head>\n <body>\n <div id=\"access_log_lib_id%(uniqueid)s\" style=\"margin-left:10px; margin-top:30px;\">\n <div class='float-left' id='acc_log_search_div%(uniqueid)s'> \n <fieldset class='ui-helper-reset'> \n <input class='form-control searchbar' id=\"dosearch%(uniqueid)s\" style=\"margin-top: 0px; height: 1.4em\" type='text' placeholder='search ...' value=''> \n </fieldset> \n \n </div> \n <div id=\"acc_pipe_lib_dur_id%(uniqueid)s\" class='float-right'>\n <span id=\"timeline%(uniqueid)s\" class=\"btn-group btn-group-sm\">\n\t\t<button type=\"button\" class=\"btn btn-default btn-primary\" value=\"Hour\">1 Hour</button>\n\t\t<button type=\"button\" class=\"btn btn-default\" value=\"Day\">1 Day</button>\n\t\t<button type=\"button\" class=\"btn btn-default\" value=\"Week\">1 Week</button>\n\t\t<button type=\"button\" class=\"btn btn-default\" value=\"Month\">1 Month</button>\n </span>\n </div>\n\n \t<div id=\"acc_pipe_loading%(uniqueid)s\"><br></div>\n\t<div id=\"acc_log_searchbody%(uniqueid)s\"><br></div>\n\n </div>\n \n \n </body></html>\n \"\"\"\n return html_template % { 'uniqueid' : uniqueid }",
"description": "Pipe based on liberty_access",
"userID": "95e949a10fd8471390b966cbe9bb66f8",
"tenantID": "95e949a10fd8471390b966cbe9bb66f8",
"version": "v1",
"pipename": "access"
},
{
"code": "\ndef TraderAppActivities(index, configuration):\n query=\"(queryString.action:buy OR queryString.action:sell)\"\n duration='Day'\n result = search_hits(index, 'liberty_access', query, sort=[{'datetime':'desc'}], start=0, size=1, fields=[])\n #print str(result[0]['queryString']['symbol']),str(result[0]['queryString']['quantity'])\n if not result :\n return \"No Results Available\"\n endTime = datetime.datetime.strptime(str(result[0]['datetime']),\"%Y-%m-%dT%H:%M:%S\")\n #Calculate base list\n baseList = list()\n if duration == 'Month':\n monthBaseList = list() \n for i in range(0,31):\n endTimeNight = datetime.datetime(endTime.year, endTime.month, endTime.day, 0, 0, 0, 0)\n endTimeLong = calendar.timegm(endTimeNight.utctimetuple())*1000\n beginningOfDaysForOneMonthLong = endTimeLong - i*24*60*60*1000\n monthBaseList.append({'count':0,'time':beginningOfDaysForOneMonthLong })\n baseList = monthBaseList\n elif duration == 'Week':\n weekBaseList = list() \n for i in range(0,7):\n endTimeNight = datetime.datetime(endTime.year, endTime.month, endTime.day, 0, 0, 0, 0)\n endTimeLong = calendar.timegm(endTimeNight.utctimetuple())*1000\n beginningOfDaysForOneMonthLong = endTimeLong - i*24*60*60*1000\n weekBaseList.append({'count':0,'time':beginningOfDaysForOneMonthLong })\n baseList = weekBaseList\n elif duration == 'Day':\n dayBaseList = list() \n for i in range(0,24):\n endTimeHour= datetime.datetime(endTime.year, endTime.month, endTime.day, endTime.hour, 0, 0, 0)\n endTimeLong = calendar.timegm(endTimeHour.utctimetuple())*1000\n beginningOfHoursForOneDayLong = endTimeLong - i*60*60*1000\n dayBaseList.append({'count':0,'time':beginningOfHoursForOneDayLong })\n baseList = dayBaseList\n elif duration == 'Hour':\n hourBaseList = list() \n for i in range(0,60):\n endTimeMin= datetime.datetime(endTime.year, endTime.month, endTime.day, endTime.hour, endTime.minute, 0, 0)\n endTimeLong = calendar.timegm(endTimeMin.utctimetuple())*1000\n beginningOfMinutesForOneHourLong = endTimeLong - i*60*60*1000\n hourBaseList.append({'count':0,'time':beginningOfMinutesForOneHourLong })\n baseList = hourBaseList\n\n #Calculate event list\n endTime_ms = calendar.timegm(endTime.utctimetuple())*1000\n if duration=='Day':\n timerange=24*60*60*1000;\n interval='hour'\n elif duration=='Week':\n timerange=7*24*60*60*1000;\n interval='day'\n elif duration=='Month':\n timerange=30*24*60*60*1000;\n interval='day'\n elif duration=='Hour':\n timerange=1*60*60*1000;\n interval='minute'\n #print timerange\n #print interval\n startTime_ms = endTime_ms - timerange;\n allquery = \" AND datetime:[\"+ str(startTime_ms) +\" TO \"+ str(endTime_ms)+\"]\"\n\n all = tuples(search_datetimefacet(index,'liberty_access',query+allquery, interval),['time','count'])\n\n\n #Normalize\n nList= normalize(tuples(baseList,['time','count']),all)\n #print nList\n\n list1 = map(lambda d: {\"time\":d[0], \"count\":d[1]} ,nList)\n\n #start of time line\n keys = ['time', ['count']]\n style = {'width': 1000, 'height': 250}\n hAxis = {'tickDisplayAngle': 20,'label': 'Time'}\n vAxis = {'label': 'Buy/Sell Activities'}\n timeline_html='<br><br><h4 style=\"text-align:center;padding-left:32px;\">Buy/Sell Activity 24 Hr Timeline</h4><br>'\n timeline_html += chart_timeline(list1, keys, style=style,legends=None, hAxis=hAxis, vAxis=vAxis)\n #end of time line\n #Activities bubble chart\n activities=search_termsfacet(index, 'liberty_access', '*' , 'queryString.action', size=100, order='count') \n #activity_chart= chart_bubble (activities, ['term','count'], style={'width':450, 'height':450})\n activity_table = \"<table id='hor-zebra' style='width:100%'>\"\n activity_table +=\"<caption><h4 style='text-align:middle;font-size:13px;font-family:Verdana,arial,sans-serif'>Cloud Trader Activities</h4></caption>\"\n activity_table += \"<tr><th>Activities</th></tr>\"\n activity_table += \"<tr><td align='middle'>\"+chart_bubble (activities, ['term','count'], style={'width':470, 'height':470})+\"</td></tr>\"\n # commenting the errors system errors and \n rerr=len(search_hits(index,'liberty_message','severity:R',fields=['methodName'],size=500))\n apperr=len(search_hits(index,'liberty_message','severity:E',fields=['methodName'],size=500))\n syserr=\"<span style='font-family:Verdana,Arial,sans-serif;font-size:14px;font-weight:700;'>System Errors\"+chart_box(str(rerr),\"\")+\"</span>\"\n applerr=\"<span style='font-family:Verdana,Arial,sans-serif;font-size:14px;font-weight:700;'>App Errors\"+chart_box(str(apperr),\"\")+\"</span>\"\n #activity_table+=\"<td>\"+syserr+applerr+\"</td></tr>\"\n\n activity_table+=\"</table>\"\n #buy sell table\n buysell_table = \"<table id='hor-zebra' style='width:100%'>\"\n buysell_table +=\"<caption><h4 style='text-align:middle;font-size:13px;font-family:Verdana,arial,sans-serif'>Top Buys by Volume </h4></caption>\"\n buysell_table += \"<tr><th align='center'>Buy Details</th></tr>\"\n\n #top buys by Volume \n topbuysresult= search_hits(index, 'liberty_access', 'queryString.action:buy', sort=[{'datetime':'desc'}], start=0, size=300, fields=['queryString.symbol','queryString.quantity'])\n s1=[element for element in topbuysresult if int(element[\"queryString.quantity\"]) > 0]\n buysell_table+=\"<td align='middle'>\"+chart_bar(s1,['queryString.symbol','queryString.quantity'] ,legends=None,style={'width':450, 'height':250 }, hAxis={'label':'symbol'}, vAxis={'label':'quantity' })+\"</td></tr>\"\n buysell_table+=\"</table>\"\n\n\n results = search_termsfacet(index, 'liberty_access', query+allquery, 'uriPath', size=15)\n #results= search_termsfacet(index, 'liberty_access',' * AND datetime:\\[1388415538000 TO 1391007538000\\]','uriPath',size=5)\n\n responseTime = []\n responseCode = []\n for respath in results:\n \timport re\n \tESCAPE_CHARS_RE = re.compile(r'(?<!\\\\)(?P<char>[&|+\\\\\\-!(){}[\\]/^\"~*?:])')\n strUriPath=ESCAPE_CHARS_RE.sub(r'\\\\\\g<char>', str(respath['term']))\n \tresult=search_termsstatisticalfacet(index, 'liberty_access', query+allquery+' AND uriPath:'+str(strUriPath),'uriPath' ,'elapsedTime', size=5)\n #print query+' AND uriPath:'+str(respath['term'])+allquery\n responseTime.append({'uripath': str(respath['term']), 'mean': round(result[0]['mean']/1000, 3)})\n result=search_termsfacet(index, 'liberty_access', query+' AND uriPath:'+str(strUriPath)+allquery, 'responseCode', size=5, order='count') \n responseCode.append(map(lambda d: { 'count': str(d['count']), 'term': str(d['term']) }, result))\n\n keys3 = ['term', 'count']\n style3 = { 'outerRadius': 52, 'innerRadius': 25, 'colors': colors_category20() }\n legend3 = { 'position':'right', 'width': 100, 'height': 0 }\n #table_html ='<div id=\"div_id_acc_title\" style=\"text-align:center\"><h2>Top Resources by Usage</h2></div>'\n table_html = \"<table id='hor-zebra' style='width:100%'>\"\n table_html +=\"<caption><h4 style='text-align:middle;font-size:13px;font-family:Verdana,arial,sans-serif'>Resource latency and Response codes</h4></caption>\"\n table_html += \"<tr><th>Resource</th><th>Avg Response Time (ms) </th><th> Response codes</th></tr>\"\n table_html += reduce(lambda x,y: x + y , map(lambda x, y: \"<tr><td>\" + x['uripath'] + \"</td><td>\" + str(x['mean']) +\"</td><td>\" + chart_pie(y, keys3, style=style3, legends=legend3) +\"</td></tr>\", responseTime, responseCode))\n table_html += \"</table>\"\n return activity_table+buysell_table+timeline_html + table_html ",
"description": "Pipe description goes here",
"userID": "95e949a10fd8471390b966cbe9bb66f8",
"tenantID": "95e949a10fd8471390b966cbe9bb66f8",
"version": "v1",
"pipename": "TraderAppActivities"
},
{
"code": "\ndef message_util(index, configuration):\n query = configuration['searchquery'][0]\n duration = configuration['duration'][0]\n # beginning of time line\n result = search_hits(index, 'liberty_message', query, sort=[{'datetime':'desc'}], start=0, size=1, fields=[])\n if not result :\n return \"No Results Available\"\n try:\n endTime= datetime.datetime.strptime(str(result[0]['datetime']),\"%Y-%m-%dT%H:%M:%S.%f\")\n except: \n endTime= datetime.datetime.strptime(str(result[0]['datetime']),\"%Y-%m-%dT%H:%M:%S\")\n \n #Calculate base li#st\n baseList = list()\n if duration == 'Month':\n monthBaseList = list() \n for i in range(0,31):\n endTimeNight = datetime.datetime(endTime.year, endTime.month, endTime.day, 0,0, 0)\n endTimeLong = calendar.timegm(endTimeNight.utctimetuple())*1000\n beginningOfDaysForOneMonthLong = endTimeLong - i*24*60*60*1000\n monthBaseList.append({'count':0,'time':beginningOfDaysForOneMonthLong })\n baseList = monthBaseList\n elif duration == 'Week':\n weekBaseList = list() \n for i in range(0,7):\n endTimeNight = datetime.datetime(endTime.year, endTime.month, endTime.day,0,0, 0)\n endTimeLong = calendar.timegm(endTimeNight.utctimetuple())*1000\n beginningOfDaysForOneWeekLong = endTimeLong - i*24*60*60*1000\n weekBaseList.append({'count':0,'time':beginningOfDaysForOneWeekLong})\n baseList = weekBaseList\n elif duration == 'Day':\n dayBaseList = list() \n for i in range(0,24):\n endTimeHour= datetime.datetime(endTime.year, endTime.month, endTime.day, endTime.hour, endTime.minute,0, 0)\n endTimeLong = calendar.timegm(endTimeHour.utctimetuple())*1000\n beginningOfHoursForOneDayLong = endTimeLong - i*60*60*1000\n dayBaseList.append({'count':0,'time':beginningOfHoursForOneDayLong })\n baseList = dayBaseList\n elif duration == 'Hour':\n hourBaseList = list() \n for i in range(0,60):\n endTimeMin= datetime.datetime(endTime.year, endTime.month, endTime.day, endTime.hour, endTime.minute,endTime.second, endTime.microsecond)\n endTimeLong = calendar.timegm(endTimeMin.utctimetuple())*1000\n beginningOfMinutesForOneHourLong = endTimeLong - i*60*1000\n hourBaseList.append({'count':0,'time':beginningOfMinutesForOneHourLong })\n baseList = hourBaseList\n #Calculate event list\n endTime_ms = calendar.timegm(endTime.utctimetuple())*1000 +endTime.microsecond/1000\n if duration=='Day':\n timerange=24*60*60*1000;\n interval='hour'\n elif duration=='Week':\n timerange=7*24*60*60*1000;\n interval='day'\n elif duration=='Month':\n timerange=30*24*60*60*1000;\n interval='day'\n elif duration=='Hour':\n timerange=1*60*60*1000;\n interval='minute'\n startTime_ms = endTime_ms - timerange;\n allquery = \" AND datetime:[\"+ str(startTime_ms) +\" TO \"+ str(endTime_ms)+\"]\"\n all = tuples(search_datetimefacet(index,'liberty_message',query+allquery, interval),['time','count'])\n nList= normalize(tuples(baseList,['time','count']),all)\n\n #Tuples baselist\n bList= tuples(baseList,['time','count'])\n elist = normalize(all, tuples(search_datetimefacet(index, 'liberty_message', query + allquery + ' AND severity:E', interval),['time','count']))\n alist = normalize(all, tuples(search_datetimefacet(index, 'liberty_message', query+ allquery + ' AND severity:A', interval),['time','count']))\n ilist = normalize(all, tuples(search_datetimefacet(index, 'liberty_message', query+allquery + ' AND severity:I', interval),['time','count']))\n olist = normalize(all, tuples(search_datetimefacet(index, 'liberty_message', query+allquery + ' AND severity:O', interval),['time','count']))\n slist = map(lambda b,e,a,i,o: {\"time\":b[0], \"E\":e[1], \"A\":a[1], \"I\":i[1], \"O\":o[1]}, \\\n all, elist, alist, ilist, olist) \n \n keys = ['time', ['E','A','I','O']]\n style = {'width': 1000, 'height': 350}\n hAxis = {'tickDisplayAngle': 20,'label': 'Time'}\n vAxis = {'label': ' Message Log Events'}\n \n timeline_html='<br><br><h4 style=\"text-align:left;padding-left:37px;\">Message Log Timeline</h4><br>'\n timeline_html += chart_timeline(slist, keys, style=style, hAxis=hAxis, vAxis=vAxis)\n #end of time line\n results = search_termsfacet(index, 'liberty_message',query+ allquery + ' AND severity:E', 'messageId', size=5, order='count')\n \n list2 = results\n keys2 = ['term', 'count']\n style2 = { 'outerRadius': 100, 'innerRadius': 50, 'colors': colors_category20() }\n legend2 = { 'position':'right', 'width': 300, 'height': 0 }\n pie2_html = chart_pie (list2, keys2, style=style2, legends=legend2)\n \n #div_html='<br><h2>Error Distribution</h2></div><br>'\n #chart_html= div_html+pie2_html\n # heatmap \n results=search_termsfacets_filters(index, 'liberty_message', query+ allquery + ' AND severity:E',['source'], ['source'], ['*','*'], size=50, order='count')\n resterms = results['source']['terms']\n source_distribution_chart=chart_pie(resterms,['term','count'],style={ 'colors': colors_category10() })\n error_dist_table='''\n<table id=\"hor-zebra1\"><thead><tr><th class=\"eventtypes\">\n<div id=\"div_msg_tab_row\" style=\"width:500px;text-align:left;\"><h4 style=\"padding-left:38px;\"> Error sources</h4></div></th>\n<th><div id=\"div_msg_spacer_row\" style=\"width:50px;\"></div></th>\n<th><div id=\"div_msg_err_row\" style=\"width:220px;text-align:left;\"><h4>Error message ids </h4></div></th>\n</tr></thead><tbody id=\"treemapId\">\n '''\n error_dist_table+='<tr><td style=\"padding-left:14px;\">'+source_distribution_chart+'</td>'\n error_dist_table+='<td></td>'\n error_dist_table+='<td>'+pie2_html+'</td></tr></tbody></table>'\n \n #end of heatmap\n table_header=''\n table_html='''\n<div style=\"overflow:auto; height:300px;\">\n<table id=\"hor-zebra\"><div id=\"div_la_fiverr_row\" style=\"text-align:left;\"><caption><h4 style='text-align:left'>Last 50 errors</h4></caption></div>\n</div><tr><th><div id=\"div_la_src_row\" style=\"width:200px;text-align:left;\">Source</div></th>\n<th><div id=\"div_la_dt_row\" style=\"width:200px;text-align:left;\"><span>Date</span></div></th>\n<th><div id=\"div_la_msgId_row\" style=\"width:200px;text-align:left;\"><span>Message Id</span></div></th>\n<th><div id=\"div_la_msg_row\" style=\"width:300px;text-align:middle;\">Messages</div></th>\n<tbody id=\"searchbody\">\n '''\n top5results=search_hits(index, 'liberty_message', query+allquery+' AND severity:E', sort=[{'datetime':'desc'}], start=0, size=50)\n tablecontent=''\n if not top5results :\n tablecontent+='<tr><td> No Results Available </td></tr>'\n for hit in top5results:\n tablecontent+='<tr><td>'+str(hit['source'])+'</td>'\n tablecontent+='<td>'+str(hit['datetime'])+'</td>'\n tablecontent+='<td>'+str(str(hit['messageId']))+'</td>'\n tablecontent+='<td>'+str(str(hit['message']))+'</td>'\n tablecontent+='</tr>'\n table_html+=tablecontent+'</tbody></table></div>'\n \n return timeline_html+error_dist_table+table_header+table_html",
"description": "Utility Pipe for message",
"userID": "95e949a10fd8471390b966cbe9bb66f8",
"tenantID": "95e949a10fd8471390b966cbe9bb66f8",
"version": "v1",
"pipename": "message_util"
},
{
"code": "\ndef access_util(index, configuration):\n query = configuration['searchquery'][0]\n duration = configuration['duration'][0] \n #query=\"*\"\n #duration=\"Day\"\n # beginning of time line\n result = search_hits(index, 'liberty_access', query, sort=[{'datetime':'desc'}], start=0, size=1, fields=[])\n if not result :\n return \"No Results Available\"\n endTime = datetime.datetime.strptime(str(result[0]['datetime']),\"%Y-%m-%dT%H:%M:%S\")\n #Calculate base list\n baseList = list()\n if duration == 'Month':\n monthBaseList = list() \n for i in range(0,31):\n endTimeNight = datetime.datetime(endTime.year, endTime.month, endTime.day, 0, 0, 0, 0)\n endTimeLong = calendar.timegm(endTimeNight.utctimetuple())*1000\n beginningOfDaysForOneMonthLong = endTimeLong - i*24*60*60*1000\n monthBaseList.append({'count':0,'time':beginningOfDaysForOneMonthLong })\n baseList = monthBaseList\n elif duration == 'Week':\n weekBaseList = list() \n for i in range(0,7):\n endTimeNight = datetime.datetime(endTime.year, endTime.month, endTime.day, 0, 0, 0, 0)\n endTimeLong = calendar.timegm(endTimeNight.utctimetuple())*1000\n beginningOfDaysForOneMonthLong = endTimeLong - i*24*60*60*1000\n weekBaseList.append({'count':0,'time':beginningOfDaysForOneMonthLong })\n baseList = weekBaseList\n elif duration == 'Day':\n dayBaseList = list() \n for i in range(0,24):\n endTimeHour= datetime.datetime(endTime.year, endTime.month, endTime.day, endTime.hour, 0, 0, 0)\n endTimeLong = calendar.timegm(endTimeHour.utctimetuple())*1000\n beginningOfHoursForOneDayLong = endTimeLong - i*60*60*1000\n dayBaseList.append({'count':0,'time':beginningOfHoursForOneDayLong })\n baseList = dayBaseList\n elif duration == 'Hour':\n hourBaseList = list() \n for i in range(0,60):\n endTimeMin= datetime.datetime(endTime.year, endTime.month, endTime.day, endTime.hour, endTime.minute, 0, 0)\n endTimeLong = calendar.timegm(endTimeMin.utctimetuple())*1000\n beginningOfMinutesForOneHourLong = endTimeLong - i*60*60*1000\n hourBaseList.append({'count':0,'time':beginningOfMinutesForOneHourLong })\n baseList = hourBaseList\n \n #Calculate event list\n endTime_ms = calendar.timegm(endTime.utctimetuple())*1000\n if duration=='Day':\n timerange=24*60*60*1000;\n interval='hour'\n elif duration=='Week':\n timerange=7*24*60*60*1000;\n interval='day'\n elif duration=='Month':\n timerange=30*24*60*60*1000;\n interval='day'\n elif duration=='Hour':\n timerange=1*60*60*1000;\n interval='minute'\n #print timerange\n #print interval\n startTime_ms = endTime_ms - timerange;\n allquery = \" AND datetime:[\"+ str(startTime_ms) +\" TO \"+ str(endTime_ms)+\"]\"\n all = tuples(search_datetimefacet(index,'liberty_access',query+allquery, interval),['time','count'])\n \n \n #Normalize\n nList= normalize(tuples(baseList,['time','count']),all)\n #print nList\n \n list1 = map(lambda d: {\"time\":d[0], \"count\":d[1]} ,nList)\n \n #start of time line\n keys = ['time', ['count']]\n style = {'width': 1000, 'height': 250}\n hAxis = {'tickDisplayAngle': 20,'label': 'Time'}\n vAxis = {'label': 'Access Log Events'}\n timeline_html='<br><br><h4 style=\"text-align:left;padding-left:32px;\">Access Log Timeline</h4><br>'\n timeline_html += chart_timeline(list1, keys, style=style,legends=None, hAxis=hAxis, vAxis=vAxis)\n #end of time line\n results = search_termsfacet(index, 'liberty_access', query+allquery, 'uriPath', size=5)\n #results= search_termsfacet(index, 'liberty_access',' * AND datetime:\\[1388415538000 TO 1391007538000\\]','uriPath',size=5)\n responseTime = []\n responseCode = []\n for respath in results:\n \timport re\n \tESCAPE_CHARS_RE = re.compile(r'(?<!\\\\)(?P<char>[&|+\\\\\\-!(){}[\\]/^\"~*?:])')\n strUriPath=ESCAPE_CHARS_RE.sub(r'\\\\\\g<char>', str(respath['term']))\n \tresult=search_termsstatisticalfacet(index, 'liberty_access', query+allquery+' AND uriPath:'+str(strUriPath),'uriPath' ,'elapsedTime', size=5)\n #print query+' AND uriPath:'+str(respath['term'])+allquery\n responseTime.append({'uripath': str(respath['term']), 'mean': round(result[0]['mean']/1000, 3)})\n result=search_termsfacet(index, 'liberty_access', query+' AND uriPath:'+str(strUriPath)+allquery, 'responseCode', size=5, order='count') \n responseCode.append(map(lambda d: { 'count': str(d['count']), 'term': str(d['term']) }, result))\n \n keys3 = ['term', 'count']\n style3 = { 'outerRadius': 52, 'innerRadius': 25, 'colors': colors_category20() }\n legend3 = { 'position':'right', 'width': 100, 'height': 0 }\n #table_html ='<div id=\"div_id_acc_title\" style=\"text-align:center\"><h2>Top Resources by Usage</h2></div>'\n table_html = \"<table id='hor-zebra' style='width:100%'>\"\n table_html +=\"<caption><h4 style='text-align:left;font-size:13px;font-family:Verdana,arial,sans-serif'>Resource latency and Response codes</h4></caption>\"\n table_html += \"<tr><th>Resource</th><th>Avg Response Time (ms) </th><th> Response codes</th></tr>\"\n table_html += reduce(lambda x,y: x + y , map(lambda x, y: \"<tr><td>\" + x['uripath'] + \"</td><td>\" + str(x['mean']) +\"</td><td>\" + chart_pie(y, keys3, style=style3, legends=legend3) +\"</td></tr>\", responseTime, responseCode))\n table_html += \"</table>\"\n return timeline_html + table_html ",
"description": "Pipe description goes here...",
"userID": "95e949a10fd8471390b966cbe9bb66f8",
"tenantID": "95e949a10fd8471390b966cbe9bb66f8",
"version": "v1",
"pipename": "access_util"
}
]