Collection of all Datadog Public endpoints
Actively maintained. Last release 7 weeks ago, commits in 26 of the last 26 weeks. A safe choice.
pip install datadog-api-clientdatadog-api-client-python
This repository contains the autogenerated Python client for the Datadog API. The client code, feature files, and test data are generated from Datadog's public OpenAPI specifications by internal tooling.
We welcome contributions that expand or improve the client's capabilities. As part of the pull request review process, Datadog's internal tooling may regenerate the affected code, feature files, and test data based on the proposed changes.
Requirements
Building and using the API client library requires Python 3.10+.
Installation
To install the API client library, simply execute:
pip install datadog-api-client
Getting Started
Please follow the installation instruction and execute the following Python code:
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v1.api.monitors_api import MonitorsApi
from datadog_api_client.v1.model.monitor import Monitor
from datadog_api_client.v1.model.monitor_type import MonitorType
body = Monitor(
name="example",
type=MonitorType("log alert"),
query='logs("service:foo AND type:error").index("main").rollup("count").by("source").last("5m") > 2',
message="some message Notify: @hipchat-channel",
tags=["test:example", "env:ci"],
priority=3,
)
configuration = Configuration()
with ApiClient(configuration) as api_client:
api_instance = MonitorsApi(api_client)
response = api_instance.create_monitor(body=body)
print(response)
Authentication
By default the library will use the DD_API_KEY and DD_APP_KEY environment variables to authenticate against the Datadog API.
To provide your own set of credentials, you need to set some keys on the configuration:
configuration.api_key["apiKeyAuth"] = "<API KEY>"
configuration.api_key["appKeyAuth"] = "<APPLICATION KEY>"
Unstable Endpoints
This client includes access to Datadog API endpoints while they are in an unstable state and may undergo breaking changes. An extra configuration step is required to enable these endpoints:
configuration.unstable_operations["<OperationName>"] = True
where <OperationName> is the name of the method used to interact with that endpoint. For example: list_log_indexes, or