How to use the grafanalib.core.Dashboard function in grafanalib

To help you get started, we’ve selected a few grafanalib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kubernetes / perf-tests / clusterloader2 / pkg / prometheus / manifests / dashboards / defaults.py View on Github external
# See the License for the specific language governing permissions and
# limitations under the License.

import re
import attr
from grafanalib import core as g

DECREASING_ORDER_TOOLTIP = g.Tooltip(sort=g.SORT_DESC)
PANEL_HEIGHT = g.Pixels(300)
QUANTILES = [0.99, 0.9, 0.5]

SOURCE_TEMPLATE = g.Template(name="source", type="datasource", query="prometheus")


@attr.s
class Dashboard(g.Dashboard):
    time = attr.ib(default=g.Time("now-30d", "now"))
    # Make it possible to use $source as a source.
    templating = attr.ib(default=g.Templating(list=[SOURCE_TEMPLATE]))


# Graph is a g.Graph with reasonable defaults applied.
@attr.s
class Graph(g.Graph):
    dataSource = attr.ib(default="$source")
    span = attr.ib(default=g.TOTAL_SPAN)
    tooltip = attr.ib(default=DECREASING_ORDER_TOOLTIP)
    nullPointMode = attr.ib(default=None)


@attr.s
class Row(g.Row):
github mesosphere / spark-build / scale-tests / sdk.dashboard.py View on Github external
title="task events per second [{} rate]".format(resolution),
                expressions=[
                    {
                        "expr": sum(service_metric(m, "rate", resolution)),
                        "legendFormat": m,
                    }
                    for m in task_metrics
                ],
                span=3,
                steppedLine=True,
            ),
        ],
    )


dashboard = G.Dashboard(
    title="Generated SDK dashboard",
    rows=[resource_row(), resource_row(POD_TYPE_VARIABLE), scheduler_row(), task_row()],
    templating=G.Templating(
        list=[
            {
                "datasource": PROMETHEUS_DATA_SOURCE,
                "hide": 0,
                "name": FRAMEWORK_VARIABLE.lstrip("$"),
                "options": [],
                "query": "label_values(offers_received, dcos_service_name)",
                "refresh": REFRESH_ON_TIMERANGE_CHANGE,
                "regex": "",
                "sort": 0,
                "tagValuesQuery": "",
                "tags": [],
                "tagsQuery": "",
github prometheus-operator / prometheus-operator / contrib / kube-prometheus / assets / grafana / _grafanalib.py View on Github external
def Dashboard(
    title, version, time, rows, graphTooltip=0, templating=None,
):
    optional_args = {}
    if templating is not None:
        optional_args['templating'] = templating
    return core.Dashboard(
        title=title, refresh=None, schemaVersion=14,
        version=version, time=time, timezone='browser', inputs=[
            {
                'name': 'DS_PROMETHEUS',
                'label': 'prometheus',
                'description': '',
                'type': 'datasource',
                'pluginId': 'prometheus',
                'pluginName': 'Prometheus'
            },
        ], rows=rows, graphTooltip=graphTooltip, editable=False, **optional_args,
    )
github LeastAuthority / leastauthority.com / k8s / monitoring / grafana-dashboards.py View on Github external
def dashboard():
    PROMETHEUS = "prometheus"
    return G.Dashboard(
        title="S4",
        rows=[
            G.Row(panels=[
                G.Graph(
                    title="Signups",
                    dataSource=PROMETHEUS,
                    xAxis=X_TIME,
                    yAxes=[
                        G.YAxis(
                            format="none",
                            label="Count",
                        ),
                        G.YAxis(
                            format="none",
                            label="Count",
                        ),