{

<% if not geo %>
    <% set geo = "[sas,man,vla]" %>
<% endif %>
<% if not prj %>
    <% set prj = "l7-balancer" %>
<% endif %>

<% set panels = "[cpu_quant,inprog,fail_5xx,externalunknown_quant,net,requests,wait_cor,debug]" %>

    "charts": [
<% set col_shift = 0 %>
<% set row_shift = 0 %>
<% set width = 9 %>
<% set height = 1 %>

<% set geo = geo|from_json %>
<% set panels = panels|from_json %>

<% for location in geo %>
    <% if not loop.first %>
        ,
    <% endif %>

    <% if location == "sas" %>
        <% set ctype = "prestable" %>
    <% endif %>
    <% if location == "man" %>
        <% set ctype = "prod" %>
    <% endif %>
    <% if location == "vla" %>
        <% set ctype = "prod" %>
    <% endif %>


    <% for panel in panels %>
        <% if not loop.first %>
            ,
        <% endif %>

        <% if "cpu_quant" == panel %>
            {
                "col": << col_shift + 1 >>,
                "row": << row_shift + 1 >>,
                "width": << width >>,
                "height": << height >>,
                "title": "CPU quantile << location >>",
                "signals": [
                    {
                        "title": "CPU quant_99",
                        "color": "#0000ff",
                        "tag": "itype=balancer;ctype=prod,prestable,experiment;prj=<< prj >>;geo=<< location >>",
                        "host": "ASEARCH",
                        "name": "quant(balancer_report-worker-cpu_usage_hgram, 99)"
                    },
                    {
                        "title": "CPU quant_95",
                        "color": "#00ff00",
                        "tag": "itype=balancer;ctype=prod,prestable,experiment;prj=<< prj >>;geo=<< location >>",
                        "host": "ASEARCH",
                        "name": "quant(balancer_report-worker-cpu_usage_hgram, 95)"
                    },
                    {
                        "title": "CPU quant_90",
                        "color": "#D894FA",
                        "tag": "itype=balancer;ctype=prod,prestable,experiment;prj=<< prj >>;geo=<< location >>",
                        "host": "ASEARCH",
                        "name": "quant(balancer_report-worker-cpu_usage_hgram, 90)"
                    },
                    {
                        "title": "CPU quant_80",
                        "color": "#8a2be2",
                        "tag": "itype=balancer;ctype=prod,prestable,experiment;prj=<< prj >>;geo=<< location >>",
                        "host": "ASEARCH",
                        "name": "quant(balancer_report-worker-cpu_usage_hgram, 80)"
                    },
                    {
                        "title": "CPU quant_50",
                        "color": "#000000",
                        "tag": "itype=balancer;ctype=prod,prestable,experiment;prj=<< prj >>;geo=<< location >>",
                        "host": "ASEARCH",
                        "name": "quant(balancer_report-worker-cpu_usage_hgram, 50)"
                    }
                ],
                "consts": [],
                "type": "graphic",
                "normalize": true,
                "stacked": false
            }
            <% set row_shift = row_shift + height  %>
        <% elif "inprog" == panel %>
            {
                "col": << col_shift + 1 >>,
                "row": << row_shift + 1 >>,
                "width": << width >>,
                "height": << height >>,
                "title": "in prog <<location>>",
                "signals": [
                    {
                        "title": "ready coroutines",
                        "color": "#EBAC1E",
                        "yAxis": 1,
                        "tag": "itype=balancer;ctype=prod,prestable,experiment;prj=<< prj >>;geo=<<location>>",
                        "host": "ASEARCH",
                        "name": "balancer_report-worker-conts_ready_ammv"
                    },
                    {
                        "title": "inprog",
                        "color": "#BA55D3",
                        "tag": "itype=balancer;ctype=prod,prestable,experiment;prj=<< prj >>;geo=<<location>>",
                        "host": "ASEARCH",
                        "name": "balancer_report-report-service_total-inprog_ammv"
                    }
                ],
                "consts": [],
                "type": "graphic",
                "normalize": true,
                "stacked": false
            }
            <% set row_shift = row_shift + height  %>
        <% elif "fail_5xx" == panel %>
            {
                "col": << col_shift + 1 >>,
                "row": << row_shift + 1 >>,
                "width": << width >>,
                "height": << height >>,
                "title": "fail and 5xx << location >>",
                "signals": [
                    {
                        "title": "fail service_total",
                        "color": "#EBAC1E",
                        "yAxis": 1,
                        "tag": "itype=balancer;ctype=prod,prestable,experiment;prj=<< prj >>;geo=<< location >>",
                        "host": "ASEARCH",
                        "name": "balancer_report-report-service_total-fail_summ"
                    },
                    {
                        "title": "fail noc_static_check",
                        "color": "#BA55D3",
                        "tag": "itype=balancer;ctype=prod,prestable,experiment;prj=<< prj >>;geo=<< location >>",
                        "host": "ASEARCH",
                        "name": "balancer_report-report-noc_static_check-fail_summ"
                    },
                    {
                        "title": "5xx service_total",
                        "color": "#1EC6EB",
                        "tag": "itype=balancer;ctype=prod,prestable,experiment;prj=<< prj >>;geo=<< location >>",
                        "host": "ASEARCH",
                        "name": "balancer_report-report-service_total-5xx-externalunknown_summ"
                    },
                    {
                        "title": "5xx noc_static_check",
                        "color": "#4D41E6",
                        "tag": "itype=balancer;ctype=prod,prestable,experiment;prj=<< prj >>;geo=<< location >>",
                        "host": "ASEARCH",
                        "name": "balancer_report-report-noc_static_check-5xx-externalunknown_summ"
                    },
                    {
                        "title": "requests on pumpkin",
                        "color": "#000000",
                        "tag": "itype=balancer;ctype=prod,prestable,experiment;prj=<< prj >>;geo=<< location >>",
                        "host": "ASEARCH",
                        "name": "sum(balancer_report-report-search_requests_to_onerror-backend_attempt_summ,balancer_report-report-morda_requests_to_onerror-backend_attempt_summ)"
                    },
                    {
                        "title": "rate limiter",
                        "color": "#3D1AEA",
                        "tag": "itype=balancer;ctype=prod,prestable,experiment;prj=<< prj >>;geo=<< location >>",
                        "host": "ASEARCH",
                        "name": "balancer_report-report-service_total-limited_backend_attempt_summ"
                    }
                ],
                "consts": [],
                "type": "graphic",
                "normalize": true,
                "stacked": false
            }
            <% set row_shift = row_shift + height  %>
        <% elif "externalunknown_quant" == panel %>
            {
                "col": << col_shift + 1 >>,
                "row": << row_shift + 1 >>,
                "width": << width >>,
                "height": << height >>,
                "title": "externalunknown quantile << location >>",
                "signals": [
                    {
                        "title": "externalunknown quant_99",
                        "color": "#0000ff",
                        "tag": "itype=balancer;ctype=prod,prestable,experiment;prj=<< prj >>;geo=<< location >>",
                        "host": "ASEARCH",
                        "name": "quant(balancer_report-report-service_total-externalunknown_hgram, 99)"
                    },
                    {
                        "title": "externalunknown quant_95",
                        "color": "#00ff00",
                        "tag": "itype=balancer;ctype=prod,prestable,experiment;prj=<< prj >>;geo=<< location >>",
                        "host": "ASEARCH",
                        "name": "quant(balancer_report-report-service_total-externalunknown_hgram, 95)"
                    },
                    {
                        "title": "externalunknown quant_90",
                        "color": "#8a2be2",
                        "tag": "itype=balancer;ctype=prod,prestable,experiment;prj=<< prj >>;geo=<< location >>",
                        "host": "ASEARCH",
                        "name": "quant(balancer_report-report-service_total-externalunknown_hgram, 90)"
                    },
                    {
                        "title": "externalunknown quant_80",
                        "color": "#8a2be2",
                        "tag": "itype=balancer;ctype=prod,prestable,experiment;prj=<< prj >>;geo=<< location >>",
                        "host": "ASEARCH",
                        "name": "quant(balancer_report-report-service_total-externalunknown_hgram, 80)"
                    },
                    {
                        "title": "externalunknown quant_50",
                        "color": "#000000",
                        "tag": "itype=balancer;ctype=prod,prestable,experiment;prj=<< prj >>;geo=<< location >>",
                        "host": "ASEARCH",
                        "name": "quant(balancer_report-report-service_total-externalunknown_hgram, 50)"
                    }
                ],
                "consts": [],
                "type": "graphic",
                "normalize": true,
                "stacked": false
            }
            <% set row_shift = row_shift + height  %>
        <% elif "net" == panel %>
            {
                "col": << col_shift + 1 >>,
                "row": << row_shift + 1 >>,
                "width": << width >>,
                "height": << height >>,
                "title": "net << location >>",
                "signals": [
                    {
                        "color": "#EBAC1E",
                        "yAxis": 1,
                        "tag": "itype=balancer;ctype=prod,prestable,experiment;prj=<< prj >>;geo=<< location >>",
                        "host": "ASEARCH",
                        "name": "netstat-tcp_retrans_segs_summ"
                    },
                    {
                        "color": "#BA55D3",
                        "tag": "itype=balancer;ctype=prod,prestable,experiment;prj=<< prj >>;geo=<< location >>",
                        "host": "ASEARCH",
                        "name": "div(portoinst-net_packets_summ, 1000)"
                    },
                    {
                        "color": "#1EC6EB",
                        "tag": "itype=balancer;ctype=prod,prestable,experiment;prj=<< prj >>;geo=<< location >>",
                        "host": "ASEARCH",
                        "name": "portoinst-net_mb_summ"
                    },
                    {
                        "color": "#4D41E6",
                        "tag": "itype=balancer;ctype=prod,prestable,experiment;prj=<< prj >>;geo=<< location >>",
                        "host": "ASEARCH",
                        "name": "portoinst-net_drops_summ"
                    }
                ],
                "consts": [],
                "type": "graphic",
                "normalize": true,
                "stacked": false
            }
            <% set row_shift = row_shift + height  %>
        <% elif "requests" == panel %>
            {
                "col": << col_shift + 1 >>,
                "row": << row_shift + 1 >>,
                "width": << width >>,
                "height": << height >>,
                "title": "requests << location >>",
                "signals": [
                    {
                        "title": "ka service_total",
                        "color": "#BA55D3",
                        "tag": "itype=balancer;ctype=prod,prestable,experiment;prj=<< prj >>;geo=<< location >>",
                        "host": "ASEARCH",
                        "name": "balancer_report-report-service_total-ka_summ"
                    },
                    {
                        "title": "nka service_total",
                        "color": "#4D41E6",
                        "yAxis": 1,
                        "tag": "itype=balancer;ctype=prod,prestable,experiment;prj=<< prj >>;geo=<< location >>",
                        "host": "ASEARCH",
                        "name": "balancer_report-report-service_total-nka_summ"
                    },
                    {
                        "title": "success service_total",
                        "color": "#EFA87B",
                        "tag": "itype=balancer;ctype=prod,prestable,experiment;prj=<< prj >>;geo=<< location >>",
                        "host": "ASEARCH",
                        "name": "balancer_report-report-service_total-succ_summ"
                    },
                    {
                        "title": "retry service_total",
                        "color": "#1F9E23",
                        "tag": "itype=balancer;ctype=prod,prestable,experiment;prj=<< prj >>;geo=<< location >>",
                        "host": "ASEARCH",
                        "name": "balancer_report-report-service_total-backend_attempt_summ"
                    },
                    {
                        "title": "success noc_static_check",
                        "color": "#37bff2",
                        "yAxis": 1,
                        "tag": "itype=balancer;ctype=prod,prestable,experiment;prj=<< prj >>;geo=<< location >>",
                        "host": "ASEARCH",
                        "name": "balancer_report-report-noc_static_check-succ_summ"
                    },
                    {
                        "title": "ipdispatch accepted",
                        "color": "#FF0000",
                        "tag": "itype=balancer;ctype=prod,prestable,experiment;prj=<< prj >>;geo=<< location >>",
                        "host": "ASEARCH",
                        "name": "balancer_report-ipdispatch-balancer-accepted_summ"
                    }
                ],
                "consts": [],
                "type": "graphic",
                "normalize": true,
                "stacked": false
            }
            <% set row_shift = row_shift + height  %>
        <% elif "wait_cor" == panel %>
            {
                "col": << col_shift + 1 >>,
                "row": << row_shift + 1 >>,
                "width": << width >>,
                "height": << height >>,
                "title": "waiting coroutines << location >>",
                "signals": [
                    {
                        "title": "waiting coroutine",
                        "color": "#37bff2",
                        "tag": "itype=balancer;ctype=prod,prestable,experiment;prj=<< prj >>;geo=<< location >>",
                        "host": "ASEARCH",
                        "name": "balancer_report-worker-conts_waiting_ammv"
                    }
                ],
                "consts": [],
                "type": "graphic",
                "normalize": true,
                "stacked": false
            }
            <% set row_shift = row_shift + height  %>
        <% elif "debug" == panel %>
            {
                "col": << col_shift + 1 >>,
                "row": << row_shift + 1 >>,
                "width": << width >>,
                "height": << height >>,
                "title": "debug balancer << location >>",
                "signals": [
                    {
                        "title": "dbg balancer error catches",
                        "color": "#F6AB31",
                        "yAxis": 1,
                        "tag": "itype=balancer;ctype=prod,prestable,experiment;prj=<< prj >>;geo=<< location >>",
                        "host": "ASEARCH",
                        "name": "balancer_report-report-service_total-dbg_balancer_error_catches_summ"
                    },
                    {
                        "title": "dbg balancer error returns",
                        "color": "#FF0000",
                        "tag": "itype=balancer;ctype=prod,prestable,experiment;prj=<< prj >>;geo=<< location >>",
                        "host": "ASEARCH",
                        "name": "balancer_report-report-service_total-dbg_balancer_error_returns_summ"
                    }
                ],
                "consts": [],
                "type": "graphic",
                "normalize": true,
                "stacked": false
            }
            <% set row_shift = row_shift + height  %>
        <% endif %>
    <% endfor %>
    <% set col_shift = col_shift + 9 %>
<% endfor %>
    ],
    "type": "panel"
}
