This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from urllib2 import urlopen | |
import csv | |
import os | |
import tempfile | |
def importUrl(url): | |
response = urlopen(url) | |
code = response.getcode() | |
if code != 200: | |
raise Exception('Invalid response', code) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Simple query object for combining multiple redash queries | |
# | |
# Example usage: | |
# Find all users who have logged in in the last 8 weeks who have sent an email by analysing the logstash logs | |
# Then group the results by the week they signed up on and their emailed yes/no status | |
# | |
# import requery | |
# userQuery = 'SELECT * FROM user WHERE lastSeen > DATE_SUB(NOW(), INTERVAL 8 WEEK)' | |
# emailQuery = '{ "index" : "logstash-*", "query": { "query_string": { "query": "action:sendEmail" } }, "size" : 1000 } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
data1 = json.loads("""{ | |
"took": 19, | |
"timed_out": false, | |
"_shards": { | |
"total": 40, | |
"successful": 40, | |
"failed": 0 | |
}, |