Import shard information
@@ -124,8 +124,15 @@ def reload_prometheus():
def import_config(config):
counters = collections.defaultdict(int)
for entry in config:
+ shard, created = models.Shard.objects.get_or_create(
+ name=entry['labels'].get('shard', 'Default')
+ )
+ if created:
+ counters['Shard'] += 1
+
service, created = models.Service.objects.get_or_create(
name=entry['labels']['service'],
+ defaults={'shard': shard}
)
if created:
counters['Service'] += 1
@@ -220,4 +227,3 @@ def mute_fromto(start, stop, labels):
logger.debug('Sending silence for %s - %s %s', start, stop, data)
url = urljoin(settings.PROMGEN['alertmanager']['url'], '/api/v1/silences')
requests.post(url, json=data).raise_for_status()
-
