Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement SLA Charts for Hosts in Reporting Using Chart.js #1041

Open
lippserd opened this issue Aug 5, 2024 · 1 comment
Open

Implement SLA Charts for Hosts in Reporting Using Chart.js #1041

lippserd opened this issue Aug 5, 2024 · 1 comment
Assignees
Labels
enhancement New feature or improvement

Comments

@lippserd
Copy link
Member

lippserd commented Aug 5, 2024

Our current reporting implementation lacks charts, a feature that has been frequently requested by customers and ourselves for years. Instead of providing a generalized approach from the start, we should implement specific reports initially to understand how we can streamline them.

First, I would like to see charts for each host individually in the selected filter/time frame, showing the SLA in % over the respective time:

Requirements:

  • Display of SLA in % over time for each host individually within the selected filter/time frame.
  • The report requires a breakdown configuration that will be used as the x-axis (time).
  • Use Chart.js for rendering the charts.
  • Ensure the charts are responsive and visually appealing.
  • Ensure that PDF exports works.
@lippserd lippserd added the enhancement New feature or improvement label Aug 5, 2024
@sukhwinder33445
Copy link
Contributor

sukhwinder33445 commented Sep 4, 2024

Notes so far:

As discussed offline, chart.js has its limitations, even for the usual scenarios. So I looked for alternative libs and tested apexcharts, echarts and billboard.js (d3.js based lib). Apexcharts is very good, but took about 4–6 times longer to render the charts than echarts, so it is not suitable for large amounts of charts. I decided to use echarts, and it is pretty good, but since @nilmerg was using d3.js for the dependency module, he advised me to also test some d3 based libraries as he prefers to have less libraries to maintain than writing a bit more code to use those libs, and I totally agree with that point. So I used billboard.js, as this is the most commonly used and up-to-date d3-based library. It has much less code to maintain than the echart.

Billboard is easy to configure and customize. It also offers a few CSS theme files for the default design. I chose the modern theme because I liked it the most.

The BillboardBehavior introduces the following dataset attributes:

Required:

  • data-chart-data {json}: Chart data (dataPoints: [int|float], xAxisTicks: [int|float|string])

Optional:

  • data-chart-type {string}: Chart type [line, bar, area...] (default: line)
  • data-chart-x-axis-type {string}: X-axis type [timeseries, category, indexed, log] (default: indexed)
  • data-chart-x-axis-ticks-type {string}: X-axis ticks type (hour, day, week, month) [only for chartXAxisType: timeseries] (default: detected automatically)
  • data-chart-time-format-locale {string}: Locale for the time format [only for chartXAxisType: timeseries] (default: 'en-US')
  • data-chart-y-axis-label {string}: Label for the y-axis (default: null)
  • data-chart-x-axis-label {string}: Label for the x-axis (default: null)
  • data-chart-show-legend {boolean}: Show legend (default: false)
  • data-chart-y-axis-max {int|float}: Max value for the y-axis (default: 100)
  • data-chart-y-axis-min {int|float}: Min value for the y-axis (default: 0)
  • data-chart-threshold {int|float}: Threshold value for the chart (default: null)
  • data-chart-line-color {string}: Color for the line (only for line chart) (default: FALLBACK_COLOR)
  • data-chart-below-threshold-color {string}: Color for values below the threshold (default: FALLBACK_COLOR)
  • data-chart-above-threshold-color {string}: Color for values above the threshold (default: FALLBACK_COLOR)
  • data-chart-tooltip-label {string}: Datapoint label for the tooltip (default: '')

How to use:

  1. Create a div with the class .icinga-chart.
  2. Collect dataPoints (values) and xAxisTicks (value labels) as an associative array.
for example:
$arr = [
        'dataPoints' => [15, 45, 10, 55],
        'xAxisTicks' => ['Jan', 'Feb', 'Mar', 'Apr']
    ];
  1. Add the data-chart-data attribute to .icinga-chart and assign the collected data ($arr as json) as value.
  2. As the xAxisTicks are of type category, set the data-chart-x-axis-type to category.

The following chart will be rendered:

Screenshot 2024-09-16 at 16 15 36

Implementation

BillboardBehavior (we can rename it to IcingaChartBehavior once transferred to ipl-web) selects all elements with .icinga-chart class, creates the chart configuration using the dataset attributes of the element and generate the chart in a new child div element created via JS (in BillboardBehavior).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or improvement
Projects
None yet
Development

No branches or pull requests

2 participants