Use Grafana Data Source Plugin for Observations

This document describes how to install the Data Source plugin locally in Grafana and make observations using Grafana Data Source.

Use Grafana Data Source Plugin for Observations - 图1note

  • Grafana should be in 7.0.0 or later versions.
  • The Data Source plugin cannot be installed through grafana-cli at this time, because Grafana has not yet accepted the plugin submission for Chaos Mesh Data Source.

Install Data Source Plugin

You can install the Data Source plugin locally in Grafana by following these steps:

  1. Download the plugin zip package with the following command, or visit https://github.com/chaos-mesh/datasource/releases to download the package:

    1. curl -LO https://github.com/chaos-mesh/datasource/releases/download/v2.1.0/chaosmeshorg-datasource-2.1.0.zip

    After downloading, extract the plugin to the Grafana plugin directory:

    1. unzip chaosmeshorg-datasource-2.1.0.zip -d YOUR_PLUGIN_DIR

    Use Grafana Data Source Plugin for Observations - 图2tip

    To find the plugin directory, refer to https://grafana.com/docs/grafana/latest/plugins/installation/#install-a-packaged-plugin.

  2. Update and save the configuration file grafana.ini of Grafana. Then, add the plugin to allow_loading_unsigned_plugins to ensure that Grafana can load the unsigned plugin:

    1. [plugins]
    2. allow_loading_unsigned_plugins = chaosmeshorg-datasource

    Use Grafana Data Source Plugin for Observations - 图3tip

    To find the configuration file, refer to https://grafana.com/docs/grafana/latest/administration/configuration/#config-file-locations.

  3. Finally, restart Grafana to load the Data Source plugin.

Set up Data Source Plugin

  1. After you have successfully installed the Data Source plugin locally in Grafana, go to Configuration -> Data sources and add Chaos Mesh to there, then visit the following configuration page:

    Configuration page

    On this page, only the URL field needs to be filled in, and the other fields can be ignored.

    Suppose that you have installed Chaos Mesh locally. In this case, Dashboard exports the API on port 2333 by default. Therefore, if you have not changed anything, you can write http://localhost:2333 in URL.

  2. Then use the port-forward command to make the API externally accessible:

    1. kubectl port-forward -n chaos-testing svc/chaos-dashboard 2333:2333
  3. Click Save & Test to test the connection. If it shows a successful notification, the set-up is complete.

Query

The Data Source plugin observes Chaos Mesh from the perspective of events. The following options are responsible for filtering different events:

  • Object ID: Filter by object UUID
  • Namespace: Filter by different namespace
  • Name: Filter by object name
  • Kind: Filter by kind (PodChaos, Schedule, and so on)
  • Limit: Limit the number of events

The settings for these options are passed as parameters to the /api/events API.

Annotations

You can integrate Chaos Mesh events into the panel by setting up Annotations. For example:

Annotations

For information on how to fill in the fields in annotations, refer to Query.

Variables

You can query Chaos Mesh for events dynamically by setting different variables.

Variables

The types of variables provided by the plugin are as follows:

  • Namespace: After your selection, all available namespaces are displayed directly at the bottom of the page under Preview of values.
  • Kind: Same as Namespace. It can get all kinds.
  • Experiment: Same as Namespace. It can get the names of all experiments.
  • Schedule: Same as Namespace. It can get the names of all schedules.

Questions and feedback

If you encounter problems during installation or set-up, you are welcome to ask questions to the community at CNCF Slack, or create an GitHub issue to communicate with the Chaos Mesh team.

What’s next

If you want to learn more details about the Data Source plugin, feel free to check out the source code for the plugin at chaos-mesh/datasource.