Coder Social home page Coder Social logo

datadog / miscellany Goto Github PK

View Code? Open in Web Editor NEW
210.0 191.0 128.0 18.66 MB

Miscellaneous scripts and tools

License: BSD 3-Clause "New" or "Revised" License

Python 78.50% Shell 1.16% HCL 5.72% PowerShell 0.48% Dockerfile 0.93% Java 13.01% Makefile 0.21%

miscellany's Introduction

Miscellany

Intended to be a repository for miscellaneous scripts and tools from Datadog to be shared with the public.

Disclaimer

These projects are not a part of Datadog's subscription services and are provided for example purposes only. They are NOT guaranteed to be bug free and are not production quality. If you choose to use to adapt them for use in a production environment, you do so at your own risk.

Contributing

When adding a new script/tool, be sure to do the following:

  • Open a PR for review
  • Add a link and description to one of the tables above

We encourage creating a subfolder with a separate README that gives more details on the script/tool.

Scripts & Tools

These scripts and tools live in this repo, some scripts/tools have their own README in their subfolder with further explaintation and usage.

Name Language Function
count_hosts_by_tag Python This script will return the number of hosts with a given tag applied. If the tag is only the key of a key:value pair, all related values will be counted.
mute_monitors_with_tags Python This script mutes all monitors that are tagged with a set of monitor tags
linux_odfs_API Bash Script to capture linux open file descriptor metrics
query_freshness Python Report the "freshness" (how long ago a metric was submitted) of a metric. See this KB for more info
custom_check_shell Python/Bash Spins up a VM using vagrant that installs the Datadog agent on it with a simple custom check using shell
empty_dash Python Creates an empty dashboard for test purposes
get_all_boards Python Gets all boards for a given organization and print out their json. Useful for malformed boards created via the API
Remove old dashboards & monitors Python Will remove all old dashboards and monitors from an account belonging to the email as specified in the script's parameter.
get_hostname_agentversion Python Gets the version of the agent running for each host
s3_permissions Python Checks S3 bucket ACL permissions for read/write access and reports a metric to Datadog
uptime Python Custom check to track uptime. At the time that this check was written, it wasn't possible to view a monitor's uptime on a dashboard or via the API, or to view uptime with multiple decimals of precision, but please check if those features are available before using this check.
api_limits_as_custom_metrics Python Gets the Datadog API rate limits from the Datadog API and submits them as metrics
cross-org-metric-broker Python Takes metrics from one account (org) and posts them to another account (org)
csvmod Python Example script of grabbing a timeseries and dumping to a CSV
dashconverter Python Convert from screenboard to timeboard and vice versa
metric_usage_report Python Enter a list of metrics, and receive a report showing where the metrics are used in your account
dd_public_ip Bash Script to run from an AWS instance that will add a tag for the public ip
fullmetrics_dash Python Creates a dashboard for a given integration with all metrics being reported through that integration
hosts_with_aws_without_agent Python List of ec2 instances without the datadog-agent installed
merge_screenboards Python Takes two screenboards and combines them into one
migrate_dashboard Python Migrate a screenboard from one account (or org) to another
migrate_monitors Python Migrate monitors by query from one account (or org) to another
dash_to_json Python Convert Dashboard to JSON and Create Dashboard from JSON
import_screenboard Python Creates a new screenboard from json
export_screenboard Python Exports a single screenboard to a json file
base_scripts Python A collection of generic scripts that can be used as a starting point for creating your own custom scripts
remove_lingering_aws_host_tags Python This is a tool for removing AWS host-level tags from your infrastructure in Datadog. It is intended for users who have removed their EC2 instances from their AWS integration and if they no longer want to see AWS tags associated with the hosts that still run datadog-agents.
remove_single_tag_tmp Python Removes a single tag from a host
update_multiple_monitors_example Python example of how to update multiple monitors at once
create_monitor Python simple example of creating metric query monitor with thresholds
weatherExample Python Example script that submits the temperature and wind speed from the Wunderground API to Datadog as metrics
sql_redacted Python Submits a metric based on a SQL query
multi_org_create_users Python Creates multiple Datadog users across multiple Datadog Orgs
create_monitor_terraform Terraform Creates a monitor using Terraform
query hosts and create tags Python queries hosts api using pagination and creates new tags
get all groups in a monitor Python queries for all groups in a monitor and outputs a list of them
create a csv file with a list of log in handles Python creates a CSV file in the same directory as the script containing a list of all user log in handles
Powershell script to call JSON REST endpoint, pass those key-value pairs to DogstatsD Powershell A Powershell script which will call a given HTTP GET endpoint, and then submit the key-value pairs found in the resulting JSON body to DogsStatsD. Resource endpoint must be a non-nested JSON body ({"a":"1","b":"2"} -> custom metrics: a|1, b|2
Dogmover Python Migrate screenboards, timeboards and monitors from one organization to another (supports migrations between US>EU instances.)
Update Host Tags with Host Metadata (example) Python Queries the host API then creates tags based off of the gohai (or other) metadata.
Historic usage to CSV Python This script is meant to pull historical usage metrics and export them to CSV.
dd_aws_add_account.py Python script for creating aws integration
Send_filesystem_events Python This script uses inotify to send an event to the event stream when it detects a change in files or folders in a given directory.
create_users_and_emails_list.py Python script to get a list of user emails as csv
DD User Report (JSON) Python Generates various different user reports and pretty prints the json for further processing -- useful for large orgs with 100s or 1000s or users
Get All Public Dashboards Python Gets a full list (returned as JSON) of all dashboards that are public for a given organization
Get All Child Orgs Python Gets a full list (returned as JSON) of all child organizations for a given organization
PySNMP-MIB-Parser Python Converts a MIB file (in PySNMP format) to a yaml file that can be used by Datadog's SNMP agent integration
aws_hosts_without_agent.py Python Gets a list of hostnames and IPs for AWS hosts not running the agent
DD Example N/A Spins up a k8s cluster using Minikube with a simple app and database, showcasing the Datadog daemonset, has APM, Logs, and Metrics
get_active_users Python Collects a list of all active (ie. non disabled or pending) users in an organization to a csv file.
Packer Image Build + Terraform Deploy with AWS Secrets Manager and Datadog Agent N/A A guide that helps you to build an AMI with updates + Datadog Agent preinstalled using Packer, and deploy to AWS using Terraform while storing your Datadog API key in AWS Secrets Manager and using an IAM Instance Profile to retrive it at deployment time.
ddog Java 1.8+ A command line tool to troubleshoot connectivity issues for on-premises environments. Ping, SendMetric, SendLog and SendTrace are the available commands.
webhooks N/A A collection of Webhooks examples which use the Datadog API to perform different actions
Metrics Without Limits Optimiser Python Run through your custom metrics to apply a MWL allowlist of tags and aggregations to a metric based on whether the tags/aggregations have been actively queried on by dashboards, notebooks, monitors, and through the API in the past 30 day and only if the resulting volume of this new config is less than not using MWL.
Postgres Database Monitoring Setup Script Python A script to prepare Postgres databases for use with Database Monitoring. Discovers all databases on a databse host, creates datadog user, schema, and explain statments, then confirms the database was prepared properly.

Additional tools

These are some additional tools and scripts written by Datadog.

Name Language Function
csv_exporter Python Exports a given metric from Datadog as a csv

Getting started

For any Python code, you'll want to run:

pip install datadog

miscellany's People

Contributors

adulmovits avatar andrew-hollingworth avatar ayylam avatar burnsie7 avatar ckelner avatar danielcbright avatar darthnater007 avatar dblaw avatar eannamacken avatar foogaro avatar gsalami00 avatar ian28223 avatar joel295 avatar johananlai avatar johanmorganti avatar martiflex avatar mikelaning avatar misiupajor avatar nicholas-devlin avatar nxnarbais avatar pvfkb avatar rsheyd avatar ruthnaebeck avatar siobhanpmahoney avatar spottsdd avatar szaporta avatar teeebs avatar utxonly avatar zhengshizhao avatar zstriker19 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

miscellany's Issues

dashconverter.py - why must this exist as a python script?

Hello DataDog team,

First, I want to thank the creators and maintainers of https://github.com/DataDog/Miscellany/blob/master/dashconverter.py - it was extremely useful and saved me a ton of time yesterday. It did leave me wondering why, given that converting a timeboard to a screenboard programmatically is possible, there isn't a button to do this in the web UI, so I thought I'd ask.

I see that the script was only added in June, so maybe it's a relatively new feature and just hasn't made it up to the top of the roadmap yet, or maybe delivering a web UI that handles the edge cases I didn't encounter using the python script adds a bunch of complexity, just curious.

Dogmover - Max retries exceeded with url: /api/v1/synthetics/tests

Hi,
I have a problem pulling my synthetics API tests with dogmover.
It crashes after pulling about 64 (sometimes a bit less, 62 or 63) synthetics API tests.
I tried to add a timeout of 60 seconds in the request, but no effect.

Here is the code :

def pull_synthetics_api_tests(options, tag):
path = False
count = 0
tags = [] if not tag else tag

r = requests.get('{}api/v1/synthetics/tests?api_key={}&application_key={}'.format(options["api_host"], options["api_key"], options["app_key"]))
synthetics = r.json()
for synthetic in synthetics["tests"]:
    if synthetic["type"] == "api":
        all_tags_found="true"
        for tag in tags:
            if not tag in synthetic["tags"]:
                all_tags_found="false"
                break

        if all_tags_found == "true":
            count = count + 1
            print("Pulling: {} and writing to file: {}".format(synthetic["name"].encode('utf8'), path))
            print ("count={}".format(count))
            json_data = requests.get('{}api/v1/synthetics/tests/{}?api_key={}&application_key={}'.format(
                    options["api_host"],
                    synthetic["public_id"],
                    options["api_key"],
                    options["app_key"]
                ), timeout=60).json()
            path = _json_to_file('synthetics_api_tests', synthetic["public_id"], json_data)
print("Retrieved '{}' synthetic tests.".format(count))

And the log & stack trace :

python ./dogmover.py pull synthetics_api_tests --tag stream:SOP

Pulling: [SOP] [OPUS] [ERROR] [PROD] [LMFR] TAXONOMY <!channel> and writing to file: False
count=1
Pulling: [SOP] [OPUS] [ERROR] [PROD] [LMFR] CATEGORY <!channel> and writing to file: ./synthetics_api_tests/9pq-ak5-fdr.json
count=2
[...]
Pulling: [SOP] [OPUS] [ERROR] [DEV] [LMFR] SEARCH WRITES RUNNING and writing to file: ./synthetics_api_tests/iu3-sbk-ic9.json
count=64
Traceback (most recent call last):
File "./dogmover.py", line 522, in
pull_synthetics_api_tests(_init_options("pull"), arguments["--tag"])
File "./dogmover.py", line 170, in pull_synthetics_api_tests
), timeout=60).json()
File "/usr/local/lib/python2.7/dist-packages/requests/api.py", line 76, in get
return request('get', url, params=params, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/api.py", line 61, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 542, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 655, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/adapters.py", line 516, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='api.datadoghq.eu', port=443): Max retries exceeded with url: /api/v1/synthetics/tests/6tq-wxw-fup?api_key=xxxx&application_key=xxxxx (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f9091bdde10>: Failed to establish a new connection: [Errno 101] Network is unreachable',))

Do you have any idea ?
Is there a way to set up the connection pool with more connections ? or to re-use always the same ? or to free connections after each request ?

use Dogmover to pull Monitors fails

Running into an issue trying to pull monitors

$ python3 dogmover.py pull monitors
Traceback (most recent call last):
  File "dogmover.py", line 449, in <module>
    pull_monitors(arguments["--tag"])
  File "dogmover.py", line 99, in pull_monitors
    if monitor["type"] == "synthetics alert":
TypeError: string indices must be integers

Rewrite not returning empty result set

I'm not sure exactly where the problem lies, but when I used the rewritten version of this tool from three weeks ago, my queries don't return any result set.

➜  metric_usage_report git:(master) ✗ more results/report.csv
Metric,Source,Dashboard Title,Dashboard Link,Author,Widget Title, Widget Link

The stable version that I had used previously, which was last revised in March, operates correctly.

Issue when running the script

Hello,

I keep getting this message each time I call the script :
If you have any warning above about outdated widget types, you should not delete the original dashboard. Follow the described procedure to properly convert the dashboard.

Do you want to delete the dash (Y/n): n
No further action needed
Traceback (most recent call last):
File "dashconverter.py", line 257, in
converter().main(args.dashboard_id)
File "dashconverter.py", line 254, in main
print ("Your new Screenboard is available at: http://app.datadoghq.com/screen/" + str(output['id']))
KeyError: 'id'

Can you please give me a hint at least where is the issue?

Python3 Support

As python2 has been EOL since Jan 1st 2020 I'm curious if there is any movement to migrating this project to python3?

Error when running the command

When I run the script i get the below error.
Reference ## is not in your timeboards
Reference ## is not in your screenboards
Traceback (most recent call last):
File "dashconverter.py", line 268, in
converter().main(args.dashboard_id)
File "dashconverter.py", line 260, in main
graphs = cls.widget_transform()
File "dashconverter.py", line 119, in widget_transform
return cls.board['dash']['graphs']
KeyError: 'dash'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.