This file contains 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
--- | |
- name: some_trigger | |
match_criteria: | |
- event_type: compute.instance.create.* | |
traits: | |
tenant_id: '406904' |
This file contains 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
def _wildcard_to_like(self, pat, escape='\\'): | |
pat = pat.replace(escape, escape * 2) | |
pat = pat.replace('_', escape + '_') | |
pat = pat.replace('%', escape + '%') | |
pat = pat.replace('*', '%') | |
pat = pat.replace('?', '_') | |
return pat | |
def _get_event_types_filter(self, included, excluded): | |
inc_clauses = [models.EventType.desc.like(self._wildcard_to_like(p), |
This file contains 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
--- | |
name: verify_trigger | |
other_stuff_goes_here: ".... you know the drill..." | |
fire_criteria: | |
- event_type: compute.instance.exists | |
traits: | |
audit_period_ending: | |
datetime: $audit_period_beginning + 1d |
This file contains 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 stackdistiller.condenser import DictionaryCondenser | |
class FixedCondenser(DictionaryCondenser): | |
def add_envelope_info(self, event_type, message_id, when): | |
self.event['event_type'] = event_type | |
self.event['message_id'] = message_id | |
self.event['timestamp'] = when |
This file contains 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
In [2]: import datetime | |
In [3]: d = datetime.datetime(2013,10,10,12,0) | |
In [4]: d | |
Out[4]: datetime.datetime(2013, 10, 10, 12, 0) | |
In [5]: str(d) | |
Out[5]: '2013-10-10 12:00:00' |
This file contains 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
select from meter select max(id), ts.ts_min, ts.ts_max | |
from meter, (select resource_id, min(timestamp) ts_min, max(timestamp) ts_max | |
from meter group by resource_id) as ts | |
where ts.resource_id = meter.resource_id and meter.timestamp = ts.ts_max group by meter.resource_id ; |