Skip to content

Instantly share code, notes, and snippets.

@mattyjones
Last active November 5, 2016 23:49
Show Gist options
  • Save mattyjones/7376b7dc8590a93a34ffeb641571f288 to your computer and use it in GitHub Desktop.
Save mattyjones/7376b7dc8590a93a34ffeb641571f288 to your computer and use it in GitHub Desktop.

Defining A Telegraf Plugin In Elzar

This serves as a style and example guide for configuring chef attriutes to install and manage telegraf plugins.

Setting the attribute name

Set the top level attribute naming scheme, this is used for plugins going out to the entire cookbook and will be the most commmon example.

default['devops_artifactory']['telegraf']['inputs'] = {}

This is used if you have multiple applications in the cookbook and only want specific plugins to go to them.

default['devops_azkaban']['executor']['telegraf']['inputs']  = {}
default['devops_azkaban']['solo']['telegraf']['inputs']      = {}
default['devops_azkaban']['web']['telegraf']['inputs']       = {]

Defining a plugin

This defines a specific plugin, in this case procstat. See the documentation for each input for a full list of configuration options. The enabled key below controls whether chef will install or uninstall a plugin. If set to true it will install it, and if set to false it will delete it if it exists. While this key does not need to be explictly set (default is true), it should be set to improve debuging, readablity, and portability.

NOTE: When using the procstat plugin for acquiring the metrics for a process, the pname tag MUST be set. All Java process will only report their name as Java, which means alerting on a specific process is useless if you have more than one java app on a system. Setting it to a user defined string will also allow greater control in how alerts are written in kapacitor and will allow for improved filtering in the Influx UI.

'process-artifactory' => {
    'config' => {
      'pid_file' => '/var/opt/jfrog/run/artifactory.pid',
      'tags' => {
        'pname' => 'artifactory'
      },
    },
    'enabled' => true,
    'type' => 'procstat'
  },

This following defines a set of metrics associated with a URL. For specifics please see the telegraf docuemntation for the desired input.

NOTE: The tag telegraf_location SHOULD be set. This will ensure that in both the Influx UI and kapacitor there is a way to tell if a check is running on the localhost or remote via another host or container. If it is running on a container the Host field will currently report as telegraf-container and if running on a machine it will report as the host name.

This functionality may work in most cases but this tag will give further clarification and allow filtering based up a specific cluster/node or other data source.

  'endpoint-artifactory' => {
    'config' => {
      'address' => 'https://localhost/artifactory/webapp/#/login',
      'response_timeout' => '5s',
      'method' => 'GET',
      'insecure_skip_verify' => true,
      'follow_redirects' => false,
      'tags' => {
        'telegraf_location' => 'local'
      },
    },
    'enabled' => true,
    'type' => 'http_response'
  },
  'endpoint-redirect-artifactory' => {
    'config' => {
      'address' => 'https://localhost',
      'response_timeout' => '5s',
      'method' => 'GET',
      'follow_redirects' => false,
      'insecure_skip_verify' => true,
      'tags' => {
        'telegraf_location' => 'local'
      },
    },
    'enabled' => true,
    'type' => 'http_response'
  },
}

Style Notes

  • All attributes and plugins need to be in alphabetical order
  • All = need to be aligned vertically
  • All linting tests must pass bundle exec rake test:all cb=COOKBOOK
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment