Skip to content

Instantly share code, notes, and snippets.

@alq666
alq666 / dog.r
Created January 17, 2014 04:14
Query Datadog from R
query_to_df <- function(api_key, application_key, query, from_t, to_t) {
res <- getForm('https://app.datadoghq.com/api/v1/query', api_key=api_key, application_key=application_key, from=from_t, to=to_t, query=query)
parsed <- fromJSON(res)
series <- parsed[['series']]
timeseries <- series[[1]]
pointlist <- timeseries[['pointlist']]
timestamps <- to_epoch(sapply(pointlist, '[', 1))
values <- sapply(pointlist, '[', 2)
return(data.frame(timestamps, values))
}
Creating log file /Users/alq/.datadog-agent/ddagent-install.log.....Done
Operating System: Darwin
Setting up virtual environment..... % Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 26 112k 26 30857 0 0 155k 0 --:--:-- --:--:-- --:--:-- 155k 100 112k 100 112k 0 0 441k 0 --:--:-- --:--:-- --:--:-- 440k
New python executable in /Users/alq/.datadog-agent/venv/bin/python
Installing setuptools...............................done.
Installing pip.....................done.
Done
Installing tornado 2.4.1 using pip.....Wheel installs require setuptools >= 0.8 for dist-info support.
#!/usr/bin/env python
"""
Nagios plugin to check PostgreSQL 9 streaming replication lag.
Requires psycopg2 and nagiosplugin (both installable with pip/easy_install).
MIT licensed:
Copyright (c) 2010 Jacob Kaplan-Moss. All rights reserved.
@alq666
alq666 / pg-df.sql
Created November 16, 2013 18:11
Compute relation sizes
SELECT nspname,
relname,
pg_size_pretty(pg_relation_size(C.oid)) AS "size"
FROM pg_class C
LEFT JOIN pg_namespace N
ON (N.oid = C.relnamespace)
WHERE nspname NOT IN ('pg_catalog', 'information_schema')
ORDER BY pg_relation_size(C.oid) DESC
LIMIT 40;
@alq666
alq666 / little.json
Created October 31, 2013 03:37
Illustrating Little's law with ELB statistics in Datadog
{
"events": [],
"requests": [
{
"q": "aws.elb.latency{host:elb_name}*sum:aws.elb.request_count{host:elb_name}"
}
],
"viz": "timeseries"
}
@alq666
alq666 / README.md
Created October 26, 2013 02:10 — forked from alekstorm/README.md

Installation

To install, place datadog.py in your callback plugins directory. If you don't yet have one, run:

mkdir -p plugins/callback

Then place the following in your ansible.cfg file:

[defaults]

callback_plugins = ./plugins/callback

@alq666
alq666 / .toprc
Created October 22, 2013 22:23
Top configuration
RCfile for "top with windows" # shameless braggin'
Id:a, Mode_altscr=0, Mode_irixps=1, Delay_time=3.000, Curwin=0
Def fieldscur=AEHIOQTWKNMbcdfgjplrsuvyzX
winflags=64441, sortindx=10, maxtasks=0
summclr=1, msgsclr=1, headclr=3, taskclr=1
Job fieldscur=ABcefgjlrstuvyzMKNHIWOPQDX
winflags=62777, sortindx=0, maxtasks=0
summclr=6, msgsclr=6, headclr=7, taskclr=6
Mem fieldscur=ANOPQRSTUVbcdefgjlmyzWHIKX
winflags=62777, sortindx=13, maxtasks=0
{% set pkgrepo = {
'Debian': {
"managed": True,
"humanname": "Datadog Agent",
"name": "deb http://apt.datadoghq.com/ unstable main",
"keyserver": "keyserver.ubuntu.com",
"keyid": "C7A7DA52",
"file": "/etc/apt/sources.list.d/datadog.list"
},
'RedHat': {

The Challenge

  1. Sign up for Datadog, get the agent reporting metrics from your local machine. Bonus question- what is the agent?

  2. Submit an event via the API.

  3. Get an event to appear in your email inbox (the email address you signed up for the account with)

@alq666
alq666 / common-role.rb
Last active December 24, 2015 03:29
An example of datadog's chef recipe for nginx
default_overrides({
:datadog => {
:api_key => "...",
# ...
}
})