Skip to content

Instantly share code, notes, and snippets.

import os
import boto3
from botocore.exceptions import ClientError
import requests
"""
http://boto3.readthedocs.io/en/latest/guide/configuration.html
Boto by default will look for configuration files in the following order:
@burnsie7
burnsie7 / java_apm_setup.md
Last active February 7, 2018 17:45
java apm setup

install agent v6

sudo DD_API_KEY=REDACTED bash -c "$(curl -L https://raw.githubusercontent.com/DataDog/datadog-agent/master/cmd/agent/install_script.sh)"

copy and edit trace-agent.conf

sudo cp /etc/datadog-agent/trace-agent.conf.example /etc/datadog-agent/trace-agent.conf

Add to config:

@burnsie7
burnsie7 / log_monitoring.md
Last active February 7, 2018 17:25
Log Monitoring Setup
@burnsie7
burnsie7 / log_access.md
Last active March 15, 2024 17:19
Granting access to logs for dd-agent (linux)

The datadog agent runs under the dd-agent user and dd-agent group. This prevents dd-agent accessing the logs in /var/log as they are only accessible by root (or a sudo admin).

In order to allow read only access for dd-agent only, create ACL's and modify logrotate to persist the permissions changes.

You can manually set the ACL with:

sudo setfacl -m g:dd-agent:rx /var/log/<application-name>

This will not persist as logrotate will not re-apply the ACL setting so for a more permanent solution you can add a rule to logrotate to reset the ACL. You will need to create a new file:

@burnsie7
burnsie7 / enable_logs.md
Last active February 17, 2018 03:01
Enabling Logs for Apache and AEM

Step 1: Enable log collection:

  1. Open /etc/datadog-agent/datadog.yaml in your editor of choice

  2. Set log_enabled: true

  3. Save and close /etc/datadog-agent/datadog.yaml

Step 2: Enable the apache integration and add the log file settings to apache.d/conf.yaml

@burnsie7
burnsie7 / multi_org_hosts_count.py
Created July 29, 2018 21:35
multi_org_hosts_count.py
import datetime
import time
import requests
import simplejson
from datadog import initialize, api
"""
This script gives a real time report on ec2 and Datadog agent host usage
from multiple organizations and reports them up to the 'main' parent account.
@burnsie7
burnsie7 / multi_line
Created August 10, 2018 21:52
Multiline Log and Test Config
mkdir /etc/datadog-agent/conf.d/logtest.d
touch /etc/datadog-agent/conf.d/logtest.d/conf.yaml
##Log section
logs:
- type: file
path: /home/vagrant/logout.log
service: cawa-server
source: cawa
@burnsie7
burnsie7 / basic_tag_update.py
Created August 13, 2018 18:26
Basic Tag Update
import json
import os
import requests
import pprint
from datadog import initialize, api
DD_API_KEY = os.getenv('DD_API_KEY', '<YOUR_API_KEY>')
DD_APP_KEY = os.getenv('DD_APP_KEY', '<YOUR_APP_KEY>')
@burnsie7
burnsie7 / ping_test.py
Last active September 19, 2018 19:51
PingCheck example
from checks import AgentCheck
import os
'''
This is for demostration purposes only and not recommended for production use.
Because of the nature of ping, it could result in a very long running check if there are excessive timeouts.
Long running checks could potentially result in other metrics and checks being skipped.
Example conf.yaml:
@burnsie7
burnsie7 / tracing_api_example.py
Last active August 23, 2018 23:17
tracing_api_example
import random
import time
import requests
import json
'''
Set the following options in /etc/datadog-agent/datadog.yaml:
# Trace Agent Specific Settings
apm_config: