ExometerDatadog v0.4.2 ExometerDatadog

ExometerDatadog integrates exometer with datadog via the datadog REST API.

It’s already possible to use the existing exometer_report_statsd reporter to feed data in to the dogstatsd agent. However, there are some situations where that is not ideal (or even possible). This library aims to cover those situations by directly submitting exometer statistics to datadog via the REST API.

Setup

To pull in ExometerDatadog to your application, you should add it to your dependencies and list of applications in mix.exs, and then add an api_key and app_key to your configuration. For example:

config :exometer_datadog,
   api_key: 'abcd',
   app_key: 'defg'

You may want to put this in prod.secret.exs or similar to avoid checking the keys in to your repository.

Now ExometerDatadog should startup along with your app. For details of what it does on startup, see start/2.

Configuration

ExometerDatadog gets it’s configuration from the mix config files. It has these config settings:

  • api_key is the datadog API key to send metrics with.
  • app_key is the datadog app key to send metrics with.
  • host_fn is a {module, function} tuple that specifies a function to be called to determine the hostname to report to datadog. Defaults to :inet.gethostname
  • host can be used instead of host_fn to hard-code the hostname.
  • add_reporter controls whether ExometerDatadog.Reporter will be registered on application startup. By default this is true.
  • report_vm_metrics controls whether VM metrics will be reported to datadog.
  • update_frequency controls the frequency with which VM metrics will be updated.
  • report_system_metrics controls whether VM metrics will be reported to datadog.
  • metric_prefix can be provided as a list of atoms to prefix the VM metric names with.
  • reporter_config can be used to provide config to the reporter. See ExometerDatadog.Reporter for more details on it’s configuration.

Loading Config from environment variables.

In some cases it might be desirable to load some of the above settings (the api_key for example) from environment variables. ExometerDatadog supports this. Simply set your mix config value to {:system, "ENV_VAR"} (where “ENV_VAR” is your environment variable name), and ExometerDatadog will read from the environment on startup.

For example, this would cause the api key & app key to be loaded from DATADOG_API_KEY & DATADOG_APP_KEY:

config :exometer_datadog,
  api_key: {:system, "DATADOG_API_KEY"},
  app_key: {:system, "DATADOG_APP_KEY"}

Summary

Functions

This adds system metrics to exometer

Creates some exometer metrics that report the status of the VM

Registers the datadog reporter with exometer

Starts the ExometerDatadog application

Functions

add_system_metrics()

This adds system metrics to exometer.

Currently this uses files located within /proc so will only work on linux machines.

add_vm_metrics()

Creates some exometer metrics that report the status of the VM.

This will create a number of metrics that report statistics about the VM to datadog.

register_reporter(opts \\ [])

Registers the datadog reporter with exometer.

This will automatically be done on application startup, but this function is provided to allow manual operation as well.

Options

By default these will be pulled from the exometer_datadog config, however they can be overridden here.

  • api_key - The datadog API key to use.
  • app_key - The datadog app specific API key to use.
start(type, args)

Starts the ExometerDatadog application.

This will:

  • Register the ExometerDatadog.Reporter with exometer. See register_reporter/1.
  • Optionally create some VM metrics and subscribe them to the datadog reporter. See add_vm_metrics/0. This is disabled by default.
  • Optionally create some system metrics and subscribe them to the datadog reporter. See add_system_metrics/0. This is disabled by default.