1

Good morning!

I'm having troubles trying to get a single number from librato to use in a html page.

I just want to get the last value of the metric AWS.Billing.EstimatedCharges.total, the name of the client that spent that value and put it all together in a HTML page (simple, but not to me)

I'm trying to use this API https://github.com/goodeggs/librato-node And I still not figured out how to solve this problem.

ps: I cannot use the embed chart.

var http = require('http'); 
http.createServer(function (req, res) { }).listen(1337, "127.0.0.1"); 
console.log('Server running at 127.0.0.1:1337/'); 
var librato = require('librato-node'); 
api = librato.configure({email: 'myemail', token: 'mytoken'}); 
librato.start(); process.once('SIGINT', function() { librato.stop(); 
// stop optionally takes a callback }); 
// Don't forget to specify an error handler, otherwise errors will be thrown
librato.on('error', function(err) { console.error(err); });
Stewartside
  • 20,378
  • 12
  • 60
  • 81
Rando1234
  • 11
  • 1
  • Hello and welcome to SO! Can you show what you have tried in code please – Fuzzybear Dec 19 '16 at 12:06
  • var http = require('http'); http.createServer(function (req, res) { }).listen(1337, "127.0.0.1"); console.log('Server running at http://127.0.0.1:1337/'); var librato = require('librato-node'); api = librato.configure({email: 'myemail', token: 'mytoken'}); librato.start(); process.once('SIGINT', function() { librato.stop(); // stop optionally takes a callback }); // Don't forget to specify an error handler, otherwise errors will be thrown librato.on('error', function(err) { console.error(err); }); – Rando1234 Dec 19 '16 at 12:08
  • after this point I dont know what to do – Rando1234 Dec 19 '16 at 12:09
  • this code basically up the server and makes the conection to the librato service – Rando1234 Dec 19 '16 at 12:10

1 Answers1

0

Try npm install librato-metrics, there's a lot of guessing here so please report back }8*)

const client = require('librato-metrics').createClient(
{
  email: process.env.LIBRATO_METRICS_EMAIL,
  token: process.env.LIBRATO_METRICS_TOKEN
}


  const payload = {
    count: 1,
    resolution: 60
  };

  client.get('/metrics/AWS.Billing.EstimatedCharges.total', payload,
    function(err, response) {
      if (err) {
        console.error(err, payload);            
      } else {
        console.log(response);

      }
    });

```

stujo
  • 2,089
  • 24
  • 29