How to use the datadog.initialize function in datadog

To help you get started, we’ve selected a few datadog examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DataDog / datadogpy / tests / unit / api / test_api.py View on Github external
def test_return_raw_response(self):
        # Test default initialization sets return_raw_response to False
        initialize()
        assert not api._return_raw_response
        # Assert that we can set this to True
        initialize(return_raw_response=True)
        assert api._return_raw_response
        # Assert we get multiple fields back when set to True
        initialize(api_key="aaaaaaaaaa", app_key="123456", return_raw_response=True)
        data, raw = api.Monitor.get_all()
github DataDog / documentation / content / api / tags / code_snippets / api-tags-add.py View on Github external
from datadog import initialize, api

options = {
    'api_key': '',
    'app_key': ''
}

initialize(**options)
hosts = api.Hosts.search(q='hosts:')
api.Tag.create(hosts['results']['hosts'][0], tags=["role:codesample"])
github dimagi / commcare-cloud / src / commcare_cloud / environment / main.py View on Github external
def record_vault_loaded_event(self, secrets):
        if (
            self.should_send_vault_loaded_event and
            secrets.get('DATADOG_API_KEY') and
            self.public_vars.get('DATADOG_ENABLED')
        ):
            self.should_send_vault_loaded_event = False
            datadog.initialize(
                api_key=secrets['DATADOG_API_KEY'],
                app_key=secrets['DATADOG_APP_KEY'],
            )
            datadog.api.Event.create(
                title="commcare-cloud vault loaded",
                text=' '.join([shlex_quote(arg) for arg in sys.argv]),
                tags=["environment:{}".format(self.name)],
                source_type_name='ansible',
            )
github DataDog / documentation / ja / code_snippets / api-host-mute.py View on Github external
from datadog import initialize, api

options = {
    'api_key': '',
    'app_key': ''
}

initialize(**options)

# Find a host to mute
hosts = api.Infrastructure.search(q='hosts:')
# Mute a host
api.Host.mute(hosts['results']['hosts'][0])
github DataDog / Miscellany / csvmod.py View on Github external
def __init__(self, api_key, app_key):
        #To strongly suggest that outside objects don't access a property or method
        #prefix it with a double underscore, this will perform name mangling on the
        #attribute in question. 
        self.__api_key = api_key
        self.__app_key = app_key

        myKeys = {
            'api_key':self.__api_key,
            'app_key':self.__app_key
            }

        initialize(**myKeys) #call the API's initialize function that unpacks the myKeys dict, and uses those key-value pairs as parameters
github DataDog / datadogpy / datadog / dogshell / __init__.py View on Github external
EventClient.setup_parser(subparsers)
    MonitorClient.setup_parser(subparsers)
    TimeboardClient.setup_parser(subparsers)
    DashboardClient.setup_parser(subparsers)
    ScreenboardClient.setup_parser(subparsers)
    DashboardListClient.setup_parser(subparsers)
    HostClient.setup_parser(subparsers)
    DowntimeClient.setup_parser(subparsers)
    ServiceCheckClient.setup_parser(subparsers)
    ServiceLevelObjectiveClient.setup_parser(subparsers)

    args = parser.parse_args()
    config.load(args.config, args.api_key, args.app_key)

    # Initialize datadog.api package
    initialize(**config)

    args.func(args)
github spinnaker / spinnaker-monitoring / spinnaker-monitoring-daemon / spinnaker-monitoring / datadog_service.py View on Github external
def api(self):
    """The Datadog API stub for interacting with Datadog."""
    if self.__api is None:
      datadog.initialize(api_key=self.__arguments['api_key'],
                         app_key=self.__arguments['app_key'],
                         host_name=self.__arguments['host'])
      self.__api = datadog.api
    return self.__api
github DataDog / documentation / content / api / metrics / code_snippets / api-metrics-post.py View on Github external
from datadog import initialize, api
import time

options = {
    'api_key': '9775a026f1ca7d1c6c5af9d94d9595a4',
    'app_key': '87ce4a24b5553d2e482ea8a8500e71b8ad4554ff'
}

initialize(**options)

now = time.time()
future_10s = now + 10

# Submit a single point with a timestamp of `now`
api.Metric.send(metric='page.views', points=1000)

# Submit a point with a timestamp (must be ~current)
api.Metric.send(metric='my.pair', points=(now, 15))

# Submit multiple points.
api.Metric.send(
    metric='my.series',
    points=[
        (now, 15),
        (future_10s, 16)
github saltstack / salt / salt / modules / datadog_api.py View on Github external
def _initialize_connection(api_key, app_key):
    '''
    Initialize Datadog connection
    '''
    if api_key is None:
        raise SaltInvocationError('api_key must be specified')
    if app_key is None:
        raise SaltInvocationError('app_key must be specified')
    options = {
        'api_key': api_key,
        'app_key': app_key
    }
    datadog.initialize(**options)