Dashboards

The dashboard provide basic mechanism for displaying data via bar or pie charts.

Getting started

All example data in this tutorial was generated by Ralph's command - ralph make_demo_data.

Goal

Display graphs with quantity assets in each data centers.

First dashboard

First of all we must create new dasboard object in Ralph by clicking in menuDashboards > Dashboards next click Add new dashboard to add new one.

add-dashboard

Next steps is create graph and configure it. add-first-graph

The important field of form above is Params - this field accepted configuration of graph in JSON format. Keys labels, series, filters are required. Below short description of these fields:

  • labels - which field in model are string representation,
  • series - aggregate by this field,
  • filters - filter query by conditions, Django ORM-like lookup (visit Django documentation for more information),
  • excludes - excludes items from results - opposite to filters.

OK, after save go our new dashboard object. Now we can see item (DC Capacity) in Graphs fields - select them. After save go to Dashboards > Dashboards in list view click Link. link-to-dashboard

Final result: link-dashboard-final

Aggregating options

distinct

series allows for aggregating by distinct value. To use it, extend series query using |distinct modifier:

{
    "labels": "name",
    "series": "serverroom__rack|distinct",
    "filters": {
        "series__lt": 5
    },
}

Ratio

series allows for calculating ratio of two aggregated fields. Set Aggregate type of graph to Ratio and use list of two values for series:

{
    "labels": "service_env__service__name",
    "series": [
        "securityscan__is_patched",
        "id"
    ]
}

Special filters and fields

Special filters are some helpers to

series

series is special field which contains all annotated values and can be filtering like other fileds:

{
    "labels": "name",
    "series": "serverroom__rack",
    "filters": {
        "series__lt": 5
    },
}

or, and

or, and extend query about extra condition, e.g.:

{
    "labels": "name",
    "series": "serverroom__rack",
    "excludes": {
        "name__exact|or": [null, ''],
    },
}

Filters accept as a argument list of elements.

from_now

from_now works only with date and date-time fields in filters section, e.g.:

{
    "labels": "name",
    "series": "serverroom__rack__datacenterasset",
    "filters": {
        "created__gt|from_now": "-1y",
    },
}

The filter above limit query to objects which created from one year ago to now. Possible variants of period:

  • y - years,
  • m - months,
  • d - days,