Example #1
0
def html_report(request):
    """Static HTML reports with PNG charts"""
    try:
        snapshots = parse_snapshots(request)
    except ObjectDoesNotExist:
        return HttpResponse("Wrong or missing snapshot", status=400)
    plotter = Plotter()
    plotter.plot(snapshots)

    id_from_url = lambda url: url.split("/")[2].split(".")[0]
    urls = [(id_from_url(url), title, url) for title, url in plotter.urls]

    if urls:
        return render_to_response("report.jade", {"urls": urls})
    else:
        return HttpResponse("No metrics found", status=400)
Example #2
0
def html_report(request):
    """Static HTML reports with PNG charts"""
    try:
        snapshots = parse_snapshots(request)
    except ObjectDoesNotExist:
        return HttpResponse("Wrong or missing snapshot", status=400)
    plotter = Plotter()
    plotter.plot(snapshots)

    id_from_url = lambda url: url.split("/")[2].split(".")[0]
    urls = [(id_from_url(url), title, url) for title, url in plotter.urls]

    if urls:
        return render_to_response("report.jade", {"urls": urls})
    else:
        return HttpResponse("No metrics found", status=400)
Example #3
0
 def get_time_series(self, observables):
     for ol in observables:
         for observable in ol:
             if observable:
                 raw_data = self.seriesly.query_data(observable)
                 if raw_data:
                     s = pd.Series(raw_data)
                     if len(s.unique()) == 1:
                         continue
                     s = pd.rolling_median(s, window=3)
                     title = Plotter.generate_title(observable)
                     yield title, s
Example #4
0
 def get_time_series(self, observables):
     for ol in observables:
         for observable in ol:
             if observable:
                 raw_data = self.seriesly.query_data(observable)
                 if raw_data:
                     s = pd.Series(raw_data)
                     if len(s.unique()) == 1:
                         continue
                     s = pd.rolling_median(s, window=3)
                     title = Plotter.generate_title(observable)
                     yield title, s
Example #5
0
def html_report(request):
    """Static HTML reports with PNG charts"""
    try:
        snapshots = parse_snapshots(request)
    except ObjectDoesNotExist:
        return HttpResponse("Wrong or missing snapshot", status=400)

    labels = request.GET.getlist("label")
    if labels and len(labels) != len(snapshots):
        return HttpResponse("Snapshot and labels do not match", status=400)

    plotter = Plotter()
    images = plotter.plot(snapshots, custom_labels=labels)

    def id_from_url(url):
        return url.split("/")[-1].split(".")[0]

    urls = [(id_from_url(url), title, url) for title, url in images]

    if urls:
        return render_to_response("report.html", {"urls": urls})
    else:
        return HttpResponse("No metrics found", status=400)