• This repository has been archived on 04/Mar/2023
  • Stars
    star
    119
  • Rank 297,930 (Top 6 %)
  • Language
    Go
  • License
    Apache License 2.0
  • Created about 10 years ago
  • Updated over 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A Statsd implementation written in GO lang

statsgod

Build Status

Statsgod is a metric aggregation service inspired by the statsd project. Written in Golang, it increases performance and can be deployed without dependencies. This project uses the same metric string format as statsd, but adds new features like alternate sockets, authentication, etc.

Usage

Usage:  statsgod [args]
  -config="config.yml": YAML config file path

Example:

  1. start the daemon.

    gom exec go run statsgod.go
    
  2. Start a testing receiver.

     gom exec go run test_receiver.go
    
  3. Send data to the daemon. Set a gauge to 3 for your.metric.name

     echo "your.metric.name:3|g" | nc localhost 8125 # TCP
     echo "your.metric.name:3|g" | nc -4u -w0 localhost 8126 # UDP
     echo "your.metric.name:3|g" | nc -U /tmp/statsgod.sock # Unix Socket
    

Metric Format

Data is sent over a socket connection as a string using the format: [namespace]:[value]|[type] where the namespace is a dot-delimeted string like "user.login.success". Values are floating point numbers represented as strings. The metric type uses the following values:

  • Gauge (g): constant metric, keeps the last value.
  • Counter (c): increment/decrement a given namespace.
  • Timer (ms): a timer that calculates averages (see below).
  • Set (s): a count of unique values sent during a flush period.

Optionally you may denote that a metric has been sampled by adding "|@0.75" (where 0.75 is the sample rate as a float). Counters will inflate the value accordingly so that it can be accurately used to calculate a rate.

An example data string would be "user.login.success:123|c|@0.9"

Sending Metrics

Client code can send metrics via any one of three sockets which listen concurrently:

  1. TCP

    • Allows multiple metrics to be sent over a connection, separated by a newline character.
    • Connection will remain open until closed by the client.
    • Config:
      • connection.udp.enabled
      • connection.udp.host
      • connection.udp.port
  2. UDP

    • Allows multiple metrics to be sent over a connection, separated by a newline character. Note, you should be careful to not exceed the maximum packet size (default 1024 bytes).
    • Config:
      • connection.udp.enabled
      • connection.udp.host
      • connection.udp.port
      • connection.udp.maxpacket (buffer size to read incoming packets)
  3. Unix Domain Socket

    • Allows multiple metrics to be sent over a connection, separated by a newline character.
    • Connection will remain open until closed by the client.
    • Config:
      • connection.unix.enabled
      • config: connection.unix.file (path to the sock file)

Configuration

All runtime options are specified in a YAML file. Please see example.config.yml for defaults. e.g.

go run statsgod.go -config=/etc/statsgod.yml

Stats Types

Statsgod provides support for the following metric types.

  1. Counters - these are cumulative values that calculate the sum of all metrics sent. A rate is also calculated to determine how many values were sent during the flush interval:

     my.counter:1|c
     my.counter:1|c
     my.counter:1|c
     # flush produces a count and a rate:
     [prefix].my.counter.[suffix] [timestamp] 3
     [prefix].my.counter.[suffix] [timestamp] [3/(duration of flush interval in seconds)]
    
  2. Gauges - these are a "last in" measurement which discards all previously sent values:

     my.gauge:1|g
     my.gauge:2|g
     my.gauge:3|g
     # flush only sends the last value:
     [prefix].my.gauge.[suffix] [timestamp] 3
    
  3. Timers - these are timed values measured in milliseconds. Statsgod provides several calculated values based on the sent metrics:

     my.timer:100|ms
     my.timer:200|ms
     my.timer:300|ms
     # flush produces several calculated fields:
     [prefix].my.timer.mean_value.[suffix] [timestamp] [mean]
     [prefix].my.timer.median_value.[suffix] [timestamp] [median]
     [prefix].my.timer.min_value.[suffix] [timestamp] [min]
     [prefix].my.timer.max_value.[suffix] [timestamp] [max]
     [prefix].my.timer.mean_90.[suffix] [timestamp] [mean in 90th percentile]
     [prefix].my.timer.upper_90.[suffix] [timestamp] [upper in 90th percentile]
     [prefix].my.timer.sum_90.[suffix] [timestamp] [sum in 90th percentile]
    
  4. Sets - these track the number of unique values sent during a flush interval:

     my.unique:1|s
     my.unique:2|s
     my.unique:2|s
     my.unique:1|s
     # flush produces a single value counting the unique metrics sent:
     [prefix].my.unique.[suffix] [timestamp] 2
    

