<!DOCTYPE html>
{% load staticfiles %}
<html>
<head>
    <title>
        {% if service %}{{ service }}-{% endif %}{% if ctype %}{{ ctype }}-{% endif %}{% if kind %}{{ kind }}-{% endif %}{% if dc %}{{ dc }}-{% endif %}{% if allserv %}{{ allserv }}-{% endif %}saas-charts
    </title>
    <link rel="icon" href="{% static 'chart.ico' %}" type="image/x-icon">
    <link href="https://yandex.st/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet" />
    <link href="{% static 'css/links.css' %}" rel="stylesheet" />
    <link href="{% static 'css/font-awesome.min.css' %}" rel="stylesheet"/>
</head>
    <script src="https://yandex.st/jquery/2.0.3/jquery.min.js" type="text/javascript"></script>
    <script src="https://yandex.st/bootstrap/3.3.4/js/bootstrap.min.js" type="text/javascript"></script>
    <script src="{% static 'js/bootstrap3-typeahead.js' %}" type="text/javascript"></script>

<script type='text/javascript' src="{% static 'js/xmlhttp.js' %}"></script>
<script type='text/javascript' src="{% static 'js/all_services_signal.js' %}"></script>
<script type='text/javascript' src="{% static 'js/copying_link.js' %}"></script>

