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

Connecting Gauges and Charts #14

Open
wedwards99 opened this issue May 15, 2014 · 1 comment
Open

Connecting Gauges and Charts #14

wedwards99 opened this issue May 15, 2014 · 1 comment

Comments

@wedwards99
Copy link

I've successfully connected up a few of the dashboard GUI components, logs, process, etc. to our running application but am having some trouble getting numeric values into gauges and charts, I can hook up two non-GUI sides okay. Like this fairly simple example:

Process A

var Monitor = require('monitor').start();
var stat = Monitor.getStatLogger('lint');
setInterval(function () {
    var randomInt = Math.floor(Math.random() * (10));
    stat.increment('loop.counter', randomInt);
    console.log('Changed stat to: ' + randomInt);
}, 5000);

Output
Changed stat to: 3
Changed stat to: 8
Changed stat to: 5

Process B

var util = require('util');
var Monitor = require('monitor');

var statOptions = {
    hostName: 'localhost',
    probeClass: 'Stat',
    initParams: {
        pollInterval: 1000,
        pattern: 'lint.loop.counter'
    }
};
var statMonitor = new Monitor(statOptions);

statMonitor.on('change', function (data) {
    console.log(util.inspect(statMonitor.get('bundle')));
});

statMonitor.connect(function (error) {
    console.log('Connect stat return');
    if (error) {
        console.error('Error connecting with the stat probe: ', error);
        process.exit(1);
    }
});

Output
[ [ '2014-05-15T21:52:26.691Z', 'lint', 'loop.counter', 3, 'c' ] ]
[ [ '2014-05-15T21:52:31.702Z', 'lint', 'loop.counter', 8, 'c' ] ]
[ [ '2014-05-15T21:52:36.713Z', 'lint', 'loop.counter', 5, 'c' ] ]

So far so good.

Where I am having trouble is in getting that loop.counter integer to show in a Gauge or in a Line chart. For, example this is the monitor definition for a the Gauge as far as I have it:

  "monitor": {
    "probeClass": "Stat",
    "hostName": "localhost",
    "appName": "",
    "appInstance": "1",
    "probeId": "59cb6efe-7cf7-a7b1-43ec-1384735b292a",
    "id": "",
    "name": "",
    "probeName": "Stat",
    "initParams": {
      "pollInterval": 1000,
      "pattern": "lint.loop.counter"
    },
    "writableAttributes": []
  },

But I'm guessing I need at least one more dab of glue to get it hooked up.

Thanks a lot, in advance,
Will

@lorenwest
Copy link
Owner

Hi Will,

You're absolutely right - a little glue is all you need. In this case, you're probably wanting some code that breaks apart the bundle, placing it into the graph data.

The charts are Highcharts, and there's lots of documentation on the web as to how they work. Drag a new chart into your page, and open the settings form. In the JavaScript onInit field, enter the code you have above to connect with your remote monitor, read the bundle, then place the results into the chart data.

At some point this will be more automated, but for now you have to write a little code to place data into the chart. Start by placing any data into the chart - some constants. Then migrate that to data you've read from a remote monitor. You're already well on your way!

-Loren

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

No branches or pull requests

2 participants