Prefix/Suffix

Prefixes and suffixes noted above can be customized in the configuration. Metrics will render as [prefix].[type prefix].[metric namespace].[type suffix].[suffix]. You may also use empty strings in the config for any values you do not wish statsgod to prefix/suffix before relaying.

namespace:
	prefix: "stats"
	prefixes:
		counters: "counts"
		gauges: "gauges"
		rates: "rates"
		sets: "sets"
		timers: "timers"
	suffix: ""
	suffixes:
		counters: ""
		gauges: ""
		rates: ""
		sets: ""
		timers: ""

Authentication

Auth is handled via the statsgod.Auth interface. Currently there are two types of authentication: no-auth and token-auth, which are specified in the configuration file:

  1. No auth

     # config.yml
     service:
     	auth: "none"
    

Works as you might expect, all metrics strings are parsed without authentication or manipulation. This is the default behavior.

  1. Token auth

     # config.yml
     service:
     	auth: "token"
     	tokens:
     		"token-name": false
     		"32a3c4970093": true
    

"token" checks the configuration file for a valid auth token. The config file may specify as many tokens as needed in the service.tokens map. These are written as "string": bool where the string is the token and the bool is whether or not the token is valid. Please note that these are read into memory when the proces is started, so changes to the token map require a restart.

When sending metrics, the token is specified at the beginning of the metric namespace followed by a dot. For example, a metric "32a3c4970093.my.metric:123|g" would look in the config tokens for the string "32a3c4970093" and see if that is set to true. If valid, the process will strip the token from the namespace, only parsing and aggregating "my.metric:123|g". NOTE: since metric namespaces are dot-delimited, you cannot use a dot in a token.

Signal handling

The statsgod service is equipped to handle the following signals:

  1. Shut down the sockets and clean up before exiting.

    • SIGABRT
    • SIGINT
    • SIGTERM
    • SIGQUIT
  2. Reload* the configuration without restarting.

    • SIGHUP

* When reloading configuration, not all values will affect the current runtime. The following are only available on start up and not currently reloadable:

  • connection.*
  • relay.*
  • stats.percentile
  • debug.verbose
  • debug.profile

Development

Read more about the development process.

License

Except as otherwise noted this software is licensed under the Apache License, Version 2.0

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

More Repositories

1

blt

Acquia's toolset for automating Drupal 10 development, testing, and deployment.
PHP
435
star
2

reservoir

A back end for your front end: a content repository. Powered by Drupal 8, JSON API and OAuth2.
244
star
3

waterwheel.js

A generic JavaScript helper library to query and manipulate Drupal 8 via core REST and JSON API
232
star
4

lightning

Lightning was a base distribution for fast and feature-rich Drupal. Support ended on November 2, 2021 and it is no longer maintained.
PHP
188
star
5

drupal-spec-tool

A tool for specifying Drupal architecture details and generating automated tests for them.
Gherkin
146
star
6

lightning-project

A Composer-based installer for the Lightning distribution of Drupal 8. Support ended on November 2, 2021 and this project is no longer maintained.
133
star
7

cloud-hooks

Acquia Cloud hook scripts and documentation
112
star
8

drupal-create

Drupal Create - an iOS mobile app
Objective-C
85
star
9

http-hmac-spec

An HMAC message format for securing RESTful web APIs.
78
star
10

commons

Project is hosted on drupal.org/project/commons. Mirrored here for Travis CI-integration.
PHP
68
star
11

headless_lightning

A more opinionated flavor of Lightning for building decoupled applications. Support ended on November 2, 2021 and this project is no longer maintained.
PHP
58
star
12

http-hmac-php

An implementation of the HTTP HMAC Spec in PHP that integrates with popular libraries such as Symfony and Guzzle.
PHP
52
star
13

moonshot

Moonshot: Because releasing services shouldn't be a moonshot!
Ruby
50
star
14

http-hmac-postman

A postman prescript for connecting to HMAC protected API's
JavaScript
43
star
15

cli

Command-line interface for Acquia Cloud Platform products
PHP
42
star
16

mc-cs-plugin-custom-objects

Mautic plugin adding Custom Objects feature
PHP
39
star
17

pipelines-examples

Pipelines examples build files
37
star
18

acquia_cms

Low or no-code site building for Drupal within the Acquia Platform.
PHP
29
star
19

acf

Acquia Commerce Framework - a lightweight reference framework for headless e-commerce with Drupal.
JavaScript
29
star
20

reservoir-project

A Composer-based installer for the Reservoir distribution of Drupal 8.
27
star
21

acquia-sdk-php

