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
# This is an example alertmanager.yaml which sends alert notifications to a slack channel. | |
global: | |
slack_api_url: "https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX" | |
route: | |
group_by: ['alertname', 'cluster', 'service'] | |
receiver: slack_general | |
receivers: | |
- name: slack_general |
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
# Clear all the segments that expire before today from the user u1 | |
print("Clean the stale segments for user u1") | |
if options.interactive: | |
pause() | |
ops = [ | |
mh.map_remove_by_value_range( | |
"u", | |
[0, aerospike.null()], | |
[end_ttl, aerospike.null()], | |
aerospike.MAP_RETURN_COUNT, |
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
# Count all the segments in the segment ID range 8000-9000 | |
print("\nCount how many segments u1 has in the segment ID range 8000-9000") | |
if options.interactive: | |
pause() | |
ops = [mh.map_get_by_key_range("u", 8000, 9000, aerospike.MAP_RETURN_COUNT)] | |
_, _, b = client.operate(key, ops) | |
print(b["u"]) | |
print(spacer) |
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
# Fetch the user's segments that are not going to expire today | |
today = datetime.datetime(now.year, now.month, now.day) | |
end_ttl = int((today - epoch).total_seconds() / 3600) | |
print("\nGet only user segments that are not going to expire today") | |
if options.interactive: | |
pause() | |
ops = [ | |
mh.map_get_by_value_range( | |
"u", | |
[0, aerospike.null()], |
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
# Update a segment's TTL by 5 extra hours | |
# First, the context for the list increment (path to the TTL) | |
ctx = [ctxh.cdt_ctx_map_key(segment_id)] | |
ops = [ | |
lh.list_increment("u", 0, 5, ctx=ctx), | |
mh.map_get_by_key("u", segment_id, aerospike.MAP_RETURN_KEY_VALUE), | |
] | |
print("\nAdd 5 hours to the TTL of user u1's segment {}".format(segment_id)) | |
if options.interactive: | |
pause() |
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
# Update multiple segments of a user profile | |
segments = {} | |
ttl_dt = now + datetime.timedelta(days=30) | |
segment_ttl = int((ttl_dt - epoch).total_seconds() / 3600) | |
for i in range(8): | |
segment_id = random.randint(0, 81999) | |
segments[segment_id] = [segment_ttl, {}] | |
print("\nUpdating multiple segments for user u1") | |
pp.pprint(segments) | |
if options.interactive: |
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
# Upsert a single segment in the user profile | |
key = (namespace, set, "u1") | |
segment_id = random.randint(0, 81999) | |
ttl_dt = now + datetime.timedelta(days=30) | |
segment_ttl = int((ttl_dt - epoch).total_seconds() / 3600) | |
ops = [ | |
mh.map_get_by_key("u", segment_id, aerospike.MAP_RETURN_KEY_VALUE), | |
mh.map_put("u", segment_id, [segment_ttl, {}]), | |
mh.map_get_by_key("u", segment_id, aerospike.MAP_RETURN_KEY_VALUE), | |
] |
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 print_sensor_data(rec, pp): | |
k, _, b = rec | |
print(k[2]) | |
print(b['t']) | |
print("=" * 30) | |
print("\nScan for a random sampling (about 0.25%) of all the sensor data") | |
if options.interactive: | |
pause() |
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
print("\nGet the data from all sensors for June 19") | |
if options.interactive: | |
pause() | |
dt = datetime.datetime(2018, 1, 1, 0, 0, 0) | |
keys = [] | |
for i in range(1, 1001): | |
keys.append((namespace, set,"sensor{}-06-19".format(i))) | |
one_day_all_sensors = client.get_many(keys) | |
for rec in one_day_all_sensors: | |
k, _, b = rec |
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
print("\nGet a year's data for sensor{}".format(sensor_id)) | |
if options.interactive: | |
pause() | |
dt = datetime.datetime(2018, 1, 1, 0, 0, 0) | |
keys = [] | |
for i in range(1, 366): | |
keys.append((namespace, set,"sensor{}-{:02d}-{:02d}".format(sensor_id, dt.month, dt.day))) | |
dt = dt + timedelta(days=1) | |
sensor_year = client.get_many(keys) | |
for rec in sensor_year: |
NewerOlder