Build from Source with Docker

This section describes how to build the OpenNMS Plugin for Grafana with Docker.

Simple build

You can compile the plugin from source with a Docker build image:

  1. Check out the repository, compile the code, and install the plugin:

    docker build -t mygrafanapluginimage .
  2. Run the image:

    docker run -p 3000:3000 -t mygrafanapluginimage
  3. Log in to your Grafana instance with the default admin credentials (admin/admin).

  4. Navigate to Plugins and enable the OpenNMS Plugin for Grafana.

The Grafana plugin directory location is changed from /var/lib/grafana/plugins to /opt/grafana/plugins. This is because the base Grafana image defines /var/lib/grafana as a volume, which cannot be changed.

Advanced build

If you want to build the OpenNMS Plugin for Grafana based on a specific GitHub fork or branch, you can use --build-arg:

docker build -t mycustomforkbranch \
            --build-arg OPENNMS_GRAFANA_PLUGIN_GIT_URL=https://github.com/OpenNMS/grafana-plugin.git \
            --build-arg OPENNMS_GRAFANA_PLUGIN_GIT_BRANCH_REF=myBranch

This creates the plugin based on the GitHub URL and branch that you provide.

Build service stack with Docker Compose

The plugin package includes an example docker-compose.yml, which builds a service stack with a compiled OpenNMS Plugin for Grafana that you can test. You can modify the build arguments in the file if you want to build from a specific GitHub fork, branch, or version tag.

When you first run docker-compose up -d, the plugin is compiled from the source. Subsequent runs will use the compiled image from your local system. If you want to rebuild the image, run docker-compose build --no-cache.

The URL for your Horizon or Meridian datasource is http://opennms:8980/opennms.

Configure Docker for PDF reports

Horizon and Meridian include templates from which you can create PDF reports. They use an existing Grafana dashboard (see Grafana Dashboard in the main OpenNMS documentation). If you want to use this feature, and you are running the OpenNMS Plugin for Grafana through Docker, you must complete additional configuration. Refer to Grafana’s remote rendering service documentation for more information.