# dt - Dynatrace Python API Client
**dt** is a Python client for the [Dynatrace Rest API].
It focuses on ease of use and nice type hints, perfect to explore the API and create quick scripts
[Dynatrace Rest API]: https://www.dynatrace.com/support/help/dynatrace-api
## Install
```bash
$ pip install dt
```
## Simple Demo
```python
from dynatrace import Dynatrace
from dynatrace import TOO_MANY_REQUESTS_WAIT
from dynatrace.environment_v2.tokens_api import SCOPE_METRICS_READ, SCOPE_METRICS_INGEST
from datetime import datetime, timedelta
# Create a Dynatrace client
dt = Dynatrace("environment_url", "api_token")
# Create a client that handles too many requests (429)
# dt = Dynatrace("environment_url", "api_token", too_many_requests_strategy=TOO_MANY_REQUESTS_WAIT )
# Create a client that automatically retries on errors, up to 5 times, with a 1 second delay between retries
# dt = Dynatrace("environment_url", "api_token", retries=5, retry_delay_ms=1000 )
# Get all hosts and some properties
for entity in dt.entities.list('type("HOST")', fields="properties.memoryTotal,properties.monitoringMode"):
print(entity.entity_id, entity.display_name, entity.properties)
# Get idle CPU for all hosts
for metric in dt.metrics.query("builtin:host.cpu.idle", resolution="Inf"):
print(metric)
# Print dimensions, timestamp and values for the AWS Billing Metric
for metric in dt.metrics.query("ext:cloud.aws.billing.estimatedChargesByRegionCurrency"):
for data in metric.data:
for timestamp, value in zip(data.timestamps, data.values):
print(data.dimensions, timestamp, value)
# Get all ActiveGates
for ag in dt.activegates.list():
print(ag)
# Get metric descriptions for all host metrics
for m in dt.metrics.list("builtin:host.*"):
print(m)
# Delete endpoints that contain the word test
for plugin in dt.plugins.list():
# This could also be dt.get_endpoints(plugin.id)
for endpoint in plugin.endpoints:
if "test" in endpoint.name:
endpoint.delete(plugin.id)
# Prints dashboard ID, owner and number of tiles
for dashboard in dt.dashboards.list():
full_dashboard = dashboard.get_full_dashboard()
print(full_dashboard.id, dashboard.owner, len(full_dashboard.tiles))
# Delete API Tokens that haven't been used for more than 3 months
for token in dt.tokens.list(fields="+lastUsedDate,+scopes"):
if token.last_used_date and token.last_used_date < datetime.now() - timedelta(days=90):
print(f"Deleting token! {token}, last used date: {token.last_used_date}")
# Create an API Token that can read and ingest metrics
new_token = dt.tokens.create("metrics_token", scopes=[SCOPE_METRICS_READ, SCOPE_METRICS_INGEST])
print(new_token.token)
```
## Implementation Progress
### Environment API V2
API | Level | Access |
:------------- | :-------------: | :----- |
Access Tokens - API tokens | :heavy_check_mark: | `dt.tokens` |
Access tokens - Tenant tokens | :heavy_check_mark: | `dt.tenant_tokens` |
ActiveGates | :heavy_check_mark: | `dt.activegates` |
ActiveGates - Auto-update configuration | :heavy_check_mark: | `dt.activegates_autoupdate_configuration` |
ActiveGates - Auto-update jobs | :heavy_check_mark: | `dt.activegates_autoupdate_jobs` |
Audit Logs | :heavy_check_mark: | `dt.audit_logs` |
Extensions 2.0 | :heavy_check_mark: | `dt.extensions_v2` |
Logs | :warning: | `dt.logs` |
Metrics | :heavy_check_mark: | `dt.metrics` |
Monitored entities | :warning: | `dt.entities` |
Monitored entities - Custom tags | :heavy_check_mark: | `dt.custom_tags` |
Network zones | :x: | |
Problems | :heavy_check_mark: | `dt.problems` |
Security problems | :x: | |
Service-level objectives | :heavy_check_mark: | `dt.slos` |
### Environment API V1
API | Level | Access |
:------------- | :-------------: | :----- |
Anonymization | :x: | |
Cluster time | :heavy_check_mark: | `dt.time` |
Cluster version | :x: | |
Deployment | :heavy_check_mark: | `dt.deployment` |
Events | :warning: | `dt.events` |
JavaScript tag management | :x: | |
Log monitoring - Custom devices | :x: | |
Log monitoring - Hosts | :x: | |
Log monitoring - Process groups | :x: | |
Maintenance window | :x: | |
OneAgent on a host | :x: | |
Problem | :x: | |
Synthetic - Locations and nodes | :x: | |
Synthetic - Monitors | :warning: | `dt.synthetic_monitors` |
Synthetic - Third party | :heavy_check_mark: | `dt.third_part_synthetic_tests` |
Threshold | :x: | |
Timeseries | :warning: | `dt.timeseries` |
Tokens | :x: | |
Topology & Smartscape - Application | :x: | |
Topology & Smartscape - Custom device | :warning: | `dt.custom_devices` |
Topology & Smartscape - Host | :warning: | |
Topology & Smartscape - Process | :x: | |
Topology & Smartscape - Process group | :x: | |
Topology & Smartscape - Service | :x: | |
User sessions | :x: | |
### Configuration API V1
API | Level | Access |
:------------- | :-------------: | :----- |
Alerting Profiles | :x: | |
Anomaly detection - Applications | :x: | |
Anomaly detection - AWS
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
共86个文件
py:77个
txt:4个
pkg-info:2个
资源分类:Python库 所属语言:Python 资源全名:dt-1.1.45.tar.gz 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
资源推荐
资源详情
资源评论
收起资源包目录
dt-1.1.45.tar.gz (86个子文件)
dt-1.1.45
PKG-INFO 954B
dynatrace
pagination.py 4KB
environment_v2
logs.py 1KB
extensions.py 11KB
events.py 9KB
metrics.py 9KB
tokens_api.py 8KB
activegates_autoupdate_configuration.py 3KB
service_level_objectives.py 12KB
activegates_autoupdate_jobs.py 5KB
activegates.py 5KB
monitored_entities.py 14KB
__init__.py 0B
problems.py 14KB
custom_tags.py 5KB
audit_logs.py 3KB
schemas.py 2KB
networkzones.py 4KB
tokens_tenant.py 2KB
main.py 7KB
environment_v1
smartscape_hosts.py 5KB
synthetic_monitors.py 6KB
custom_device.py 8KB
deployment.py 19KB
oneagents.py 6KB
__init__.py 0B
timeseries.py 4KB
cluster_time.py 899B
synthetic_third_party.py 11KB
event.py 5KB
utils.py 2KB
dynatrace_object.py 1KB
http_client.py 5KB
configuration_v1
oneagent_environment_wide_configuration.py 4KB
endpoint.py 965B
extensions.py 12KB
metric_events.py 6KB
anomaly_detection_process_groups.py 4KB
oneagent_in_a_hostgroup.py 5KB
dashboard.py 4KB
oneagent_on_a_host.py 8KB
__init__.py 0B
notifications.py 13KB
auto_tags.py 18KB
tile.py 1KB
schemas.py 4KB
alerting_profiles.py 16KB
maintenance_windows.py 8KB
plugins.py 3KB
__init__.py 94B
test
environment_v2
test_tokens_tenant.py 638B
test_customtags.py 2KB
test_networkzones.py 1KB
test_entities.py 7KB
test_events_v2.py 3KB
test_problems.py 6KB
test_activegate_autoupdate_jobs.py 2KB
test_extensions.py 2KB
__init__.py 0B
test_activegate_autoupdate_configuration.py 636B
test_service_level_objectives.py 2KB
test_metrics.py 5KB
test_audit_logs.py 2KB
environment_v1
test_synthetic_monitors.py 2KB
test_deployment.py 4KB
__init__.py 0B
test_smartscape_hosts.py 1KB
conftest.py 1KB
configuration_v1
test_auto_tags.py 2KB
test_notifications.py 2KB
test_oneagent_on_a_host.py 4KB
test_extensions.py 4KB
__init__.py 0B
test_oneagent_environment_wide_configuration.py 2KB
test_alerting_profiles.py 5KB
test_oneagent_in_a_hostgroup.py 2KB
__init__.py 0B
LICENSE 11KB
setup.cfg 38B
setup.py 1KB
README.md 14KB
dt.egg-info
PKG-INFO 954B
requires.txt 15B
SOURCES.txt 3KB
top_level.txt 15B
dependency_links.txt 1B
共 86 条
- 1
资源评论
挣扎的蓝藻
- 粉丝: 13w+
- 资源: 15万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功