Ejemplo n.º 1
0
def build_dashboards(es_url, kibana_url, es_index, template_file,
                     template_assess_file, model_name, backend_metrics_data,
                     from_date, to_date):
    """
    Create all the dashboards needed to viz a Quality Model

    :param es_url: Elasticsearch URL
    :param kibana_url: Kibana URL
    :param es_index: index in elasticsearch with the metrics data
    :param template_file: template file to be used for building the attribute dashboards
    :param template_assess_file: template file to be used for the assessment dashboard
    :param model_name: quality model to use
    :param backend_metrics_data: backend to use to collect the metrics data
    :param from_date: date since which the metrics must be computed
    :param to_date: date until which the metrics must be computed
    :return:
    """

    logging.debug('Building the dashboards for the model: %s', model_name)

    if not template_assess_file:
        template_assess_file = ASSESS_PANEL

    qm_menu = {}  # Kibana menu for accessing the Quality Model dashboards
    assess_menu = {}  # Kibana menu for accessing the assessment dashboard

    # Check that the model and the template dashboard exists
    model_orm = None
    try:
        model_orm = QualityModel.objects.get(name=model_name)
    except QualityModel.DoesNotExist:
        logging.error('Can not find the metrics model %s', model_name)
        raise RuntimeError("Can not find the metrics model " + model_name)

    # Build a new dashboard for each attribute in the quality model
    for goal in model_orm.goals.all():
        for attribute in goal.attributes.all():
            dash_json = build_dashboard(es_url, kibana_url, es_index,
                                        template_file, goal, attribute,
                                        backend_metrics_data)
            qm_menu[dash_json['dashboard']['value']
                    ['title']] = dash_json['dashboard']['id']

    # Project assessment is included also in the viz
    assess(es_url, es_index, model_name, backend_metrics_data, from_date,
           to_date)
    # Upload the radar viz to show the assessment
    assess_dash = VizTemplatesData.read_template(template_assess_file)
    feed_dashboard(assess_dash, es_url, kibana_url)
    assess_menu[assess_dash['dashboard']['value']
                ['title']] = assess_dash['dashboard']['id']

    build_menu(es_url, qm_menu, assess_menu)
Ejemplo n.º 2
0
Archivo: views.py Proyecto: acs/prosoul
    def post(self, request):
        error = None
        form = AssessmentForm(request.POST)
        context = {'active_page': "assess", "assess_config_form": form, 'kibana_url': KIBANA_URL}
        if form.is_valid():
            qmodel_name = form.cleaned_data['quality_model']
            es_url = form.cleaned_data['es_url']
            es_index = form.cleaned_data['es_index']
            backend_metrics_data = form.cleaned_data['backend_metrics_data']
            from_date = form.cleaned_data['from_date']
            to_date = form.cleaned_data['to_date']

            # Time to execute the assessment creation
            try:
                assessment = assess(es_url, es_index, qmodel_name, backend_metrics_data, from_date, to_date)
            except Exception as ex:
                error = "Problem creating the assessment " + str(ex)

            context.update({"errors": error})
            if not error:
                (assessment_table, projects) = Assessment.render_tables(assessment)
                if assessment_table:
                    context.update({"assessment": assessment_table, "projects": projects,
                                    "assessment_raw": json.dumps(assessment)})
                else:
                    context.update({"errors": "Empty assessment. Review the form data."})
            return shortcuts.render(request, 'prosoul/assessment.html', context)
        else:
            context.update({"errors": form.errors})
            return shortcuts.render(request, 'prosoul/assessment.html', context)
Ejemplo n.º 3
0
    def create(request):
        error = None
        if request.method == 'POST':
            form = AssessmentForm(request.POST)
            context = {'active_page': "assess", "assess_config_form": form}
            if form.is_valid():
                qmodel_name = form.cleaned_data['quality_model']
                es_url = form.cleaned_data['es_url']
                es_index = form.cleaned_data['es_index']
                backend_metrics_data = form.cleaned_data[
                    'backend_metrics_data']

                # Time to execute the assessment creation
                try:
                    assessment = assess(es_url, es_index, qmodel_name,
                                        backend_metrics_data)
                except Exception as ex:
                    error = "Problem creating the assessment " + str(ex)

                context.update({"errors": error})
                if not error:
                    assessment_table = Assessment.render_tables(assessment)
                    if assessment_table:
                        context.update({
                            "assessment":
                            Assessment.render_tables(assessment)
                        })
                    else:
                        context.update({
                            "errors":
                            "Empty assessment. Review the form data."
                        })
                return shortcuts.render(request, 'prosoul/assessment.html',
                                        context)
            else:
                context.update({"errors": form.errors})
                return shortcuts.render(request, 'prosoul/assessment.html',
                                        context)
        else:
            return shortcuts.render(request, 'prosoul/assessment.html',
                                    {"error": "Use POST method to send data"})