The Acquia SDK for PHP allows developers to build applications on top of Acquia services.
PHP
27
star
22

orca

A tool for testing a company's software packages together in the context of a realistic, functioning, best practices Drupal build
PHP
26
star
23

aws-proxy

A reverse proxy to Amazon web services
Go
25
star
24

logstream

Stream logs from Acquia Cloud.
Ruby
24
star
25

drupal-recommended-project

Recommended Drupal project for use on Acquia Cloud
23
star
26

acsf-tools

Command line tools for working with Acquia Cloud Site Factory
PHP
20
star
27

next-acms

ACMS with fully or progressively decoupled front-end
TypeScript
19
star
28

coding-standards-php

PHP_CodeSniffer rules (sniffs) for Acquia coding standards
19
star
29

cohesion

Cohesion redefines what it takes to create beautiful websites. Cohesion is a low-code, Drupal add-on available for Acquia customers.
PHP
19
star
30

df

Demo Framework - mirrored at https://git.drupal.org/project/df.git
PHP
18
star
31

acquia-migrate-accelerate

An enhanced UI and assistant for Drupal migrations.
PHP
13
star
32

graphite-cassandra-plugin

A backend plugin for Graphite
Python
12
star
33

training

Training code resources for Acquia and its Partners
PHP
12
star
34

content-hub-php

A PHP Client library to consume the Acquia Content Hub API.
PHP
11
star
35

lightning-features

Decoupled components used by the Lightning distribution for Drupal. – Mirror of
PHP
11
star
36

club

Command Line Utility for BLT
PHP
11
star
37

df-project

A Composer-based installer for the Demo Framework Drupal distribution
10
star
38

acquia-cms-project

A Composer project template for building sites with Acquia CMS.
Shell
10
star
39

drupal-environment-detector

Provides common methods for detecting the current Acquia environment
PHP
10
star
40

http-hmac-go

An implementation of the HTTP HMAC Spec in Golang.
Go
10
star
41

fifo2kinesis

Continuously reads data from a named pipe and publishes it to a Kinesis stream.
Go
10
star
42

blt-project

Composer-based installer for a Drupal 8 project utilizing BLT (READ-ONLY SUBTREE SPLIT)
PHP
9
star
43

acquia-ra-composer

Example composer.json and repo architecture that works with Remote Administrations Acquia Automation.
8
star
44

http-hmac-java

An implementation of the HTTP HMAC Spec in Java.
Java
7
star
45

logstream-chrome

Allows you to see what logs are being generated in real time as you browse around a website that you maintain on Acquia Cloud
JavaScript
7
star
46

decoupled-drupal

Example decoupled Druapl architecture intended to work along with acquia/decoupled-js
PHP
6
star
47

lift-sdk-php

Acquia Lift SDK for PHP -- [Created 2016-08-17 by nickveenhof aka [email protected] via github.acquia.com]
PHP
6
star
48

acquia-cms-starterkit

Provide Starter kits for Acquia CMS.
PHP
6
star
49

decoupled-js

Example decoupled JavaScript application intended to work along with acquia/decoupled-drupal
JavaScript
6
star
50

mc-cs-plugin-slooce

Slooce SMS Transport for Mautic
PHP
5
star
51

microbus

Turn a Rubygem into a package for deployment, including native gems.
Ruby
4
star
52

lightning-dev

Development tools for working on the Lightning distribution and its components.
PHP
4
star
53

contenthub-console

A package providing Acquia ContentHub commands for the CommonConsole command line interface.
PHP
4
star
54

acquia_lift

Mirror of the drupal.org repository for Acquia Lift module
PHP
4
star
55

cohesion-theme

Acquia Cohesion minimal theme. A Cohesion enabled kickstarter theme for use within Cohesion projects.
Twig
4
star
56

commons3

A github mirror for travis-ci integration
PHP
4
star
57

drupal-recommended-settings

The composer plugin to add Acquia's drupal recommended settings in your drupal project.
PHP
4
star
58

drupal-canary-project

Canary / reference Drupal application
PHP
3
star
59

layout

A clone of http://drupal.org/project/layout intended for demonstration
JavaScript
3
star
60

ember-logging-service

A generic ember logging service
JavaScript
3
star
61

DevDesktopCommon

Roff
3
star
62

blt-phpcs

Acquia BLT PHPCS plugin
PHP
3
star
63

http-hmac-javascript

An implementation of the HTTP HMAC Spec in JavaScript. -- [Created 2016-01-12 by ynx aka [email protected] via github.acquia.com]
JavaScript
3
star
64

http-hmac-ruby

An implementation of the HTTP HMAC Spec in ruby.
Ruby
3
star
65

