def get_incremental_starts(config, default_start):
influx = InfluxDBClient(
username=config['influx']['user'],
password=config['influx']['password'],
database=config['influx']['db'],
host=config['influx'].get('host'))
account_starts = {}
for account in config.get('accounts'):
for region in account.get('regions'):
res = influx.query("""
select * from program_event_name
where account = '%s'
and region = '%s'
order by time desc limit 1""" % (
account['name'], region))
if res is None or len(res) == 0:
account_starts[(account['name'], region)] = default_start
continue
# its all utc
account_starts[(account['name'], region)] = parse_date(
res.raw['series'][0]['values'][0][0]).replace(tzinfo=None)
return account_starts
评论列表
文章目录