     .option('--end <DATETIME>', 'End time of queried period.', String, 'now')
     .option('--query-interval <minutes>', 'How big chucks to request at a time', Number, 30)
     .option('--concurrency <N>', 'Number of concurrent commands/subprocesses', Number, 5)
+    .option('--where <CLAUSE>', 'Extra where clause to further limit', String, '')
     .parse(args)
 
 normalize = (options) ->

      end: new Date(e)
  return intervals

getScaleEventsChunk = (insights, start, end, app, fields, event, callback) ->
  start = start.toISOString()
  end = end.toISOString()

  limit = 999
  query = "SELECT #{fields} FROM #{event}"
  query += " WHERE appName = '#{app}'" if app
  query += " SINCE '#{start}' UNTIL '#{end}'"
  query += " LIMIT #{limit}"
  debug 'query', query


  # execute queries
  getChunk = (period, cb) ->
    return getScaleEventsChunk insights, period.start, period.end, options.app, options.fields, options.event, options.where, cb

  debug "Executing #{queries.length} over #{options.period} days"
  throw new Error "Extremely high number of queries needed, over 3k: #{queries.length}" if queries.length > 3000