<script type='text/javascript'>
    let is_waiting = false;
    let skeys = {'skeys_empty': 1};
    let keys_init = 0;

    let ctype_services = {};
    let sla = {};
    let add_999 = '';

    let current_state = {'service': 'none'};

    let norm = {% if normalize %}true{% else %}false{% endif %};
    let show_sla = true;

    function getSKeys(){
        let xmlhttp = getXmlHttp();
        let req_url = 'secret_key';
        xmlhttp.open('GET', '{%  url "sendpost" "N"  %}'.replace('N', req_url), true);
        let ans = '{}';
        xmlhttp.onreadystatechange = function() {
            try{
            if (xmlhttp.readyState === 4) {
                ans =  this.responseText.toString();
                let kall = JSON.parse(ans);
                let keys = {};
                for (let ct in kall){
                    if (kall.hasOwnProperty(ct)){
                        for (let serv in kall[ct]){
                            if (kall[ct].hasOwnProperty(serv)){
                                keys[serv] = kall[ct][serv];
                            }
                        }
                    }
                }
                skeys = keys;
          //      console.log(JSON.stringify(skeys));
            }}catch(e){
                console.log(e);
            }
        };
        xmlhttp.send();
    }

    function onTyped(check_match) {
        if (check_match) {
            let service = document.getElementById('serv').value;
            let ctype = document.getElementById('ctype').value;
            if (!checkCtypeServCompat(service, ctype)) {
                return;
            }
        }
        norm = document.getElementById('normalize').checked;
        show_sla = document.getElementById('sla').checked;
        console.log(document.getElementById('serv').value + ' ' + document.getElementById('uniserv').value);
        if (is_waiting) {return;}
        is_waiting = true;
        try {
            setTimeout(ShowPanel, 200);
            is_waiting=false;
        } catch(err) {
            console.log(err);
            is_waiting = false;
        }
    }

    let proxy_allserv = {
        'index-def-200': 'indexerproxy:saas_unistat-index-default--CTYPE--SERV--200_dmmm',
        'search-200': 'searchproxy:saas_unistat-search--CTYPE--SERV--200_dmmm',
        'index-def-5xx': 'indexerproxy:saas_unistat-index-default--CTYPE--SERV--5xx_dmmm',
        'search-5xx': 'searchproxy:saas_unistat-search--CTYPE--SERV--5xx_dmmm',
        'index-def-4xx': 'indexerproxy:saas_unistat-index-default--CTYPE--SERV--4xx_dmmm',
        'search-4xx': 'searchproxy:saas_unistat-search--CTYPE--SERV--4xx_dmmm',
        'search-timeouted': 'searchproxy:saas_unistat-search--CTYPE--SERV--timeouted_dmmm',
        'search-exception': 'searchproxy:saas_unistat-search--CTYPE--SERV--exceptions_dmmm',
        'search-unavailable': 'searchproxy:saas_unistat-search--CTYPE--SERV--unavailable_dmmm',
        'search-not-fetched': 'searchproxy:saas_unistat-search--CTYPE--SERV--not-fetched_dmmm',
        'search-incomplete': 'searchproxy:saas_unistat-search--CTYPE--SERV--incomplete_dmmm',
        'search-unauthorized': 'searchproxy:sum(saas_unistat-search--CTYPE--SERV--tvm-bad_ticket_dmmm,saas_unistat-search--CTYPE--SERV--tvm-no_ticket_dmmm,saas_unistat-search--CTYPE--SERV--tvm-access_denied_dmmm,saas_unistat-search--CTYPE--SERV--tvm-exception_dmmm)',
        'index-202': 'indexerproxy:saas_unistat-index--CTYPE--SERV--202_dmmm',
        'index-206': 'indexerproxy:saas_unistat-index--CTYPE--SERV--206_dmmm',
        'index-304': 'indexerproxy:saas_unistat-index--CTYPE--SERV--304_dmmm',
        'index-513': 'indexerproxy:saas_unistat-index--CTYPE--SERV--513_dmmm',
        'index-export-200': 'indexerproxy:saas_unistat-index-export--CTYPE--SERV--200_dmmm',
        'index-export-5xx': 'indexerproxy:saas_unistat-index-export--CTYPE--SERV--5xx_dmmm',
        'index-export-4xx': 'indexerproxy:saas_unistat-index-export--CTYPE--SERV--4xx_dmmm',
        'index-5xx-perc': 'indexerproxy:perc~saas_unistat-index--CTYPE--SERV--5xx_dmmm~saas_unistat-index--CTYPE--SERV--all_dmmm',
        'index-202-perc': 'indexerproxy:perc~saas_unistat-index--CTYPE--SERV--202_dmmm~saas_unistat-index--CTYPE--SERV--all_dmmm',
        'search-5xx-perc': 'searchproxy:perc~saas_unistat-search--CTYPE--SERV--5xx_dmmm~saas_unistat-search--CTYPE--SERV--200_dmmm',
        'index-4xx-perc': 'indexerproxy:perc~saas_unistat-index--CTYPE--SERV--4xx_dmmm~saas_unistat-index--CTYPE--SERV--all_dmmm',
        'search-4xx-perc': 'searchproxy:perc~saas_unistat-search--CTYPE--SERV--4xx_dmmm~saas_unistat-search--CTYPE--SERV--200_dmmm',
        'index-duplicated': 'indexerproxy:saas_unistat-index--CTYPE--SERV--duplicated_dmmm',
        'index-deferred-200': 'indexerproxy:saas_unistat-index-defer--CTYPE--SERV--200_dmmm',
        'index-deferred-5xx': 'indexerproxy:saas_unistat-index-defer--CTYPE--SERV--5xx_dmmm',
        'index-deferred-4xx': 'indexerproxy:saas_unistat-index-defer--CTYPE--SERV--4xx_dmmm',
        'index-deferred-3xx': 'indexerproxy:saas_unistat-index-defer--CTYPE--SERV--3xx_dmmm',
        'index-docs-in-flight': 'indexerproxy:iproxy_metrics--CTYPE--SERV-_in_flight_tmmv',
        'iproxy-queue-kb': 'indexerproxy:iproxy_infoserver--CTYPE--SERV--queue_kbytes_tmmv',
        'iproxy-queue-docs': 'indexerproxy:iproxy_infoserver--CTYPE--SERV--queue_docs_tmmv',
        'b:docs-final': 'rtyserver:rty_infoserver-SERV---CTYPE--docs_in_final_indexes_tmmv',
        'b:docs-replica-min': 'deploymanager:dm_dashboard--CTYPE--SERV--min-replica-docs_txxv',
        'b:docs-replica-diff': 'deploymanager:diff~dm_dashboard--CTYPE--SERV--max-replica-docs_txxv~dm_dashboard--CTYPE--SERV--min-replica-docs_txxv',
        'b:docs-replica-diff-ratio': 'deploymanager:div(diff(dm_dashboard--CTYPE--SERV--max-replica-docs_txxv,dm_dashboard--CTYPE--SERV--min-replica-docs_txxv),dm_dashboard--CTYPE--SERV--max-replica-docs_txxv)',
        'b:downs-cnt': 'deploymanager:aver~dm_broadcast-downs--CTYPE--SERV-_tvvv',
        'b:downs-perc': 'deploymanager:aver~dm_broadcast-pcnt-downs--CTYPE--SERV-_tvvv',
        'b:age': 'rtyserver:aver(rty_infoserver-SERV---CTYPE--age_tvvv)',
        'b:age-diff': 'rtyserver:diff(rty_infoserver-SERV---CTYPE--age_txxv,rty_infoserver-SERV---CTYPE--age_tnnv)',
        'b:docs-disk': 'rtyserver:rty_infoserver-SERV---CTYPE--docs_in_disk_indexers_tmmv',
        'b:docs-mem': 'rtyserver:rty_infoserver-SERV---CTYPE--docs_in_memory_indexes_tmmv',
        'b:queue-disk': 'rtyserver:rty_infoserver-SERV---CTYPE--queue_disk_tmmv',
        'b:queue-mem': 'rtyserver:rty_infoserver-SERV---CTYPE--queue_mem_tmmv',
        'b:index-size-max': 'rtyserver:rty_infoserver-SERV---CTYPE--index_size_gb_max_txxv',
        'b:index-size-maxtoavg': 'rtyserver:div(sum(rty_infoserver-SERV---CTYPE--index_size_gb_max_txxv,const(0.5)),sum(aver(rty_infoserver-SERV---CTYPE--index_size_gb_tvvv), const(0.5)))',
        'b:files-cnt-max': 'rtyserver:rty_infoserver-SERV---CTYPE--index_files_cnt_max_txxv',
        'b:mem-ratio-max': 'rtyserver:rty_infoserver-SERV---CTYPE--mem_lock_ratio_txxv',
        'bal:5xx-ratio': 'balancer:div(balancer_log-SERV--5xx_dmmm,sum(balancer_log-SERV--succ_dmmm,const(1)))',
        'bal:err-ratio': 'balancer:div(balancer_log-SERV--error_dmmm,sum(balancer_log-SERV--succ_dmmm,const(1)))',
        'bal:search-2xx': 'balancer:balancer_log-SERV--succ_dmmm',
        'inconsistent-replics': 'deploymanager:aver~dm_dashboard--CTYPE--SERV--inconsistent-ratio_tvvv',
        'inconsist-replics-size': 'deploymanager:aver~dm_dashboard--CTYPE--SERV--size-inconsistent-ratio_tvvv',
        'size-sum-approx': 'deploymanager:mul(aver(dm_dashboard--CTYPE--SERV--respond_replics_tvvv),dm_dashboard--CTYPE--SERV--max-replica-size-gb_txxv)',
        'b:search-error': 'rtyserver:saas_unistat-backend-search--CTYPE--SERV--error_dmmm',
        'b:search-unavaiable': 'rtyserver:saas_unistat-backend-search--CTYPE--SERV--unavailable_dmmm',
        'b:source-unanswers': 'rtyserver:saas_unistat-backend-source--CTYPE--SERV--unanswers_dmmm',
        'b:source-unans-ratio': 'rtyserver:div(saas_unistat-backend-source--CTYPE--SERV--unanswers_dmmm,saas_unistat-backend-search--CTYPE--SERV--count-all_dmmm)',
        'b:result-errors': 'rtyserver:saas_unistat-backend-search--CTYPE--SERV--result-fail_dmmm',
        'b:fail-on-zero': 'rtyserver:saas_unistat-backend-search--CTYPE--SERV--fail-on-zero_dmmm',
        'b:index-503': 'rtyserver:saas_unistat-backend-index--CTYPE--SERV--503_dmmm',
        'b:index-4xx': 'rtyserver:saas_unistat-backend-index--CTYPE--SERV--4xx_dmmm',
        'b:search-q50': 'rtyserver:quant~saas_unistat-search-times--CTYPE--SERV--full_dhhh~50',
        'b:search-q90': 'rtyserver:quant~saas_unistat-search-times--CTYPE--SERV--full_dhhh~90',
        'b:search-q99': 'rtyserver:quant~saas_unistat-search-times--CTYPE--SERV--full_dhhh~99',
        'b:search-q999': 'rtyserver:quant~saas_unistat-search-times--CTYPE--SERV--full_dhhh~999',
        'b:search-docs-q999': 'rtyserver:quant~saas_unistat-search-report-doc-count--CTYPE--SERV-_dhhh~999',
        'b:search-threads': 'rtyserver:' + threads_estimate_signal('-CTYPE-', '-SERV-'),
        'b:crashes': 'rtyserver:crashes_log-saas_-CTYPE--SERV-_exit_signal_mmmm',
        'b:crashes-err': 'rtyserver:crashes_log-saas_-CTYPE--SERV-_exit_error_mmmm',
        'search-quant-999': 'searchproxy:quant~saas_unistat-times--CTYPE--SERV-_dhhh~999',
        'search-quant-99': 'searchproxy:quant~saas_unistat-times--CTYPE--SERV-_dhhh~99',
        'search-quant-95': 'searchproxy:quant~saas_unistat-times--CTYPE--SERV-_dhhh~95',
        'search-quant-50': 'searchproxy:quant~saas_unistat-times--CTYPE--SERV-_dhhh~50',
        'search-report-kb-q999': 'searchproxy:quant~saas_unistat-search--CTYPE--report-kilobyte-size-SERV-_dhhh~999',
        'search-queue-time': 'searchproxy:quant~saas_unistat-times--CTYPE--wait_in_queue-SERV-_dhhh~999',
        'search-empty-perc': 'searchproxy:perc~saas_unistat-search--CTYPE--SERV--count-zero_dmmm~saas_unistat-search--CTYPE--SERV--200_dmmm',
        'search-200+5xx': 'searchproxy:sum(saas_unistat-search--CTYPE--SERV--200_dmmm,saas_unistat-search--CTYPE--SERV--5xx_dmmm)',
        'search-gt300ms': 'searchproxy:hcount~saas_unistat-times--CTYPE--SERV-_dhhh~300~inf',
        'search-gt300ms_perc': 'searchproxy:hperc~saas_unistat-times--CTYPE--SERV-_dhhh~300~inf',
        'search-gt500ms_perc': 'searchproxy:hperc~saas_unistat-times--CTYPE--SERV-_dhhh~500~inf',
        'search-gt1000ms_perc': 'searchproxy:hperc~saas_unistat-times--CTYPE--SERV-_dhhh~1000~inf'
    };
    function allServSignals(){
        let kind = document.getElementById('kind').value;
        try{
            let choises = Object.keys(proxy_allserv);
            choises.unshift('-');
            $('#uniserv').typeahead({
                source: choises,
                minLength: 0,
                showHintOnFocus: true,
                items: 'all'
            });
        } catch(err){
            alert(err);
        }
    }

    function fill_ctype_services() {
        {% for ct, slist in serv_ct.items %}
            ctype_services['{{ ct }}'] = [];
            {% for serv in slist %} ctype_services['{{ ct }}'].push('{{ serv }}'); {% endfor %}
        {% endfor %}
    }

    function fill_sla() {
        {% for ct, cts in slas.items %}
            sla['{{ ct }}'] = {};
            {% for serv, ssla in cts.items %}sla['{{ ct }}']['{{ serv }}']={maxdocs:'{{ ssla.maxdocs }}',total_index_size_bytes:'{{ ssla.total_index_size_bytes }}',search_q_999_ms:'{{ ssla.search_q_999_ms }}',search_q_99_ms:'{{ ssla.search_q_99_ms }}',search_rps:'{{ ssla.search_rps }}'};{% endfor %}
        {% endfor %}
       // console.log(JSON.stringify(sla));
    }

    function switch_ctypes() {
        let service = document.getElementById('serv').value;
        if (service !== current_state.service) {
            let els = document.getElementById('ctype').children;
            for (let i=0; i < els.length; ++i) {
                if (service === '' || service === 'nservices') {
                    els[i].style.color = 'black';
                    els[i].innerText = els[i].value;
                    continue;
                }
                let i_ctype = els[i].value;
                if (ctype_services.hasOwnProperty(i_ctype) && ctype_services[i_ctype].indexOf(service) !== -1) {
                    els[i].style.color = 'black';
                    els[i].innerText = els[i].value;
                } else {
                    els[i].style.color = 'grey';
                    els[i].innerText = '(-) ' + els[i].value;
                }
            }
            current_state.service = service;
        }
    }

    $(document).ready(function(){
        {% if warnings %}console.log('{{ warnings }}');{% endif %}
        try {
            fill_ctype_services();
        } catch(err){ console.log(err); }
        try {
            fill_sla();
        } catch(err) { console.log(err); }
        try {
            switch_ctypes();
        } catch(err){ console.log(err); }
        redoTypeahead();
        allServSignals();
        getSKeys();
        if (window.location.search.search('q999=') !== -1) {
            add_999 = '1';
        }
        ShowPanel();
    });

    function reloadFrame(srcl, onload_func){
        document.getElementById('gfr').onload = onload_func;
        if (srcl === ""){
            document.getElementById('gfr').src += ' ';
        } else{
            document.getElementById('gfr').src = 'https://yasm.yandex-team.ru/iframe-panel';
        }
    }

    function redoTypeahead(){
    try {
        let ctype = document.getElementById('ctype').value;
        let serv_list = ctype_services[ctype];
        if (serv_list.length === 0 && ctype !== 'stable_gemini'){
            alert('no services for ctype %s, all: ' + JSON.stringify(ctype_services));
        }
        if (ctype === 'stable_gemini') {
            serv_list = ['gemini'];
        } else {
            serv_list.push('nservices');
        }
        $('#serv').typeahead('destroy')
        .typeahead({
            source: serv_list,
            minLength: 0,
            showHintOnFocus: true
        });
    } catch(err){
        alert(err);
    }
    }

    function checkCtypeServCompat(service, ctype){
        if (service === 'nservices' || service === '' || service === '-'){ return true; }
        return (ctype_services[ctype].indexOf(service) !== -1);
    }

    function getLinkText(){
        let ctype = document.getElementById('ctype').value;
        let service = document.getElementById('serv').value;
        let kind = document.getElementById('kind').value;
        let dc = document.getElementById('dc').value;
        let allserv = document.getElementById('uniserv').value;
        let link = window.location.toString();
        link = link.split('?')[0];
        link += '?ctype=' + ctype + '&service=' + service + '&kind=' + kind + '&dc=' + dc + '&allserv=' + allserv;
        return link;
    }

    function getLink(do_open){
        let link = getLinkText();
        if (document.getElementById('normalize').checked)
            link += '&normalize=1';
        if (do_open) {
            window.open(link);
        } else {
            copyTextToClipboard(link);
            document.getElementById('getLinkElem').innerHTML="Copied";
            setTimeout(
                function() {
                    document.getElementById('getLinkElem').innerHTML="Link";
                }
                , 500)
        }
    }

    function ctypeToTag(ctype, dc){
        let ct_tag = '';
        if (ctype === 'stable'){
            ct_tag = '_prod_saas_';
        } else if (ctype === 'stable_kv'){
            ct_tag = '_prod_saas-kv_';
        } else if (ctype === 'stable_middle_kv'){
            ct_tag = '_prod_saas-middle-kv_';
        } else if (ctype === 'prestable'){
            ct_tag = '_hamster_saas_';
        } else if (ctype === 'testing'){
            ct_tag = '_test_saas_';
        }
        ct_tag = ct_tag + dc;
        return ct_tag;
    }

    function extractSlaValue(ctype, service, field) {
        let serv_pure = service;
        if (serv_pure !== '' && serv_pure[0] === '-') {
            serv_pure = serv_pure.substr(1);
        }
        try {
            if (sla.hasOwnProperty(ctype) && sla[ctype].hasOwnProperty(serv_pure) && sla[ctype][serv_pure][field] !== '') {
                return sla[ctype][serv_pure][field];
            }
        } catch(err) { console.log(err); }
        return '';
    }

    function threads_estimate_signal(ctype, serv_only) {
        let thr_sums = [];
        let time_ints = [0, 1, 3, 5, 10, 20, 30, 50, 100, 200, 500, 1000, 2000];
        let init_sig = "saas_unistat-search-times-" + ctype + serv_only + "-full_dhhh";
        for (let j=1; j<time_ints.length; ++j) {
            let interv_cnt =  "hcount(" + init_sig + "," + time_ints[j-1] + "," + time_ints[j] + ")";
            thr_sums.push("mul(" + interv_cnt + "," + time_ints[j] + ")");
        }
        return "div(sum(" + thr_sums.join(',') + "),5000)";
    }

    function sproxyPanel(service, dc, ctype, col){
        let tag_add = (dc === '') ? '' : (';geo=' + dc);
        let signals = [{
            name:"hcount~saas_unistat-times-" + ctype + service + "_dhhh~0~inf",
            host: 'ASEARCH',
            tag:'itype=searchproxy' + tag_add,
            title:'all',
            color:'#000000'}];
        let long_time_beg = '100';
        let time_ints = ['2000', '1000', '500', '300', '200',
                 '100', '50', '30', '20', '10'];
        if (ctype.search('kv') !== -1) {
            time_ints = ['200', '100', '50', '30', '20',
                 '10', '5', '3', '2', '1'];
            long_time_beg = '10';
        }
        let signals_long = [{
            name:"hcount~saas_unistat-times-" + ctype + service + "_dhhh~" + long_time_beg +"~inf",
            host: 'ASEARCH',
            tag:'itype=searchproxy' + tag_add,
            title: long_time_beg + '--inf',
            color:'#000000'}];
        let colors = ['#550000', '#CC0000', '#DD00AA', '#CE78EE', '#3154D2', '#3154D2',
                    '#0000FF', '#018D72', '#07EAB3', '#44CC00'];
        for (let t=0; t<time_ints.length; ++t){
            try{
                if (t < 5){
                    signals_long.push({
                        name:"hcount~saas_unistat-times-" + ctype + service + "_dhhh~" + long_time_beg + "~" + time_ints[t],
                        host: 'ASEARCH',
                        tag:'itype=searchproxy' + tag_add,
                        title: long_time_beg + "--" + time_ints[t],
                        color: colors[t]
                    });
                }
                signals.push({
                        name:"hcount~saas_unistat-times-" + ctype + service + "_dhhh~0~" + time_ints[t],
                        host: 'ASEARCH',
                        tag:'itype=searchproxy' + tag_add,
                        title: "time-less-" + time_ints[t],
                        color: colors[t]
                    });

            }catch(Err){
                alert(Err);
            }
        }
        if (show_sla) {
            let sla_s_rps = extractSlaValue(ctype, service, 'search_rps');
            if (sla_s_rps !== '') {
                let rps_level_sig = "mul(const(" + sla_s_rps + "),normal())";
                signals.push({
                    name:rps_level_sig, host: 'ASEARCH', tag:'itype=searchproxy' + tag_add,
                    title:'sla search rps' + (norm ? '' : ' x norm'), color:'red'});
            }
        }
        let signals_times = [
                "quant~saas_unistat-times-" + ctype + service + "_dhhh~50",
                "quant~saas_unistat-times-" + ctype + service + "_dhhh~90",
                "quant~saas_unistat-times-" + ctype + service + "_dhhh~95",
                "quant~saas_unistat-times-" + ctype + service + "_dhhh~97",
                "quant~saas_unistat-times-" + ctype + service + "_dhhh~98",
                "quant~saas_unistat-times-" + ctype + service + "_dhhh~99"
        ];
        for (let i=0; i<signals_times.length; ++i) {
            signals_times[i] = {host: 'ASEARCH', tag:'itype=searchproxy' + tag_add,
                name: signals_times[i]};
        }
        if (show_sla) {
            let sla_q999 = extractSlaValue(ctype, service, 'search_q_999_ms');
            let sla_q99 = extractSlaValue(ctype, service, 'search_q_99_ms');

            if (add_999 !== '' || sla_q999 !== '') {
                signals_times.push({host: 'ASEARCH', tag:'itype=searchproxy' + tag_add,
                    name: "quant~saas_unistat-times-" + ctype + service + "_dhhh~999"});
            }
            if (sla_q999 !== '') {
                signals_times.push({
                    name:"const~" + sla_q999, host: 'ASEARCH', tag:'itype=searchproxy' + tag_add,
                    title:'sla q999 limit', color:'red'});
            }
            if (sla_q99 !== '') {
                signals_times.push({
                    name:"const~" + sla_q99, host: 'ASEARCH', tag:'itype=searchproxy' + tag_add,
                    title:'sla q99 limit', color:'orange'});
            }
        }
        let signals_empty = [
            {name: "quant(saas_unistat-search-" + ctype + "-report-kilobyte-size" + service + "_dhhh, 50)", host: 'ASEARCH', tag:'itype=searchproxy' + tag_add, title: "kb q50"},
            {name: "quant(saas_unistat-search-" + ctype + "-report-kilobyte-size" + service + "_dhhh, 90)", host: 'ASEARCH', tag:'itype=searchproxy' + tag_add, title: "kb q90"},
            {name: "quant(saas_unistat-search-" + ctype + "-report-kilobyte-size" + service + "_dhhh, 95)", host: 'ASEARCH', tag:'itype=searchproxy' + tag_add, title: "kb q95"},
            {name: "quant(saas_unistat-search-" + ctype + "-report-kilobyte-size" + service + "_dhhh, 99)", host: 'ASEARCH', tag:'itype=searchproxy' + tag_add, title: "kb q99"},
            {name: "quant(saas_unistat-search-" + ctype + "-report-kilobyte-size" + service + "_dhhh, 999)", host: 'ASEARCH', tag:'itype=searchproxy' + tag_add, title: "kb q999"},
            {name: "perc~saas_unistat-search-" + ctype + service +
                             "-count-zero_dmmm~saas_unistat-search-" + ctype + service + "-200_dmmm",
                             host: 'ASEARCH', tag:'itype=searchproxy' + tag_add,
                             title: "empty perc", yAxis:1, width:3, color:"#6a8fc9"},
            {name: "perc~saas_unistat-search-" + ctype + service +
                             "-4xx_dmmm~saas_unistat-search-" + ctype + service + "-200_dmmm",
            host: 'ASEARCH', tag:'itype=searchproxy' + tag_add,
            title: "4xx perc", yAxis:1, width:2}];
        let signals_err = ["saas_unistat-search-" + ctype + service + "-5xx_dmmm",
                           "saas_unistat-search-" + ctype + service + "-exceptions_dmmm",
                           "saas_unistat-search-" + ctype + service + "-unavailable_dmmm",
                           "saas_unistat-search-" + ctype + service + "-timeouted_dmmm",
                           "saas_unistat-search-" + ctype + service + "-not-fetched_dmmm",
                           "saas_unistat-search-" + ctype + service + "-incomplete_dmmm"];
        if (service === ""){
            signals_err.push("messages-" + ctype + "-crashes_total_summ");
            signals_err.push("crashes_log-saas_" + ctype + "_exit_signal_mmmm");
        }
        for (let i=0; i<signals_err.length; ++i) {
            signals_err[i] = {host: 'ASEARCH', tag:'itype=searchproxy' + tag_add,
                name: signals_err[i]};
        }
        signals_err.push({host: 'ASEARCH', tag:'itype=searchproxy' + tag_add,
                name: "sum(saas_unistat-search-" + ctype + service + "-tvm-bad_ticket_dmmm,saas_unistat-search-"
                    + ctype + service + "-tvm-no_ticket_dmmm,saas_unistat-search-" + ctype + service + "-tvm-access_denied_dmmm,saas_unistat-search-"
                    + ctype + service + "-tvm-exception_dmmm,saas_unistat-search-" + ctype + service + "-tvm-bad_ticket-dryrun_dmmm,saas_unistat-search-"
                    + ctype + service + "-tvm-no_ticket-dryrun_dmmm,saas_unistat-search-" + ctype + service + "-tvm-access_denied-dryrun_dmmm,saas_unistat-search-"
                    + ctype + service + "-tvm-exception-dryrun_dmmm)",
                yAxis:1, title:'unauthorized', color: '#97B0C9'});

        norm = document.getElementById('normalize').checked;
        return [{title:"search & bytimes " + ctype + " " + dc,signals:signals, col: col, normalize: norm},
            {title:"search-5xx",signals:signals_err, col: col, normalize: norm},
            {title:"search-replytimes",signals:signals_times, col: col, normalize: norm},
            {title:"report size & empty perc",signals:signals_empty, col: col, normalize: norm},
            {title:"long requests & bytimes",signals:signals_long, col: col, normalize: norm}
        ];
    }

    function iproxyPanel(service, dc, ctype, col){
        let tag_add = (dc === '') ? '' : (';geo=' + dc);
        let signals = [{
            name:"hcount~saas_unistat-times-default-" + ctype + service + "_dhhh~0~inf",
            host: 'ASEARCH', 'tag': 'itype=indexerproxy' + tag_add,
            title:"all",
            color:"#000000"
        }];
        let signals_be = [{
            name:"hcount~saas_unistat-index-times-" + ctype + service + "_dhhh~0~inf",
            host: 'ASEARCH', 'tag': 'itype=rtyserver' + tag_add,
            title:"all",
            color:"#000000"
        }];
        let signals_err = [{name: "saas_unistat-index-default-" + ctype + service + "-5xx_dmmm",host: 'ASEARCH', tag:'itype=indexerproxy' + tag_add},
            {name:"saas_unistat-index-default-" + ctype + service + "-4xx_dmmm",host: 'ASEARCH', tag:'itype=indexerproxy' + tag_add},
            {name:"saas_unistat-index-default-" + ctype + service + "-304_dmmm",host: 'ASEARCH', tag:'itype=indexerproxy' + tag_add},
            {name:"saas_unistat-index-default-" + ctype + service + "-206_dmmm",host: 'ASEARCH', tag:'itype=indexerproxy' + tag_add},
            {name:"saas_unistat-backend-index-" + ctype + service + "-5xx_dmmm",host: 'ASEARCH', tag:'itype=rtyserver' + tag_add},
            {name:"saas_unistat-backend-index-" + ctype + service + "-4xx_dmmm",host: 'ASEARCH', tag:'itype=rtyserver' + tag_add},
            {name:"saas_unistat-index-" + ctype + service + "-duplicated_dmmm",host: 'ASEARCH', tag:'itype=indexerproxy' + tag_add}
                        ];

        if (service === '') {
            signals_err.push({name:"messages-" + ctype + "-crashes_total_summ",host: 'ASEARCH', tag:'itype=indexerproxy' + tag_add});
            signals_err.push({name:"crashes_log-saas_" + ctype + "_exit_signal_mmmm",host: 'ASEARCH', tag:'itype=indexerproxy' + tag_add});
        }
        let time_ints = ['2000', '1000', '500', '200',
                 '100', '50', '30', '20', '10'];
        let colors = ['#880000', '#AA3333', '#CC0000', '#DD00AA', '#A1126A',
                    '#0000FF', '#018D72', '#07EAB3', '#44CC00'];
        for (let t=0; t<time_ints.length; ++t){
            try{
            signals.push({
                name:"hcount~saas_unistat-times-default-" + ctype + service + '_dhhh~0~' + time_ints[t],
                host: 'ASEARCH', 'tag': 'itype=indexerproxy' + tag_add,
                title:'<' + time_ints[t] + 'ms',
                color: colors[t]
            });
            signals_be.push({
                name:"hcount~saas_unistat-index-times-" + ctype + service + '_dhhh~0~' + time_ints[t],
                host: 'ASEARCH', 'tag': 'itype=rtyserver' + tag_add,
                title:'<' + time_ints[t] + 'ms',
                color: colors[t]
            });
            }catch(Err){
                alert(Err);
            }
        }
        let signals_age = [];
        let cans = [["#354a7d", (24 * 3600).toString(), "24h"], ["#387A8D", (6 * 3600).toString(), "6h"],
            ["#1C9783", (3600).toString(), "1h"], [ "#30B66A", (15 * 60).toString(), "15m"], ["#79D36F", (60).toString(), "1m"]];
        for (let i=0; i<cans.length; ++i){
            signals_age.push({color: cans[i][0],
                name: "hcount~saas_unistat-ages-default-" + ctype + service + "_dhhh~0~" + cans[i][1],
                host: 'ASEARCH', 'tag': 'itype=indexerproxy' + tag_add,
                title: "def-age-less-" + cans[i][2]});
            signals_age.push({color: cans[i][0],
                name: "hcount~saas_unistat-ages-export-" + ctype + service + "_dhhh~0~" + cans[i][1],
                host: 'ASEARCH', 'tag': 'itype=indexerproxy' + tag_add,
                title: "exp-age-less-" + cans[i][2]});
        }
        let signals_times = [
                "quant~saas_unistat-times-" + ctype + service + "_dhhh~50",
                "quant~saas_unistat-times-" + ctype + service + "_dhhh~90",
                "quant~saas_unistat-times-" + ctype + service + "_dhhh~95",
                "quant~saas_unistat-times-" + ctype + service + "_dhhh~97",
                "quant~saas_unistat-times-" + ctype + service + "_dhhh~98",
                "quant~saas_unistat-times-" + ctype + service + "_dhhh~99"
        ];
        if (add_999 !== '') {
            signals_times.push("quant~saas_unistat-times-" + ctype + service + "_dhhh~999");
        }
        for (let i=0; i<signals_times.length; ++i) {
            signals_times[i] = {host: 'ASEARCH', tag:'itype=indexerproxy' + tag_add,
                name: signals_times[i]};
        }
        norm = document.getElementById('normalize').checked;
        return [{title:"index-proxy & bytimes " + ctype + " " + dc,signals:signals, col: col, normalize: norm},
            {title:"index-5xx,4xx",signals:signals_err, col: col, normalize: norm},
            {title:"index-replytimes",signals:signals_times, col: col, normalize: norm},
            {title:"index-backend & bytimes",signals:signals_be, col: col, normalize: norm},
            {title:"index & byages",signals:signals_age, col: col, normalize: norm}];
    }
    function proxyDetailedPanel(service, dc, ctype){
        let ct_tag = '';
        let tag_add = (dc === '') ? '' : (';geo=' + dc);
        let signals_nonzer = [{
            name:"hcount~saas_unistat-times-" + ctype + "-nonzero" + service + "_dhhh~0~inf",
            host: 'ASEARCH', tag: 'itype=searchproxy' + tag_add,
            title:'200',
            color:'#000000'}];
        let signals_nonzero_percent = [{
            name: "perc~saas_unistat-search-" + ctype + service + "-nonzero_dmmm" +
                    "~saas_unistat-search-" + ctype  + service + "-200_dmmm",
            color:'#44CC00',
            host: 'ASEARCH', tag: 'itype=searchproxy' + tag_add,
            title: 'nonzero perc'
        },
        {
            name: "perc~saas_unistat-search-" + ctype + service + "-4xx_dmmm" +
                    "~saas_unistat-search-" + ctype  + service + "-200_dmmm",
            color:'#0044CC',
            host: 'ASEARCH', tag: 'itype=searchproxy' + tag_add,
            title: '4xx perc'
        }];
        let signals_ch = [{
            name:"hcount~saas_unistat-times-" + ctype + "-cache" + service + "_dhhh~0~inf",
            host: 'ASEARCH', tag: 'itype=searchproxy' + tag_add,
            title:'200',
            color:'#000000'}];
        let signals = [{
            name:"saas_unistat-search-" + ctype + service + "-200_dmmm",
            host: 'ASEARCH', tag: 'itype=searchproxy' + tag_add,
            title:'200',
            color:'#000000'}];
        let signals_202 = [{
            name: "saas_unistat-index-" + ctype + service + "-202_dmmm",
            color:'#0044CC',
            host: 'ASEARCH', tag: 'itype=indexerproxy' + tag_add,
            title: '202'
        },
        {   name: "sum~saas_unistat-index-" + ctype + service + "-202_dmmm" +
                    "~saas_unistat-index-" + ctype  + service + "-200_dmmm",
            color:'#44CC00',
            host: 'ASEARCH', tag: 'itype=indexerproxy' + tag_add,
            title: '202 + 200'}];
        let time_ints = ['2000', '1000', '500', '300', '200',
                 '100', '50', '30', '20', '10'];
        if (ctype.search('kv') !== -1) {
            time_ints = ['200', '100', '50', '30', '20',
                 '10', '5', '3', '2', '1'];
        }
        let colors = ['#550000', '#CC0000', '#DD00AA', '#CE78EE', '#3154D2', '#3154D2',
                    '#0000FF', '#018D72', '#07EAB3', '#44CC00'];
        for (let t=0; t<time_ints.length; ++t){
            try{
                signals_nonzer.push({
                name:"hcount~saas_unistat-times-" + ctype + "-nonzero" + service + "_dhhh~0~" + time_ints[t],
                host: 'ASEARCH', tag: 'itype=searchproxy' + tag_add,
                title: "<" + time_ints[t],
                color: colors[t]
                });
                signals_ch.push({
                name:"hcount~saas_unistat-times-" + ctype + "-cache" + service + "_dhhh~0~" + time_ints[t],
                host: 'ASEARCH', tag: 'itype=searchproxy' + tag_add,
                title: "<" + time_ints[t],
                color: colors[t]
                });
                signals.push({
                        name:"hcount~saas_unistat-times-" + ctype + service + "_dhhh~0~" + time_ints[t],
                        host: 'ASEARCH', tag: 'itype=searchproxy' + tag_add,
                        title: "<" + time_ints[t],
                        color: colors[t]
                    });
            }catch(Err){
                alert(Err);
            }
        }

        norm = document.getElementById('normalize').checked;

        return [{title:"search & bytimes " + ctype + " " + ct_tag,signals:signals,col:1, normalize: norm},
                {title:"search-not-empty-res & bytimes",signals:signals_nonzer,col:0, normalize: norm},
                {title:"search-nonzero-percent", signals:signals_nonzero_percent,col:0, normalize: norm},
                {title:"search-cache & bytimes",signals:signals_ch,col:1, normalize: norm},
                {title:"202 vs 200",signals:signals_202,col:0, normalize: norm}
        ];
    }
    function backendPanel(service, dc, ctype){
        let ct_tag = '';
        let tag_add = (dc === '') ? '' : (';geo=' + dc);
        if (ctype.search('stable') === 0 && service !== '' && service !== '-') {
            tag_add += ';prj=saas' + ctype.replace('stable', '');
            tag_add += service;
            tag_add = tag_add.replace(new RegExp('_', 'g'), '-');
        }
        let serv_only = service;
        service = service + '-' + ctype;
        let signals = [];
        let signals_df = [];
        let signals_ch = [];
        let signals_ind = [];
        let time_ints = ['inf', '2000', '1000', '500',
                 '200', '100', '50', '30', '20', '10'
        ];
        if (ctype.search('kv') !== -1) {
            time_ints = ['inf', '200', '100', '50',
                '20', '10', '5', '3', '2', '1'];
        }
        let colors = ['#000000', '#880000', '#AA3333', '#CC0000', '#DD00AA', '#A1126A',
                    '#0000FF', '#018D72', '#07EAB3', '#44CC00'];
        for (let t=0; t<time_ints.length; ++t){
            try{
            signals.push({
                name: "hcount~saas_unistat-search-times-" + ctype + serv_only + "-full" + "_dhhh~0~" + time_ints[t],
                host: 'ASEARCH', tag: 'itype=rtyserver' + tag_add,
                title: time_ints[t],
                color: colors[t]});
            signals_df.push({
                name:"hcount~saas_unistat-search-times-" + ctype + "-dfda" + serv_only + "-full" + "_dhhh~0~" + time_ints[t],
                host: 'ASEARCH', tag: 'itype=rtyserver' + tag_add,
                title: time_ints[t],
                color: colors[t]});
            signals_ch.push({
                name:"hcount~saas_unistat-search-times-" + ctype + "-cache" + serv_only + "-full" + "_dhhh~0~" + time_ints[t],
                host: 'ASEARCH', tag: 'itype=rtyserver' + tag_add,
                title: time_ints[t],
                color: colors[t]});
            signals_ind.push({
                name:"hcount~saas_unistat-index-times-" + ctype + serv_only + "_dhhh~0~" + time_ints[t],
                host: 'ASEARCH', tag: 'itype=rtyserver' + tag_add,
                title: time_ints[t],
                color: colors[t]});
            }catch(Err){
                alert(Err);
            }
        }
        let signals_err = [
                ["saas_unistat-backend-source-" + ctype + serv_only + "-unanswers_dmmm"],
                ["saas_unistat-backend-search-" + ctype + serv_only + "-error_dmmm"],
                ["saas_unistat-backend-search-" + ctype + serv_only + "-unavailable_dmmm"],
                ["saas_unistat-backend-search-" + ctype + serv_only + "-fail-on-zero_dmmm"],
                ["perc(saas_unistat-backend-search-" + ctype + serv_only
                + "-count-zero_dmmm,saas_unistat-backend-search-" + ctype + serv_only + "-count-all_dmmm)",
                "zero perc"],
                ["perc(hcount(saas_unistat-search-times-" + ctype + "-cache" + serv_only
                + "-full_dhhh),hcount(saas_unistat-search-times-" + ctype + serv_only + "-full_dhhh))",
                "cachehit perc"]
                ];
        if (ctype.search('_kv') === -1) {
            signals_err.push(["saas_unistat-backend-search-" + ctype + serv_only + "-result-fail_dmmm"]);
        }
        if (serv_only === ''){
            signals_err.push(["messages-" + ctype + "-crashes_total_summ"]);
            signals_err.push(["crashes_log-saas_" + ctype + "_exit_signal_mmmm"]);
        } else {
            signals_err.push(["crashes_log-saas_" + ctype + serv_only + "_exit_signal_mmmm"]);
        }

        for (let i=0; i<signals_err.length; ++i) {
            signals_err[i] = {name: signals_err[i][0],
                title: (signals_err[i].length > 1) ? signals_err[i][1] : signals_err[i][0],
                host: 'ASEARCH', tag: 'itype=rtyserver' + tag_add};
        }

        let signals_times = [
                "quant~saas_unistat-search-times-" + ctype + serv_only + "-full_dhhh~50",
                "quant~saas_unistat-search-times-" + ctype + serv_only + "-full_dhhh~90",
                "quant~saas_unistat-search-times-" + ctype + serv_only + "-full_dhhh~95",
                "quant~saas_unistat-search-times-" + ctype + serv_only + "-full_dhhh~97",
                "quant~saas_unistat-search-times-" + ctype + serv_only + "-full_dhhh~98",
                "quant~saas_unistat-search-times-" + ctype + serv_only + "-full_dhhh~99"
        ];
        let sla_q999 = '';
        if (show_sla) {
            sla_q999 = extractSlaValue(ctype, serv_only, 'search_q_999_ms');
            if (add_999 !== '' || sla_q999 !== '') {
                signals_times.push("quant~saas_unistat-search-times-" + ctype + serv_only + "-full_dhhh~999");
            }
        }
        for (let i=0; i<signals_times.length; ++i) {
            signals_times[i] = {name: signals_times[i],
                host: 'ASEARCH', tag: 'itype=rtyserver' + tag_add};
        }
        if (show_sla) {
            if (sla_q999 !== '') {
                signals_times.push({name:"const~" + sla_q999,
                    host: 'ASEARCH', tag: 'itype=rtyserver' + tag_add,
                    title: 'sla search q999 limit', color: 'red'});
            }
        }
        let signals_srch_doccnt = [
            {name: "quant(saas_unistat-search-total-doc-count-" + ctype + serv_only + '_dhhh, 50)', host: 'ASEARCH', tag: 'itype=rtyserver' + tag_add, title: 'doccount q50'},
            {name: "quant(saas_unistat-search-total-doc-count-" + ctype + serv_only + '_dhhh, 80)', host: 'ASEARCH', tag: 'itype=rtyserver' + tag_add, title: 'doccount q80'},
            {name: "quant(saas_unistat-search-total-doc-count-" + ctype + serv_only + '_dhhh, 90)', host: 'ASEARCH', tag: 'itype=rtyserver' + tag_add, title: 'doccount q90'},
            {name: "quant(saas_unistat-search-total-doc-count-" + ctype + serv_only + '_dhhh, 95)', host: 'ASEARCH', tag: 'itype=rtyserver' + tag_add, title: 'doccount q95'},
            {name: "quant(saas_unistat-search-total-doc-count-" + ctype + serv_only + '_dhhh, 99)', host: 'ASEARCH', tag: 'itype=rtyserver' + tag_add, title: 'doccount q99'},
            {name: "quant(saas_unistat-search-total-doc-count-" + ctype + serv_only + '_dhhh, 999)', host: 'ASEARCH', tag: 'itype=rtyserver' + tag_add, title: 'doccount q999'},
        ];
        let signals_doccount = [
            {name:"dm_dashboard-"  + ctype + serv_only + "-min-replica-docs_txxv",
                host: 'ASEARCH', tag: 'itype=deploymanager', title:"docs in replica min"},
            {name:"dm_dashboard-"  + ctype + serv_only + "-max-replica-docs_txxv",
                host: 'ASEARCH', tag: 'itype=deploymanager', title:"docs in replica max"}
        ];
        if (show_sla) {
            let sla_maxdocs = extractSlaValue(ctype, serv_only, 'maxdocs');
            if (sla_maxdocs !== '') {
                signals_doccount.push({name:"const~" + sla_maxdocs,
                    host: 'ASEARCH', tag: 'itype=deploymanager', title: 'sla maxdocs limit', color: 'red'});
            }
        }

        let signals_rep_size = [
            {name:"dm_dashboard-"  + ctype + serv_only + "-min-replica-size-gb_txxv",
                host: 'ASEARCH', tag: 'itype=deploymanager', title:"replica gb min"},
            {name:"dm_dashboard-"  + ctype + serv_only + "-max-replica-size-gb_txxv",
                host: 'ASEARCH', tag: 'itype=deploymanager', title:"replica gb max"}
        ];
        if (show_sla) {
            let sla_maxbytes = extractSlaValue(ctype, serv_only, 'total_index_size_bytes');
            if (sla_maxbytes !== '') {
                signals_rep_size.push({name:"div(const(" + sla_maxbytes + "),1000000000)",
                    host: 'ASEARCH', tag: 'itype=deploymanager', title: 'sla replica gb limit', color: 'red'});
            }
        }
        signals_ind.push(
            {name: "rty_infoserver" + service + "-queue_mem_tmmv",
                host: 'ASEARCH', tag: 'itype=rtyserver' + tag_add, title: 'queue_mem', yAxis:1, color: '#A6BDC9', width:2});
        signals_ind.push({name: "rty_infoserver" + service + "-queue_disk_tmmv",
                host: 'ASEARCH', tag: 'itype=rtyserver' + tag_add, title: 'queue_disk', yAxis:1, color: '#9bc9a8', width:2});
        let signals_merg = [
            {name: "rty_infoserver" + service + "-merger_tasks_tmmv",
                host: 'ASEARCH', tag: 'itype=rtyserver' + tag_add},
            {name: "rty_infoserver" + service + "-search_sources_count_tmmv",
                host: 'ASEARCH', tag: 'itype=rtyserver' + tag_add, yAxis:1},
            {name: "aver~dm_broadcast-alives-" + ctype + serv_only + '_tvvv',
                host: 'ASEARCH', tag: 'itype=deploymanager'},
            {name: "aver~dm_broadcast-downs-" + ctype + serv_only + '_tvvv',
                host: 'ASEARCH', tag: 'itype=deploymanager'}
        ];
        let signals_age = [
            {
                name: "aver~rty_infoserver" + service + "-age_tvvv",
                host: 'ASEARCH', tag: 'itype=rtyserver' + tag_add, title: 'index age avg'
            },
            {
                name: "aver~saas_unistat-backend-df" + service + "-receive_lag_avvv",
                host: 'ASEARCH', tag: 'itype=rtyserver' + tag_add, title: 'receive lag'
            },
            {
                name: "aver~saas_unistat-index-searchable-age-" + ctype + serv_only + "-avg_avvv",
                host: 'ASEARCH', tag: 'itype=rtyserver' + tag_add, title: 'searchable age avg'
            },
            {
                name: "saas_unistat-index-searchable-age-" + ctype + serv_only + "-max_axxx",
                host: 'ASEARCH', tag: 'itype=rtyserver' + tag_add, title: 'searchable age max'
            }
        ];
        norm = document.getElementById('normalize').checked;
        return [{title:"search count & bytimes " + ctype + " " + ct_tag,signals:signals, col: 0, normalize: norm},
            {title:"search-errors"+service,signals:signals_err, col: 0, normalize: norm},
            {title:"search replytimes",signals:signals_times, col: 0, normalize: norm},
            {title:"search total doccount",signals:signals_srch_doccnt, col: 0, normalize: norm},
            {title:"search df & bytimes",signals:signals_df, col: 0, normalize: norm},
            {title:"docs"+service,signals:signals_doccount, col: 1, normalize: norm},
            {title:"size"+service,signals:signals_rep_size, col: 1, normalize: norm},
            {title:"index & bytimes & queues",signals:signals_ind, col: 1, normalize: norm},
     //       {title:"queues",signals:signals_queue, col: 1, normalize: norm},
            {title:"merger&caches",signals:signals_merg, col: 1, normalize: norm},
      //      {title:"search with cache & bytimes",signals:signals_ch, col: 1, normalize: norm},
            {title:"docs min age",signals:signals_age, col: 1, normalize: norm}
        ];
    }
    function backendDetailedPanel(service, dc, ctype){
        let ct_tag = '';
        let tag_add = (dc === '') ? '' : (';geo=' + dc);
        let serv_only = service;
        service = service + '-' + ctype;
        let signals_doccount_list = [
            "rty_infoserver" + service + "-docs_in_final_indexes_tmmv",
            "rty_infoserver" + service + "-docs_in_memory_indexes_tmmv",
            "rty_infoserver" + service + "-docs_in_disk_indexers_tmmv",
            "rty_infoserver" + service + "-archive_alive_count_tmmv",
            "rty_infoserver" + service + "-archive_removed_count_tmmv"
        ];
        let signals_doccount = [
            {name: "dm_dashboard-"  + ctype + serv_only + "-min-replica-docs_txxv",
                host: 'ASEARCH', tag: 'itype=deploymanager'},
            {name: "dm_dashboard-"  + ctype + serv_only + "-max-replica-docs_txxv",
                host: 'ASEARCH', tag: 'itype=deploymanager'}
        ];
        for (let i=0; i<signals_doccount_list.length; ++i) {
            signals_doccount.push({
                name: signals_doccount_list[i],
                host: 'ASEARCH', tag: 'itype=rtyserver' + tag_add
            });
        }
        let signals_docs = [];
        let signals_parts = [];
        let arch_digits = ['01', '03', '04', '05', '06', '07'];
        for (let i=0; i<arch_digits.length; ++i) {
            try {
                signals_docs.push({name: "rty_infoserver" + service + "-archive-opt-docs-02-" + arch_digits[i] + '_tmmv',
                    host: 'ASEARCH', tag: 'itype=rtyserver' + tag_add});
                signals_parts.push({name: "rty_infoserver" + service + "-archive-opt-parts-02-" + arch_digits[i] + '_tmmv',
                    host: 'ASEARCH', tag: 'itype=rtyserver' + tag_add});
            }
            catch(Err) { alert(Err); }
        }

        let threads_signal = {name: threads_estimate_signal(ctype, serv_only),
                    host: 'ASEARCH', tag: 'itype=rtyserver' + tag_add};

        norm = document.getElementById('normalize').checked;
        return [
            {title:"doccounts"+service + " " + ctype + " " + ct_tag,signals:signals_doccount, col: 0, normalize: norm},
            {title:"archive docs stat"+service,signals:signals_docs, col: 0, normalize: norm},
            {title:"archive parts stat"+service,signals:signals_parts, col: 0, normalize: norm},
            {title:"threads count estimate"+service,signals:[threads_signal], col:0, normalize: norm}
        ];
    }

    function uniServPanel(sig_templ, title, dc, ctype){
        let ct_tag = '';
        let templ = sig_templ.replace('-CTTAG-', ct_tag).replace(/-CTYPE-/g, ctype);
        let services = [];
        if (ctype_services[ctype].length === 0) {
            alert('no services for ctype ' + ctype);
            return;
        }
        for (let i=0; i<ctype_services[ctype].length; ++i) {
            services[i] = '-' + ctype_services[ctype][i];
        }
        let signals = [];
        try{
            signals = getServicesPanels(services, templ, dc);
        } catch(err){
            alert(err);
        }
        let panels = [];
        norm = document.getElementById('normalize').checked;
        for (let j=0; j<signals.length; ++j){
            panels.push({title: title + " " + ct_tag, signals: signals[j], col: j % 2, normalize: norm})
        }
        return panels;
    }

    function serviceHashes(service){
                let adapt_hashes = [];
        let adapt_names = [];
        if (service !== ''){
            let serv = service.substr(1, service.length);
            try{
            if (serv !== 'mailsuggest'){
                adapt_hashes.push(skeys[serv]['json_ref']);
                adapt_names.push('json_ref');
                adapt_hashes.push(skeys[serv]['json_to_rty']);
                adapt_names.push('json_to_rty');
            }else{
                adapt_hashes.push(skeys[serv]['rtyserver']);
                adapt_names.push('rtyserver');
            }
            }catch(e){
                alert(e);
            }
        }
        return {'ad_names': adapt_names, 'ad_hashes': adapt_hashes};
    }

    function allServicesBalancersPanel(ct_tag, s_kind){
        let services = [];
        {% for serv in services %}
            services.push('-' + '{{ serv }}');
        {% endfor %}

        let signals_i = [[]];
        let signals_s = [[]];

        try{
            for(let i=0; i<services.length; ++i){
                //alert(i);
            let service = services[i];
            let leng = signals_s.length;
            if (signals_s[leng-1].length > 8){
                signals_i.push([]);
                signals_s.push([]);
                ++leng;
            }
            try{
                let ad = serviceHashes(service);
                for (let k=0; k<ad['ad_names'].length; ++k){
                    signals_i[leng-1].push({
                        signal: "ASEARCH:balancer_prod_saas-indexer-proxy_man_self:balancer_log-"
                                + ad['ad_hashes'][k] + "-error",
                        name: service + '-' + ad['ad_names'][k] + '-man'
                    });
                    signals_i[leng-1].push({
                        signal: "ASEARCH:balancer_prod_saas-indexer-proxy_vla_self:balancer_log-"
                                + ad['ad_hashes'][k] + "-error",
                        name: service + '-' + ad['ad_names'][k] + '-vla'
                    });
                    signals_i[leng-1].push({
                        signal: "ASEARCH:balancer_prestable_saas-indexer-proxy_sas_self:balancer_log-"
                                + ad['ad_hashes'][k] + "-error",
                        name: service + '-' + ad['ad_names'][k] + '-sas'
                    });
                }
            }catch(e){

            }
            signals_s[leng-1].push({
                signal:"ASEARCH:balancer_prod_saas_man_self:balancer_log" + service + "-error",
                name:service + '-man'
            });
            signals_s[leng-1].push({
                signal:"ASEARCH:balancer_prod_saas_vla_self:balancer_log" + service + "-error",
                name:service + '-vla'
            });
            signals_s[leng-1].push({
                signal:"ASEARCH:balancer_prestable_saas_sas_self:balancer_log" + service + "-error",
                name:service + '-sas'
            });

            }
        }catch(e){
            alert(e);
        }

        let panels = [];
        norm = document.getElementById('normalize').checked;
        for (let j=0; j<signals_i.length; ++j){
            panels.push({title:"index-errors", signals:signals_i[j], col:0, normalize: norm});
            panels.push({title:"search-errors", signals:signals_s[j], col:1, normalize: norm});
        }
         //   alert(JSON.stringify(panels));
        return panels;
    }

    function balancerPanel(service, ct_tag, ctype){
        if ( skeys.hasOwnProperty('skeys_empty') && keys_init < 5 ){
           // getSKeys();
           // console.log(skeys);
            keys_init += 1;
            setTimeout(ShowPanel, 3000);
            return 0;
        }
        let search_err = [];
        let search_err_5xx = [];
        let search_part_err = [];
        let search_succ = [];
        let index_err = [];
        let index_err_5xx = [];
        let index_part_err = [];
        let index_succ = [];

        let adapt_hashes = [];
        let adapt_names = [];
        if (service !== ''){
            let serv = service.substr(1, service.length);
            try{
            if (serv !== 'mailsuggest'){
                adapt_hashes.push(skeys[serv]['json_ref']);
                adapt_names.push('json_ref');
                adapt_hashes.push(skeys[serv]['json_to_rty']);
                adapt_names.push('json_to_rty');
            }else{
                adapt_hashes.push(skeys[serv]['rtyserver']);
                adapt_names.push('rtyserver');
            }
            }catch(e){
                console.log(e);
            }
        }
        let ctag = "prod";
        let sctag = "prestable";
        if (ctype === "prestable"){
            ctag = "hamster";
            sctag = "hamster";
        }
        let sprj = "_saas";
        let iprj = "_saas-indexer-proxy";
        if (ctype === "stable_kv") {
            sprj = "_saas-searchproxy-kv";
            iprj = "_saas-indexerproxy-kv";
        } else if (ctype === 'stable_middle_kv') {
            sprj = "_saas-searchproxy-middle-kv";
            iprj = "_saas-indexerproxy-middle-kv";
        }

        try{
            search_err.push({"signal": "ASEARCH:balancer_"+ctag+sprj+"_man_self:balancer_log" + service + "-error_dmmm", "name": "man-err"});
            search_err.push({"signal": "ASEARCH:balancer_"+ctag+sprj+"_vla_self:balancer_log" + service + "-error_dmmm", "name": "vla-err"});
            search_err.push({"signal": "ASEARCH:balancer_"+sctag+sprj+"_sas_self:balancer_log" + service + "-error_dmmm", "name": "sas-err"});
            search_err_5xx.push({"signal": "ASEARCH:balancer_"+ctag+sprj+"_man_self:balancer_log" + service + "-5xx_dmmm", "name": "man-5xx"});
            search_err_5xx.push({"signal": "ASEARCH:balancer_"+ctag+sprj+"_vla_self:balancer_log" + service + "-5xx_dmmm", "name": "vla-5xx"});
            search_err_5xx.push({"signal": "ASEARCH:balancer_"+sctag+sprj+"_sas_self:balancer_log" + service + "-5xx_dmmm", "name": "sas-5xx"});
            search_part_err.push({"signal": "ASEARCH:balancer_"+ctag+sprj+"_man_self:balancer_log" + service + "-part-error_dmmm", "name": "man"});
            search_part_err.push({"signal": "ASEARCH:balancer_"+ctag+sprj+"_vla_self:balancer_log" + service + "-part-error_dmmm", "name": "vla"});
            search_part_err.push({"signal": "ASEARCH:balancer_"+sctag+sprj+"_sas_self:balancer_log" + service + "-part-error_dmmm", "name": "sas"});
            if (service === '') {
                search_succ.push({"signal": "ASEARCH:balancer_"+ctag+sprj+"_man_self:balancer_report-report-service_total-outgoing_2xx_summ", "name": "man"});
                search_succ.push({"signal": "ASEARCH:balancer_"+ctag+sprj+"_vla_self:balancer_report-report-service_total-outgoing_2xx_summ", "name": "vla"});
                search_succ.push({"signal": "ASEARCH:balancer_"+sctag+sprj+"_sas_self:balancer_report-report-service_total-outgoing_2xx_summ", "name": "sas"});
            } else {
                search_succ.push({"signal": "ASEARCH:balancer_"+ctag+sprj+"_man_self:balancer_log" + service + "-succ_dmmm", "name": "man"});
                search_succ.push({"signal": "ASEARCH:balancer_"+ctag+sprj+"_vla_self:balancer_log" + service + "-succ_dmmm", "name": "vla"});
                search_succ.push({"signal": "ASEARCH:balancer_"+sctag+sprj+"_sas_self:balancer_log" + service + "-succ_dmmm", "name": "sas"});
            }
            if (service === ''){
                index_err.push({"signal": "ASEARCH:balancer_"+ctag+iprj+"_man_self:balancer_log-error_dmmm", "name": "man-err"});
                index_err.push({"signal": "ASEARCH:balancer_"+ctag+iprj+"_vla_self:balancer_log-error_dmmm", "name": "vla-err"});
                index_err.push({"signal": "ASEARCH:balancer_"+sctag+iprj+"_sas_self:balancer_log-error_dmmm", "name": "sas-err"});
                index_err_5xx.push({"signal": "ASEARCH:balancer_"+ctag+iprj+"_man_self:balancer_log-5xx_dmmm", "name": "man-5xx"});
                index_err_5xx.push({"signal": "ASEARCH:balancer_"+ctag+iprj+"_vla_self:balancer_log-5xx_dmmm", "name": "vla-5xx"});
                index_err_5xx.push({"signal": "ASEARCH:balancer_"+sctag+iprj+"_sas_self:balancer_log-5xx_dmmm", "name": "sas-5xx"});
                index_part_err.push({"signal": "ASEARCH:balancer_"+ctag+iprj+"_man_self:balancer_log-part-error_dmmm", "name": "man"});
                index_part_err.push({"signal": "ASEARCH:balancer_"+ctag+iprj+"_vla_self:balancer_log-part-error_dmmm", "name": "vla"});
                index_part_err.push({"signal": "ASEARCH:balancer_"+sctag+iprj+"_sas_self:balancer_log-part-error_dmmm", "name": "sas"});
                index_succ.push({"signal": "ASEARCH:balancer_"+ctag+iprj+"_man_self:balancer_report-report-service_total-outgoing_2xx_summ", "name": "man"});
                index_succ.push({"signal": "ASEARCH:balancer_"+ctag+iprj+"_vla_self:balancer_report-report-service_total-outgoing_2xx_summ", "name": "vla"});
                index_succ.push({"signal": "ASEARCH:balancer_"+sctag+iprj+"_sas_self:balancer_report-report-service_total-outgoing_2xx_summ", "name": "sas"});
            }else{
                for (let i=0; i<adapt_names.length; ++i){
                    index_err.push({"signal": "ASEARCH:balancer_"+ctag+iprj+"_man_self:balancer_log-" +
                            adapt_hashes[i] + "-error_dmmm", "name": adapt_names[i] + "-man-err"});
                    index_err.push({"signal": "ASEARCH:balancer_"+ctag+iprj+"_vla_self:balancer_log-" +
                            adapt_hashes[i] + "-error_dmmm", "name": adapt_names[i] + "-vla-err"});
                    index_err.push({"signal": "ASEARCH:balancer_"+sctag+iprj+"_sas_self:balancer_log-" +
                            adapt_hashes[i] + "-error_dmmm", "name": adapt_names[i] + "-sas-err"});
                    index_err_5xx.push({"signal": "ASEARCH:balancer_"+ctag+iprj+"_man_self:balancer_log-" +
                            adapt_hashes[i] + "-5xx_dmmm", "name": adapt_names[i] + "-man-5xx"});
                    index_err_5xx.push({"signal": "ASEARCH:balancer_"+ctag+iprj+"_vla_self:balancer_log-" +
                            adapt_hashes[i] + "-5xx_dmmm", "name": adapt_names[i] + "-vla-5xx"});
                    index_err_5xx.push({"signal": "ASEARCH:balancer_"+sctag+iprj+"_sas_self:balancer_log-" +
                            adapt_hashes[i] + "-5xx_dmmm", "name": adapt_names[i] + "-sas-5xx"});
                    index_part_err.push({"signal": "ASEARCH:balancer_"+ctag+iprj+"_man_self:balancer_log-" +
                            adapt_hashes[i] + "-part-error_dmmm", "name": adapt_names[i] + "-man"});
                    index_part_err.push({"signal": "ASEARCH:balancer_"+ctag+iprj+"_vla_self:balancer_log-" +
                            adapt_hashes[i] + "-part-error_dmmm", "name": adapt_names[i] + "-vla"});
                    index_part_err.push({"signal": "ASEARCH:balancer_"+sctag+iprj+"_sas_self:balancer_log-" +
                            adapt_hashes[i] + "-part-error_dmmm", "name": adapt_names[i] + "-sas"});
                    index_succ.push({"signal": "ASEARCH:balancer_"+ctag+iprj+"_man_self:balancer_log-" +
                            adapt_hashes[i] + "-succ_dmmm", "name": adapt_names[i] + "-man"});
                    index_succ.push({"signal": "ASEARCH:balancer_"+ctag+iprj+"_vla_self:balancer_log-" +
                            adapt_hashes[i] + "-succ_dmmm", "name": adapt_names[i] + "-vla"});
                    index_succ.push({"signal": "ASEARCH:balancer_"+sctag+iprj+"_sas_self:balancer_log-" +
                            adapt_hashes[i] + "-succ_dmmm", "name": adapt_names[i] + "-sas"});
                }
            }

        }catch(e){
            alert(e);
        }

        let panels = [];
        norm = document.getElementById('normalize').checked;
        panels.push({title:"index-errors", signals:index_err, col:0, normalize: norm});
        panels.push({title:"index-5xx", signals:index_err_5xx, col:0, normalize: norm});
        panels.push({title:"index-part-errors", signals:index_part_err, col:0, normalize: norm});
        panels.push({title:"index-success", signals:index_succ, col:0, normalize: norm});
        panels.push({title:"search-errors", signals:search_err, col:1, normalize: norm});
        panels.push({title:"search-5xx", signals:search_err_5xx, col:1, normalize: norm});
        panels.push({title:"search-part-errors", signals:search_part_err, col:1, normalize: norm});
        panels.push({title:"search-success", signals:search_succ, col:1, normalize: norm});
    //    alert(JSON.stringify(panels));
        return panels;
    }

    function exportPanel(service, dc, ctype){
        let ct_tag = '';
        let tag_add = (dc === '') ? '' : (';geo=' + dc);
        let exp_err = [];
        let exp_ok = [];
        let docf_err = [];
        let docf_ok = [];
        let docf_all = [];
        let distr_delt = [];
        let distr_abs = [];

        let panels = [];

        norm = document.getElementById('normalize').checked;

        let dservice = '-' + ctype;
        let d_tag = '_prod_saas_msk';
        if (ct_tag === '_hamster_saas_msk'){
            ct_tag = '';
            d_tag = '_test_saas_msk';
        }else if (ct_tag === '_prod_saas_msk'){
            ct_tag = '';
        }else if (ct_tag === '_test_saas_msk'){
            ct_tag = '';
            d_tag = '_test_saas_msk';
        }
        docf_err.push({name: "saas_unistat-backend-df" + service + dservice + "-error_dmmm",
            host: 'ASEARCH', tag: 'itype=rtyserver' + tag_add});
        docf_err.push({name: "saas_unistat-backend-df" + service + dservice + "-error-400_dmmm",
            host: 'ASEARCH', tag: 'itype=rtyserver' + tag_add});
        docf_err.push({name: "saas_unistat-backend-df" + service + dservice + "-error-500_dmmm",
            host: 'ASEARCH', tag: 'itype=rtyserver' + tag_add});

        docf_ok.push( {
                    color: "#332e63",
                    name: "hcount~saas_unistat-backend-df" + service + dservice + "-age_dhhh~0~inf",
                    host: 'ASEARCH', tag: 'itype=rtyserver' + tag_add,
                    title: "all"
                });
        let cans = [["#366280", "10h", "36000"], ["#387A8D", "1h", "3600"],
            ["#1C9783", "10m", "600"], ["#30B66A", "1m", '60'], [ "#79D36F", "10s", '10']];
        for (let i=0; i<cans.length; ++i){
            docf_ok.push({color: cans[i][0],
            name: "hcount~saas_unistat-backend-df" + service + dservice + "-age_dhhh~0~" + cans[i][2],
            host: 'ASEARCH', tag: 'itype=rtyserver' + tag_add,
            title: "age-less-" + cans[i][1]});
        }
        docf_all.push({name: "saas_unistat-backend-df" + service + dservice + "-incoming_dmmm",
            host: 'ASEARCH', tag: 'itype=rtyserver' + tag_add});
        docf_all.push({name: "saas_unistat-backend-df" + service + dservice + "-expired_dmmm",
            host: 'ASEARCH', tag: 'itype=rtyserver' + tag_add});
        docf_all.push({name: "saas_unistat-backend-df" + service + dservice + "-deprecated_dmmm",
            host: 'ASEARCH', tag: 'itype=rtyserver' + tag_add});

        panels.push({title: "docfetcher errors", signals: docf_err, col: 1, normalize: norm});
        panels.push({title: "docfetcher incoming by ages", signals: docf_ok, col: 1, normalize: norm});
        panels.push({title: "docfetcher all", signals: docf_all, col: 1, normalize: norm});

        return panels;
    }

    function ShowPanel(){
        let linkText = getLinkText();
        if (linkText !== location.href) {
            history.pushState({}, '', linkText);
        }
        document.getElementById('gfr').focus();

        let service_orig = document.getElementById('serv').value;
        let service = "-" + service_orig;
        let uniserv = (document.getElementById('uniserv').value.length > 2);
        if (service === '-' || service === '-all'){
            service = '';
        }
        let ctype = document.getElementById('ctype').value;
        let dc = document.getElementById('dc').value;
        let ct_tag = '';
        if (dc !== ''){
            ct_tag = ctypeToTag(ctype, dc);
        }
        let kind = document.getElementById('kind').value;
        document.title = service_orig + '-' + ctype + '-' + kind + '-saas-charts';
        let panelData = {};
        if (uniserv){
            let sig_title = document.getElementById('uniserv').value;
            let sig_templ = '';
            if (proxy_allserv.hasOwnProperty(sig_title)){
                sig_templ = proxy_allserv[sig_title];
            } else {
                alert ('no such signal');
                return;
            }
            panelData = {charts: uniServPanel(sig_templ, sig_title, dc, ctype)};
        } else {
        switch(kind){
            case 'proxy':
                panelData = {charts : iproxyPanel(service, dc, ctype, 0).concat(sproxyPanel(service, dc, ctype, 1))};
                break;
            case 'proxy-details':
                panelData = {charts : proxyDetailedPanel(service, dc, ctype)};
                break;
            case 'backend':
                panelData = {charts : backendPanel(service, dc, ctype)};
                break;
            case 'backend-details':
                panelData = {charts : backendDetailedPanel(service, dc, ctype)};
                break;
            case 'balancer':
                panelData = {charts : balancerPanel(service, ct_tag, ctype)};
                break;
            case 'export':
                panelData = {charts: exportPanel(service, dc, ctype)};
                break;
            default:
                break;

        }
            try {
                let compat = checkCtypeServCompat(service_orig, ctype);
            //    console.log('compat=' + compat + ';service_orig=' + service_orig + ';ctype=' + ctype);
                let el = document.getElementById('warn_incompat');
                let is_warn_hidden = el.hasAttribute('hidden');
                if (compat) {
                    if (!is_warn_hidden) { el.setAttribute('hidden', 'True'); }
                } else {
                    if (is_warn_hidden) {
                        el.removeAttribute('hidden');
                    }
                }
            } catch(err) { alert(err);}
        }

   //     console.log(panelData.toString());
        try{
            function postPanel(){
                let jsd = JSON.stringify(panelData);
                if (jsd.search('prestable') !== -1) {
                    jsd = jsd.replace(new RegExp('indexerproxy', 'g'), 'indexerproxydisc');
                    panelData = JSON.parse(jsd);
                }
                document.getElementById('conftext').innerText = jsd;
                document.getElementById('gfr').contentWindow.postMessage({fullscreen: false, panelConfig:panelData}, "*");
            }

            reloadFrame('', postPanel);

        }catch(Err){
            alert(Err);
        }
        is_waiting = false;
    }

