config

package
v0.0.0-...-8487dac Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 3, 2016 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package config parses config files for metaphite.

metaphite config files are in JSON format, and consists of a single JSON object containing string/string pairs. The key should be a metrics prefix to match, and the value should be a URL for the graphite server. For example,

{
	"address": ":80",
	"mappings": {
		"dev": "https://dev-graphite.example.net/",
		"production": "https://graphite.example.net/",
		"staging": "https://stage-graphite.example.net/"
	}
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Do not validate HTTPS certs
	InsecureHTTPS bool
	// directory to load CA certs from
	CACertDir string
	// file to load CA certs from
	CACert string
	// The address to listen on, if not specified on the command line.
	Address string
	// Maps from metrics prefix to backend URL.
	Mappings map[string]string
	// Dump proxied requests
	Debug bool
	// contains filtered or unexported fields
}

A Config contains the necessary information for running a metaphite server. Most importantly, it contains the mappings of metrics prefixes to backend servers. In the config JSON, the value of the "mappings" key must be an object of prefix -> URL pairs.

func Parse

func Parse(r io.Reader) (*Config, error)

Parse parses the config data from r and parses its content into a *Config value.

func ParseFile

func ParseFile(path string) (*Config, error)

ParseFile opens the config file at path and calls Parse on it.

func (*Config) ServeHTTP

func (c *Config) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP routes a graphite render query to a backend graphite server based on its content. If the query contains metrics that map one (and only one) of the prefixes in a configuration, ServeHTTP will strip the prefix and proxy the request to the appropriate backend server.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL