magneticio/vamp

There should be a list with metric names that are requestable on the metric endpoint

tnolet opened this issue · 2 comments

The docs don't state what metrics are available on the metrics endpoint or directly on elasticsearch.
It's very unclear how to query them either using the REST endpoint /metrics or using direct queries to elasticsearch. Furthermore there seem to be three naming schemes:

  1. haproxy acronyms like "Tt" and "ft", see https://gist.github.com/ayosec/8112308
  2. hyphened full words, "response-time", see https://vamp.io/documentation/api/v0.9.5/api-metrics/
  3. camelCased full words, responseTime in the event tab in the UI.

+1

The mapping of the haproxy native names to, in this case camelCased names, is done in the metrics workflow. See snippet below. It also shows that per default, only rate and responseTime are inserted into the metrics stream. Our examples talk about a bunch of other metrics, i.e. scur in https://vamp.io/documentation/using-vamp/v0.9.5/events/#example-3

  type: application/javascript
  definition: |
    'use strict';

    let _ = require('highland');
    let vamp = require('vamp-node-client');

    let api = new vamp.Api();
    let logger = new vamp.Log();
    let metrics = new vamp.ElasticsearchMetrics(api);

    let window = 30; // seconds

    function publish(tags, metrics) {
      logger.log('metrics: [' + JSON.stringify(tags) + '] - ' + metrics);
      api.event(tags, metrics, 'metrics');
    }

    api.gateways().each(function (gateway) {

      metrics.average({ft: gateway.lookup_name}, 'Tt', window).each(function (response) {
        publish(['gateways:' + gateway.name, 'gateway', 'metrics:rate'], response.rate);
        publish(['gateways:' + gateway.name, 'gateway', 'metrics:responseTime'], response.average);
      });

      api.namify(gateway.routes).each(function (route) {
        metrics.average({ft: route.lookup_name}, 'Tt', window).each(function (response) {
          publish(['gateways:' + gateway.name, 'routes:' + route.name, 'route', 'metrics:rate'], response.rate);
          publish(['gateways:' + gateway.name, 'routes:' + route.name, 'route', 'metrics:responseTime'], response.average);
        });
      });
    });