</script>

<body>
<button onclick='ShowPanel()'>Show</button>
<label for='serv'></label>
<input id='serv' type='text' data-provide='typeahead' value='{{ service }}' onchange="onTyped(0);switch_ctypes()">
<select id='ctype' onchange='redoTypeahead();onTyped(1)'>
    <option value='stable' {% if ctype == 'stable' %}selected{% endif %} >stable</option>
    <option value='prestable' {% if ctype == 'prestable' %}selected{% endif %} >prestable</option>
    <option value='testing' {% if ctype == 'testing' %}selected{% endif %} >testing</option>
    <option value='stable_kv' {% if ctype == 'stable_kv' %}selected{% endif %} >stable_kv</option>
    <option value='stable_middle_kv' {% if ctype == 'stable_middle_kv' %}selected{% endif %} >stable_middle_kv</option>
    <option value='stable_hamster' {% if ctype == 'stable_hamster' %}selected{% endif %} >stable_hamster</option>
    <option value='stable_knn' {% if ctype == 'stable_knn' %}selected{% endif %} >stable_knn</option>
    {% for oct in other_ctypes %}
    <option value="{{ oct }}" {% if ctype == oct %}selected{% endif %}>{{ oct }}</option>
    {% endfor %}
    <option value='stable_gemini' {% if ctype == 'stable_gemini' %}selected{% endif %} >stable_gemini</option>
