librato-api
This package allows you to manage your Librato backend configuration and query time series data, but it is not intended to submit metric data. There are other packages doing that in a better way.
For a full description of the Librato API see the official Librato API documentation.
At the moment support for the following sections is implemented: Authentication, Pagination, Metrics, Spaces, Charts, Alerts, Services, Sources. Note the official API does not expose visual layout of spaces yet, only contents.
Explicit support for the following sections is missing: Annotations, API Tokens, Jobs, Snapshots and Measurements Beta. This is easy to fix, pull requests are welcome.
Examples
// the package is a ready to use client,// using LIBRATO_USER and LIBRATO_TOKEN from the process environmentconst libratoApi = // it's also possible to create a client with custom config (all properties are optional)const LibratoApi = LibratoAPIconst libratoApi = serviceUrl: 'https://...' auth: user: '...' pass: '...' logger: ... request: ... // all methods return PromiseslibratoApi // most methods support an options object which is passed to request-promiselibratoApi // iterates over paginationlibratoApi // get a metric definitionlibratoApi // retrieve one page of time series data for metric and time framelibratoApi // retrieve all pages of time series data for metric and time framelibratoApi // update metric definitionlibratoApi // use custom space finder (getSpace requires id)libratoApi // update chart definition in a spacelibratoApi // not everything is explicitly supported yet, but generic api requests are easy to dolibratoApi
CLI Tool
This package installs a CLI tool named "librato" into your global or package bin-dir.
You have to export LIBRATO_USER and LIBRATO_TOKEN for authentication to work.
export LIBRATO_USER='...'export LIBRATO_TOKEN='...'librato helplibrato list-metrics...
Warning
This tool is quite new and still a bit rough regarding command line parsing, integrated help, etc. To see what it's doing it may be helpful to set LOG_LEVEL to verbose or debug.
Configuration Directory Support
Apart from functions which model single API calls, the tool can take a local directory containing json or js files in a certain structure and apply the contained elements to a Librato account with the "update-from-dir" command. The repository contains an example directory "example-config" which demonstrates this feature.
Note that all elements are referenced by their name (or title for alerts), even if the API usually handles them with a numeric id. This way generic configuration can be applied to multiple Librato accounts, but uniquness of names etc. is assumed.
There is a simple templating feature to create serieses of similar metrics. The "show-config-dir" command can be used to debug templating easily.
In general this will leave alone (not delete) server side elements which are not defined in the config dir, but it can remove elements which are explicitly enumerated in the outdated.json file.