<% set notifications = [
    {
        "template_name": "on_status_change",
        "template_kwargs": {
            "status": [
                "CRIT"
            ],
            "login": [
            		"ya_kernel",
            ],
            "method": [
                "telegram"
            ]
        }
    }
] %>

<% macro make_alert(host_prfx, signal_name, signal, dc, warn_threshold, crit_threshold) -%>
    <% set alert_base = {
      "abc": "coroner",
			"juggler_base": {
					"namespace": "RTC",
					"notifications": notifications,
					"aggregator": "logic_or",
					"aggregator_kwargs": {
							"nodata_mode": "force_crit"
					},
					"flaps": {
						"stable": 0,
						"critical": 0,
					}
			},
      "juggler_host": "{}_{}".format(host_prfx, dc),
      "juggler_tags": ["{}".format(host_prfx)],
			"tags": {
				"itype": "coroner",
				"geo": "none",
      },
			"value_modify": {
					"window": 300,
					"type": "aver",
			},
      "name_tmpl": "{}_{}_{}".format(host_prfx, dc, signal_name),
      "signal": signal,
			"warn": warn_threshold,
			"crit": crit_threshold,
      "juggler_service": "{}".format(signal_name),
      "description_tmpl": "{}".format(signal_name) }%>
    << Alert(base=alert_base) >>
<%- endmacro %>

<% set signals = [
    {
        "host_prfx": "coroner",
        "name": "in_queue_size",
        "signal": "push-coroner-in_queue_tmmm",
        "thresholds": {
            "vla":  [[10, 500], [500, None]]},
    },
    {
        "host_prfx": "coroner",
        "name": "out_queue_size",
        "signal": "push-coroner-out_queue_tmmm",
        "thresholds": {
            "vla":  [[10, 3000], [3000, None]]},
    },
] %>

[
<% for data in signals %>
<% for dc in data["thresholds"] %>
<< make_alert(data['host_prfx'], data['name'], data['signal'], dc, data["thresholds"][dc][0], data["thresholds"][dc][1]) >>,
<% endfor %>
<% endfor %>
]
