<% macro make_alert(mgroup, extensions, tags, warn_threshold, crit_threshold) -%>
    <% set alert_base = {
        "juggler_host": "cgroups_{mgroups[0]}_{ctype}_{geo}",
        "juggler_tags": [
            "auto_downtime",
            "cgroups"
        ],
        "juggler_base": {
            "namespace": "RTC",
            "aggregator": "logic_or",
            "aggregator_kwargs": {
                "nodata_mode": "force_crit"
            },
            "flaps": {
                "boost": 0,
                "critical": 0,
                "stable": 600
            },
            "ttl": 900,
            "refresh_time": 5
        },
        "abc": "srertc",
        "mgroups": [mgroup],
        "warn": [warn_threshold, crit_threshold],
        "crit": [crit_threshold, None]
    } %>
    <<Alert(base=alert_base|combine(extensions), tags=tags)>>
<%- endmacro %>

<% set more_than_normal_percent = {
    "signal": "hperc(cgroup-cpu_count_hgram, 3000, inf)",
    "name_tmpl": "{mgroups[0]}_{ctype}_{geo}_cgroups",
    "juggler_service": "more_than_normal_percent",
    "description_tmpl": "{mgroups[0]} {geo} {ctype}"
} %>

[
<% for tags in list_tags_combinations('runtimecloud', ctype=['production', 'prestable'], fill_tags=['geo', 'ctype']) %>
    <% if tags['ctype'] in ('production',) and tags['geo'] in ('sas', 'man', 'vla', 'msk') %>
    << make_alert('ASEARCH', more_than_normal_percent, tags, 1, 3) >>,
    <% endif %>
<% endfor %>
]
