簡體   English   中英

使用NodeJS通過libbrado檢索指標

[英]Retrieving metrics through librado using NodeJS

早上好!

我在嘗試從librato獲取單個數字以在html頁面中使用時遇到了麻煩。

我只想獲取指標AWS.Billing.EstimatedCharges.total的最后一個值,即花費該值並將其全部放到HTML頁面中的客戶端名稱(簡單,但對我而言不行)

我正在嘗試使用此API https://github.com/goodeggs/librato-node而且我仍然不知道如何解決此問題。

ps:我無法使用嵌入圖表。

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); });

嘗試npm install librato-metrics ,這里有很多猜測,因此請報告} 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);

      }
    });

```

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM