Experimental project

This is a sandbox project, which contains experimental code for developer use only.

Overview

The goal of this module is to facilitate the submission of custom metrics to the Stackdriver web-service. A custom hook is used to collect user-defined metric names and values when a drush command is run. These names and values are then compiled and sent to Stackdriver.


More information regarding Stackdriver can be found on their website, here: Stackdriver

Requirements

This module is designed for use with Drupal 7, further compatibility has not been tested.

Tutorials

  • Inserting Your API Key (Module must be enabled)

    1. Navigate to your Drupal site.
    2. Sign in as a site administrator.
    3. Navigate to the settings menu for Custom Stackdriver Metrics by following the path: admin/settings/custom_stackdriver_metrics.
    4. Insert your Stackdriver API Key in the API Key field.
    5. Click the button labeled: Save Configuration.

    Congratulations, you have successfully inserted your API Key!


  • Preparing to Send Custom Metrics

    The following example code may be implemented in any module within your Drupal installation that is enabled .

    <module>_stackdriver_metrics() {
          $items = array();
          $items['<name_of_metric>'] = array(
              'name' => '<name_of_metric>'
              'value' => <function_that_returns_value>()
          );
          return $items;
    

    Replace <module> with the name of your module, <name_of_metric> with the name of the metric you want to send, and <function_that_returns_value> with a function that will return the value of your metric.

    You may add other metrics to the $items array by following the same format.

    That's it! The Custom Stackdriver Metrics module will take care of the rest.


  • Sending Custom Metrics

    (Requires Inserting Your API Key and Preparing to Send Custom Metrics).

    1. Access the command line of the server on which your Drupal installation is hosted (using PuTTy or a comparable program if needed).
    2. Run the command: drush send_stackdriver_metrics.
    3. If the metrics were successfully uploaded to Stackdriver, you will see a status of Published echoed in the command line. Otherwise, an error message will appear detailing what caused the POST to fail.
    4. To view your custom metrics, navigate to Stackdriver > Services > Custom Metrics.
    5. Again, that's it! Super simple.

Project information