</select>
<select id='kind' onchange="onTyped(0)">
    <option value='proxy' {% if kind == 'proxy' %}selected{% endif %}>proxy</option>
    <option value='backend' {% if kind == 'backend' %}selected{% endif %}>backend</option>
    <option value='proxy-details' {% if kind == 'proxy-more' or kind == 'proxy-details' %}selected{% endif %}>proxy more</option>
    <option value='backend-details' {% if kind == 'backend-more' %}selected{% endif %}>backend more</option>
    <option value='balancer' {% if kind == 'balancer' %}selected{% endif %}>balancer</option>
    <option value='export' {% if kind == 'export' %}selected{% endif %}>export</option>
</select>
<select id='dc' onchange="onTyped(0)">
    <option value='' {% if dc == '' %}selected{% endif %}>(dc)</option>
    <option value='sas' {% if dc == 'sas' %}selected{% endif %}>sas</option>
    <option value='man' {% if dc == 'man' %}selected{% endif %}>man</option>
    <option value='vla' {% if dc == 'vla' %}selected{% endif %}>vla</option>
</select>
<a onclick='getLink(0)' style='cursor:pointer;padding-left:20px' id='getLinkElem' title='copy link to clipboard'>Link</a>
<a onclick='getLink(1)' style='cursor:pointer;padding-left:6px' id='doDup' title='open in new window'><i class="fa fa-external-link"></i></a>
<label style='color: grey;margin-left: 15px;margin-top: 3px;margin-right: 5px'>
normalize: <input id='normalize' type='checkbox' {% if normalize %}checked{% endif %} onchange="onTyped(0)"></label>
<label style='color: grey;margin-left: 5px;margin-top: 3px;margin-right: 5px'>
sla: <input id='sla' type='checkbox' {% if show_sla %}checked{% endif %} onchange="onTyped(0)"></label>

<button id='swfr' onclick='reloadFrame("", null)' style='float:right;margin-left: 3px'>Stop</button>

<input id='uniserv' type='text' data-provide='typeahead' value='{{ allserv }}' onchange='onTyped(0)' style='float: right'>
<label for='uniserv' style='color: grey;float: right;margin-top: 3px;margin-right: 5px'>all-services: </label>
<a style='cursor:pointer;float: right;padding-right:20px;margin-top: 3px;' target='_blank' href='https://wiki.yandex-team.ru/users/anikella/golovanui/'>Help</a>

<div hidden id='warn_incompat' style='background-color:lightsalmon'>Warning: no such service for this ctype</div>
<!--<button onclick='reloadFrame("")'>Modify</button> -->
<div>
<iframe id='gfr' src='https://yasm.yandex-team.ru/iframe-panel' width='100%' height='800'>panel</iframe>
</div>
<div id='conftext' hidden></div>
</body>

</html>
