Examples

Top-of-funnel report

View HTML

This example utilizes a MySQL Datasource and multiple Plot visualizations to show a high-level overview of the number of new signups over the last week (both as an running total and as a count of new signups per day).

Show/hide configuration YAML
---
title: Top-of-funnel report

datasources:
  db:
    plugin: mysql
    args:
      host: mysql
      user: kpireport
      passwd: kpireport_pass

views:
  # Show a time series of user signups over the report period.
  signups_over_time:
    plugin: plot
    title: Total sign-ups
    description: |
      The running total of user accounts.
    args:
      datasource: db
      query: |
        select created_at,
        count(*) over (order by created_at)
          + (select count(*) from kpireport.signups where created_at < {from})
          as total_signups
        from kpireport.signups
        where created_at >= {from} and created_at < {to}
      query_args:
        parse_dates: ['created_at']
  new_signups:
    plugin: plot
    title: Daily new sign-ups
    description: |
      How many new users signed up on each day.
    cols: 4
    args:
      kind: bar
      datasource: db
      query: |
        select date_format(created_at, '%%Y-%%m-%%d') as day, count(*) as daily_total
        from kpireport.signups
        where created_at >= {from} and created_at < {to}
        group by day(created_at)
      query_args:
        # Because we're roughly grouping by day, and not a full date time,
        # automatic parsing of dates doesn't quite work, so we need to give
        # a bit of help to say which columns should be treated as dates.
        parse_dates:
          day: '%Y-%m-%d'
      time_column: day
  # Additionally, show a stat indicating how much the total signups have
  # increased (or decreased) in comparison to the previous report period.
  signups_change:
    plugin: single_stat
    title: Week total
    cols: 2
    args:
      datasource: db
      query: |
        select count(*) from kpireport.signups
        where created_at >= {from} and created_at < {to}
      comparison_query: |
        select count(*) from kpireport.signups
        where created_at >= date_sub({from}, {interval})
          and created_at < {from}
      comparison_type: percent
      # comparison_type: raw
  new_signups_table:
    plugin: table
    args:
      datasource: db
      query: |
        select date_format(created_at, '%%Y-%%m-%%d') as Day, count(*) as 'Daily total'
        from kpireport.signups
        where created_at >= {from} and created_at < {to}
        group by day(created_at)

CI report

View HTML

This example uses both a View and Datasource provided by the Jenkins plugin to show an overview of build jobs and their success/failure statuses.

Show/hide configuration YAML
---
title: CI report

datasources:
  jenkins:
    plugin: jenkins
    args:
      host: jenkins:8080
      user: jenkins_user
      api_token: jenkins_token

views:
  app_build_summary:
    plugin: jenkins.build_summary
    title: Problem application builds
    args:
      filters:
        name: -app
  other_builds:
    plugin: jenkins.build_summary
    title: Other builds
    args:
      filters:
        invert: True
        name: -app

Ops report

View HTML

This example uses both a View and Datasource provided by the Prometheus plugin to show a visualization of some time series data representing server load, as well as a summary of alerts fired by the Prometheus server over the report window.

Show/hide configuration YAML
---
title: Ops report

datasources:
  prom:
    plugin: prometheus
    args:
      host: prometheus:9090

views:
  server_load:
    plugin: plot
    title: Load
    args:
      datasource: prom
      query: |
        100 - (avg by(hostname) (irate(node_cpu_seconds_total{mode="idle"}[5m])) * 100
      groupby: hostname
      plot_rc:
        lines.linewidth: 1
  critical_alerts:
    plugin: prometheus.alert_summary
    title: Critical alerts
    args:
      datasource: prom
      labels:
        severity: critical
  warning_alerts:
    plugin: prometheus.alert_summary
    title: Warnings
    args:
      datasource: prom
      show_timeline: False
      labels:
        severity: warning