plugin

package
v0.0.0-...-f82f096 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2017 License: Apache-2.0 Imports: 17 Imported by: 0

README

DC/OS Metrics Service Plugins

NOTE These plugins are considered experimental and are not supported by the DC/OS support team. If you're having issues, please feel free to file an issue to this repo (not github.com/dcos/dcos) or file a Pull Request (we love pull requests!).

Though your mileage may vary, if there is a plugin missing that you need, please feel free to file an issue so we can poll what services our users want the most.

Developing

To develop a new plugin in preparation for a pull request to this project:

Plugin Development

  1. Create a new package for your cool plugin mkdir plugins/cool/
  2. Make a go file named after your package touch plugins/cool/cool.go
Get a new plugin.Plugin{}
  1. Create flags: myFlags := []cli.Flag{}
  2. myPlugin := plugin.New(myFlags) -> plugin.Plugin{}
  3. Use myPlugin.App.Action and pass it a cli.ActionFunc() which has all the main() logic your plugin needs.
  4. Call myPlugin.Metrics() which returns a slice of producers.MetricsMessage{} from the metrics HTTP API.

At this point you can write what ever helper methods you need to transform these and send to your metrics aggregation or cloud hosted service.

Unit Test Coverage

  1. Add a unit test (aim for 80% coverage)
Add a README.md in your cool package explaining:
vi plugins/cool/README.md
# The Cool Plugin
This cool plugin allows you to plugin to cool stuff.

# How To Run Me
1. ...

# Caveats
I knew there were caveats!
Submit a Pull Request!

Ping @malnick on DC/OS community slack :)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DatapointValueToFloat64

func DatapointValueToFloat64(value interface{}) (float64, error)

DatapointValueToFloat64 converts a Datapoint's Value from an interface{} to a float64.

func ParseDatapointTimestamp

func ParseDatapointTimestamp(timestamp string) (*time.Time, error)

ParseDatapointTimestamp parses an RFC3339 timestamp to a *time.Time

Types

type Option

type Option func(*Plugin) error

Option lets each plugin configure the Plugin type. The plugin.New(...) method will call each supplied Option before returning the initialized Plugin.

func ConnectorFunc

func ConnectorFunc(connect func([]producers.MetricsMessage, *cli.Context) error) Option

ConnectorFunc is what the plugin framework will call once it has gathered metrics. It is expected that this function will convert these messages to a 3rd party format and then send the metrics to that service.

func ExtraFlags

func ExtraFlags(extraFlags []cli.Flag) Option

ExtraFlags sets additional cli.Flag's on the Plugin

func MetricsHost

func MetricsHost(h string) Option

MetricsHost allows the plugin to set a custom hostname for the url it calls to gather metrics.

func MetricsPort

func MetricsPort(port int) Option

MetricsPort allows the plugin to set a custom port for the url it calls to gather metrics.

func MetricsProtocol

func MetricsProtocol(proto string) Option

MetricsProtocol allows the plugin to set either "http" or "https" for the url it calls to gather metrics.

func Name

func Name(n string) Option

Name allows the plugin to set a custom name for itself.

func PollingInterval

func PollingInterval(i int) Option

PollingInterval sets the polling interval to the supplied value.

type Plugin

type Plugin struct {
	App               *cli.App
	Name              string
	Endpoints         []string
	Role              string
	PollingInterval   int
	MetricsPort       int
	MetricsScheme     string
	MetricsHost       string
	Log               *logrus.Entry
	ConnectorFunc     func([]producers.MetricsMessage, *cli.Context) error
	Client            *http.Client
	ConfigPath        string
	IAMConfigPath     string `yaml:"iam_config_path"`
	CACertificatePath string `yaml:"ca_certificate_path"`
}

Plugin is used to collect metrics and then send them to a remote system (e.g. DataDog, Librato, etc.). Use plugin.New(...) to build a new plugin.

func New

func New(options ...Option) (*Plugin, error)

New returns a mandatory plugin config which every plugin for metrics will need

func (*Plugin) Metrics

func (p *Plugin) Metrics() ([]producers.MetricsMessage, error)

Metrics polls the DC/OS components and returns a slice of producers.MetricsMessage.

func (*Plugin) StartPlugin

func (p *Plugin) StartPlugin() error

StartPlugin starts a (previously configured) Plugin. It will periodically poll the system for metrics and send them to the ConnectorFunc. This method will block.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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