{

<% if not prj %>
    <% set prj = "l7-balancer-term" %>
<% endif %>

<% if not hosts %>
    <% set hosts = "ASEARCH" %>
<% endif %>

<% if not ctype%>
	<% set ctype = "prod,prestable" %>
<% endif %>

<% if not geo %>
    <% set geo = list_geo(itype='balancer', prj=prj|string) %>
<% else %>
	<% set geo = ("[" + geo|string + "]")|from_json %>
<% endif %>

<% set panel_height = 4 %>
<% set upstreams_height = panel_height * 1.5 %>
<% set panel_width = 9 %>
<% if not signal_width %>
	<% set signal_width = 1 %>
<% endif %>

<% if not upstream_signal %>
	<% set upstream_signal = "requests_summ" %>
<% endif %>

"abc": "appbalancer",
"title": "L7 balancer signal by upstreams",
"description": "https://wiki.yandex-team.ru/balancer/Как-Мониторить-Балансер/",
"type": "panel",
"charts": [
<% set main_layout = create_main_layout("vertical", default_width=panel_width, default_height=panel_height) %>

<% set upstreams_layout = main_layout.sub("vertical", default_width=panel_width * geo|length, default_height=panel_height) %>
<% set rps_layout = upstreams_layout.sub("horizontal") %>
{
	"title": "RPS by upstreams",
	"type": "graphic",
	"normalize": "true",
	<<rps_layout.coords()>>,
    "signals": [
    	<% for signal in list_signals(pattern='balancer_report-report-(?P<section>.+)-requests_summ', itype='balancer', prj=prj, limit=5000) %>
        	<%- set s = signal.sub('section')|string %>
            <%- if 'default' not in s
				and 'service_total' not in s
				and 'requests_to' not in s
				and 'noc_static_check' not in s
				and not s.startswith('_') %>
				{
					"tag": "itype=balancer;ctype=<< ctype >>;prj=<< prj >>",
					"host": "<< hosts >>",
					"name": "balancer_report-report-<< signal.sub('section') >>-<< upstream_signal >>",
					"title": "<< signal.sub('section') >>",
					"width": << signal_width >>,
				},
            <% endif %>
        <% endfor %>
    ],
},
],
"type": "panel"
}