memcache-settings

Recommended default Memcache settings for use with Acquia Cloud hosting.
PHP
3
star
66

hmac-request

An implementation of the HTTP HMAC Spec in PHP that integrates with popular libraries such as Symfony and Guzzle.
PHP
3
star
67

acquia-search-proxy

A web service proxy for the Acquia Search service
PHP
3
star
68

blt-launcher

Provides a BLT executable for your global PATH
PHP
3
star
69

pingdom-api

A PHP library for interacting with the Pingdom REST API.
PHP
3
star
70

mc-cs-plugin-vtiger

Enables VTiger CRM integration
PHP
3
star
71

blt-drupal-test

BLT Plugin for Drupal core and contributed testing
PHP
3
star
72

acquia_commercemanager

The Acquia Commerce Manager Drupal module enables site builders to use tools and templates in Drupal to rapidly build commerce experiences. It connects Drupal sites to Acquia's Commerce Connector Service leveraging eCommerce systems as the source of truth for eCommerce data in these experiences.
PHP
3
star
73

flightpath-cli

Get insight into your Drupal 7 migration to Drupal 9 (or later) powered by Acquia Migrate Accelerate.
PHP
3
star
74

zendesk-api

A PHP library for interacting with the Zendesk REST API.
PHP
3
star
75

acquia-lift-gtm

Google Tag Manager (GTM) template which allows customers to easily install and use Lift on their site via GTM.
Smarty
3
star
76

contenthub-console-helpers

A set of helper classes and traits for tasks common to console components.
PHP
2
star
77

blt-vm

Acquia BLT plugin providing support for Drupal VM
PHP
2
star
78

acquia-lift-samples

This provides sample code and examples of how to use the Lift API and SDK. This is for reference only, and is not intended to be used on a production site.
PHP
2
star
79

blt-travis

Travis CI integration for Acquia BLT
Shell
2
star
80

AD-Pressflow

Acquia-Drupal on Pressflow
PHP
2
star
81

acsf-contenthub-console

A package providing Acquia Cloud Site Factory commands for the CommonConsole command line interface.
PHP
2
star
82

drupal-minimal-project

Minimal Drupal project for use on Acquia Cloud
2
star
83

blt-require-dev

This package is used as a wrapper to include BLT's dev requirements. READ-ONLY SUBTREE SPLIT
2
star
84

mc-cf-mega-openapi-php-sdk

PHP SDK for MEGA's OpenAPI
PHP
2
star
85

carbon-cassandra-plugin

A backend plugin for Megacarbon to talk with Cassandra
Python
2
star
86

apidoc-openapi-3

NodeJs (npm) tool to convert apidoc to OpenAPI 3.0 spec. (inspired by apidoc-swagger-3)
JavaScript
2
star
87

pipelines-ci-public

Public repo used for public forks behaviour testing by the pipelines team -- [Created 2017-01-31 by marcingy aka [email protected] via github.acquia.com]
2
star
88

acquia-search-service-client-php

A Client Library for the Acquia Search Service API
PHP
2
star
89

ember-http-hmac

An Ember addon utilizing the http-hmac-javascript library to automatically sign Ajax requests either standalone and through ember-data
JavaScript
2
star
90

gsuite-sso

Public hosting of our Google Suite SSO information. -- [Created 2018-02-02 by Zlender aka [email protected] via github.acquia.com]
2
star
91

nessus-client

Ruby library and simple cli tool for interacting with the Nessus 6 REST API https://cloud.tenable.com/api#/ -- [Created 2016-03-18 by pwolanin aka [email protected] via github.acquia.com]
Ruby
2
star
92

fluent-plugin-sumologic-cloud-syslog

Fluentd plugin to send logs to the Sumologic cloud syslog collectors
Ruby
2
star
93

pyplexus

Python based command line interface tool for plexus. -- [Created 2019-08-21 by jfarrell aka [email protected] via github.acquia.com]
1
star
94

d8

Drupal 8 hackathon work
PHP
1
star
95

blt-tugboat

Acquia BLT Tugboat integration
PHP
1
star
96

collectd-traefik

Collectd plugin to report metrics for Traefik
Python
1
star
97

acquia_claro

A clean, accessible, and powerful Drupal administration theme.
SCSS
1
star
98

acquia-sdk-php-cloud-db

[READ ONLY] Subtree split of the Acquia Cloud Database component
PHP
1
star
99

acquia_cms_page

Unstructured Page content type and related configuration for Acquia CMS.
PHP
1
star
100

acquia_cms_place

Place content type and related configuration for Acquia CMS.
PHP
1
star