WHERE DO I START?
You are here:Integrations > Etsy StatsD

Etsy StatsD

Etsy StatsD is one of the most popular StatsD libraries available. Netuitive offers a backend plugin for the Etsy StatsD library that allows you to send your StatsD metric data to Netuitive. We recommend using our Etsy StatsD integration if you currently have an Etsy StatsD server running and want to send your instrumented data to Netuitive. For more information about Etsy StatsD, see the following documentation.

Note   If you do not have a StatsD server already, we recommend using our Netuitive StatsD server that's bundled with our Linux agent. Read more about the Netuitive StatsD server here.

Dependencies

OS

UNIX-like OS
Node.js

Configuration

Installation

Setting up an Etsy StatsD integration is a three-step process:

  1. Copy the unique API key from the Etsy StatsD integration in your account.
  2. Copy netuitive.js and the netuitive directory to your StatsD backends directory.
  3. Edit your StatsD configuration file.

Step 1: Copy the unique API key from the StatsD integration in your account

  1. From the top navigation menu, click Integrations.
  2. Click the Etsy | StatsD card. Data collection should already be enabled, and a unique API key for your account has already been generated.
  3. Copy the API key.
    Note   You will use this API key in Step 3.

Step 2: Copy netuitive.js and netuitive directory to your StatsD backends directory

  1. Clone the Netuitive StatsD Backend project to the desired location.
  2. Copy the netuitive.js file and the entire netuitive directory to your StatsD backend directory. For more information about cloning existing repositories in Stash with Git, see the following documentation.

Step 3: Edit your StatsD configuration file

  1. Open your local StatsD configuration file.
  2. In your configuration file, add "./backends/netuitive" to the backends section.
    {
      backends:[
        "./backends/netuitive"
      ]
    }
    
  3. Add the following lines below the backends section:
    {
      backends:[
        "./backends/netuitive"
      ],
      netuitive: {
        apiKey: "YOUR_API_KEY",
        apiHost: "api.app.netuitive.com",
        apiPort: 443,
      }
    }
    

    ... where YOUR_API_KEY should be the the unique API key generated for your account that you copied in step 1, and the apiPort should be set to the proper port number (if necessary).

  4. In order to associate StatsD metrics with an element in Netuitive, ensure that there is at least one mapping for Netuitive defined in the mappings section of your StatsD configuration file. Each mapping uses a pattern with a regular expression (regex) that corresponds with a set of keys in StatsD. The regex value can convert these keys to metrics that belong to an element in Netuitive. If the element or metric name is in the StatsD key, it can be represented by $(regex-captured-group-number), demonstrated in the code below. Element and metric names can also be written as a string literal. You can define more than one mapping to capture multiple metrics that belong to the same element or to capture different elements. You can also add tags to metrics, though a name is required for each tag block; both name and value can use either ${regex-captured-group-number} or string literal. There are many online regex tools that can help you with the mapping process (e.g. regex101). Element types are required and metric names have their metric type appended before matching against the pattern i.e. ".counter", ".gauge", ".timer".
  5. Example(s)   
    {
      backends:["./backends/netuitive"],
      netuitive: {
        apiKey: "YOUR_API_KEY",
        apiHost: "YOUR_NETUITIVE_API_HOST",
        apiPort: 443,
        mappings: [
          {
            pattern: "(.*?app.*?)\\.(.*?\\.mean)\\.gauge",
            element: {
              type: "APP Server",
              name: "$1",
              metric: {
                name: "$2"
              } 
            }
          },
          {
            pattern: "(.*?app.*?)\\.(service.utilization)\\.gauge",
            element: {
              type: "APP Server",
              name: "$1",
              metric: {
                name: "$2",
                tags: [
                  {"name": "utilization", "value":"true"}
                ]
              }
            }
          },
          {
            pattern: "\^(statsd\\..*)",
            element: {
              type: "StatsD",
              name: "StatsD",
              metric: {
                name: "$1"
              }
            }
          },
          {
            pattern: "\^(timestamp_lag.*)",
            element: {
              type: "StatsD",
              name: "StatsD",
              metric: {
                name: "statsd.$1"
              }
            }
          }
        ]
      }
    }
  6. We recommend that you set the flushInterval in your StatsD configuration file to 60000 milliseconds. This will ensure that your StatsD data is collected by Netuitive every 1 minute.
  7. After saving the configuration file, restart StatsD.