InfluxDB

heiko-braun edited this page Nov 6, 2014 · 39 revisions

Using InfluxDB with Wildfly

The monitor subsystem can be configured to use InfluxDB for storing the metric data. In these section we'll walk through the necessary steps to install and configure the subsystem and related components to create a simple end-to-end solution.

Getting Started

Install the monitor subsystem

The monitor subsystem needs to be installed on a Wildfly instance. The README covers it in great detail.

Install InfluxDB

Either leverage the hosted service or install Influx locally. Make a note of the database name, the user and password. It's needed to configure the storage adapter later on.

Don't worry, the accounts at http://play.influxdb.org/ are free for a limited time

Subsystem Configuration

In order to leverage influx you need to re-configure the storage adapter (influx) and point it to the database you intend to use. In this example we are using the hosted service, running at sandbox.influxdb.com:8086:

<subsystem xmlns="urn:org.rhq.metrics:wildfly-monitor:1.0">

  <storage-adapter
    name="influx"
    url="http://sandbox.influxdb.com:8086" 
    db="<db_name>"
    user="<user>"
    password="<password>"/>

  <server-monitor name="default" enabled="true" num-threads="2">

        <data-input name="heap"
                    seconds="20"
                    resource="/core-service=platform-mbean/type=memory"
                    attribute="heap-memory-usage#used"/>

        <data-input name="non-heap"
                    seconds="20"
                    resource="/core-service=platform-mbean/type=memory"
                    attribute="non-heap-memory-usage#used"/>

        <data-input name="thread-count"
                    minutes="1"
                    resource="/core-service=platform-mbean/type=threading"
                    attribute="thread-count"/>

    </server-monitor>

    <diagnostics
            name="console"
            enabled="true" seconds="10"/>
</subsystem>

Accessing the data

Before getting your hands on the web interface or the CLI it helps to make yourself familiar with influx query language. Both Grafana and the CLI make use of it.

Grafana Dashboards

Grafana is web application that allows you to easily create dashboards. To use it with Wildfly, you need to configure the web application and point it to your influx database (config.js):

 datasources: {
      influxdb: {
        default: true,
        type: 'influxdb',
        url: "http://sandbox.influxdb.com:8086/db/<db_name>",
        username: '<user>',
        password: '<password>'
      },
      grafana: {
        type: 'influxdb',
        url: "http://sandbox.influxdb.com:8086/db/<db_name>",
        username: '<user>',
        password: '<password>',
        grafanaDB: true
      },
    },

Once that is done, you can deploy the web application to wildfly and access it locally (http://localhost:8080/grafana-1.8.1/) .

Command Line Access

There are plenty of Influx command line tools, but influx-cli has proven to be quiet useful.

Connect to the database:

node ./influxdb-cli -h sandbox.influxdb.com -u <user> -p <password> -d <db_name>

Verify your metrics are propagated:

wildfly-test> ✔ ready
wildfly-test> list series;
┌──────┬────────────────────────────────────┐
│ time │ name                               │
├──────┼────────────────────────────────────┤
│ 0    │ radio-86rk-2.heap-memory-usage     │
│ 0    │ radio-86rk-2.non-heap-memory-usage │
│ 0    │ radio-86rk-2.thread-count          │
└──────┴────────────────────────────────────┘
Query took  303 ms

Query the data points:

wildfly-test> select * from "radio-86rk-2.heap-memory-usage";
┌───────────────┬─────────────────┬───────────┐
│ time          │ sequence_number │ datapoint │
├───────────────┼─────────────────┼───────────┤
│ 1415192498489 │ 12970001        │ 126515968 │
│ 1415192478488 │ 12940001        │ 122902160 │
│ 1415192458584 │ 12930001        │ 119396104 │
│ 1415192438486 │ 12890001        │ 115891632 │

Need help on the query language? Checkout the InfuxDB documentation

Trouble Shooting

The wildfly monitor and related components are in it's early stages. If you run into problems or have further suggestions, please let us know.