Skip to content

Graphite-web, without the interface. Just the rendering HTTP API.

License

Notifications You must be signed in to change notification settings

icecrime/graphite-api

 
 

Repository files navigation

Graphite-API

Build Status

Coverage Status

Graphite-web, without the interface. Just the rendering HTTP API.

This is a minimalistic API server that replicates the behavior of Graphite-web. I removed everything I could and simplified as much code as possible while keeping the basic functionality.

Implemented API calls:

  • /metrics/find
  • /metrics/expand
  • /metrics/search (removed strange keep_query_pattern parameter)
  • /render

No-ops:

  • /dashboard/find
  • /dashboard/load/<name>
  • /events/get_data

Additional API calls:

  • /index (POST or PUT only): rebuilds the search index by recursively querying the storage backends for available paths. Replaces graphite-web's build-index command-line script.

Difference from graphite-web

  • Stateless. No need for a database.
  • No caching. Rendering is live.
  • No Pickle.
  • JSON data in request bodies is supported, additionally to form data and querystring parameters.
  • Ceres integration will be as an external backend.
  • Compatibility with python 2 and 3.
  • Easy to install and configure.

Goals

  • Solid codebase. Strict flake8 compatibility, good test coverage.
  • Ease of installation/use/configuration.
  • Compatibility with the original Graphite-web API.

Non-goals

  • Support for very old Python versions.
  • Built-in support for every metric storage system in the world. Whisper is included by default, other storages are added via 3rd-party backends.

Installation

git clone git@github.com:brutasse/graphite-api.git
cd graphite-api
sudo python setup.py install

Alternatively, you can run setup.py install as a normal user, in a virtualenv.

Configuration

The default config file path is /etc/graphite-api.conf. The format is YAML.

search_index: /srv/graphite/index
whisper:
  directories:
    - /srv/graphite/whisper
time_zone: Europe/Berlin

If you need the configuration file to be at a different location, you can set the GRAPHITE_API_CONFIG environment variable to the location you want.

Storage finders

Graphite-API can read from any metrics store as long as it has a compatible storage finder. Finders can be configured this way:

finders:
  - graphite_api.finders.whisper.WhisperFinder
  - cyanite.CyaniteFinder

Multiple finders are allowed.

Functions

Custom functions can be added to extend the built-in grammar. The default functions are:

functions:
  - graphite_api.functions.SeriesFunctions
  - graphite_api.functions.PieFunctions

CORS

If your dashboard and your graphite-api server don't have the same hostname, you might need to setup CORS to allow browsers to make cross-domain HTTP requests.

For example, if you have graphite-api on https://api.graph.example.com and grafana on https://dashboard.graph.example.com, you need the following in your graphite-api config:

allowed_origins:
  - dashboard.graph.example.com

You can add as many hosts as you want.

Error handling

Request exceptions can be sent to Sentry for painless debugging.

Just add to your config:

sentry_dsn: https://key:secret@host/id

And install raven, the sentry client:

pip install raven[flask]

Deploying

With Gunicorn or any WSGI server. The WSGI application is located at graphite_api.app:app.

sudo pip install gunicorn
gunicorn graphite_api.app:app

Hacking

Tox is used to run the tests for all supported environments. To get started from a fresh clone of the repository:

pip install tox
tox

About

Graphite-web, without the interface. Just the rendering HTTP API.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 99.9%
  • Shell 0.1%