15 Feb 2023 dynatrace使用tips

2023-10-17 10:21:21 浏览数 (1)

  • 定义alert时可用的特殊变量

  • {alert_condition}:表示alert的条件,大于(above)或者小于(below)
  • {baseline}:基线的违反值
  • {dims}:指标的所有维度数据,比如dt.entity.custom_device.name和dt.entity.custom_device
  • {entityname}:受影响的服务名称
  • {metricname}:指标名称
  • {missing_data_samples}:缺失的样本数,启用缺失数据alert时生效
  • {severity}:指标当前的值
  • {threshold}:设置的告警阈值

  • 在dynakube中启用azure监控
代码语言:javascript复制
  spec:
    activeGate:
      capabilities:
      - routing
      - kubernetes-monitoring
      - dynatrace-api
      customProperties:
        value: |
          [azure_monitoring]
          azure_monitoring_enabled = true
  • 调用api创建alert
代码语言:javascript复制
curl 'https://test.live.dynatrace.com/api/v2/settings/objects' 
-X POST 
-H 'Accept: application/json; charset=utf-8' 
-H 'Content-Type: application/json; charset=utf-8' 
-H 'Authorization: Api-Token ACCESS_TOKEN' 
-d $'[{"schemaId":"builtin:anomaly-detection.metric-events","scope":"tenant","value":{"enabled":true,"summary":"Azure DB for PostgreSQL (Flexible) active connections [Azure]","queryDefinition":{"type":"METRIC_KEY","metricKey":"ext:cloud.azure.microsoft_dbforpostgresql.flexibleservers.active_connections","aggregation":"AVG","queryOffset":null,"entityFilter":{"dimensionKey":"dt.entity.custom_device","conditions":[]},"dimensionFilter":[]},"modelProperties":{"type":"STATIC_THRESHOLD","threshold":688,"alertOnNoData":false,"alertCondition":"ABOVE","violatingSamples":3,"samples":5,"dealertingSamples":5},"eventTemplate":{"title":"Azure DB for PostgreSQL (Flexible) has too many connections (> 80%).","description":"Found {severity} active connections in Azure DB for PostgreSQL (Flexible) {entityname}.","eventType":"CUSTOM_ALERT","davisMerge":true,"metadata":[]},"eventEntityDimensionKey":"dt.entity.custom_device","legacyId":null}}]'
  • 获取所有alert
代码语言:javascript复制
curl 'https://test.live.dynatrace.com/api/v2/settings/objects?schemaIds=builtin:anomaly-detection.metric-events&scopes=tenant&fields=objectId,value' -X GET -H 'Accept: application/json; charset=utf-8' -H 'Content-Type: application/json; charset=utf-8' -H 'Authorization: Api-Token ACCESS_TOKEN' | jq '. > all-alerts.json
  • 获取某个实体的tag
代码语言:javascript复制
curl -L -X GET 'https://test.live.dynatrace.com/api/v2/tags?entitySelector=type("CUSTOM_DEVICE"),entityName.startsWith("psql-")' -H 'Authorization: Api-Token TOKEN'
  • 给某个实体加tag
代码语言:javascript复制
curl -L -X POST 'https://test.live.dynatrace.com/api/v2/tags?entitySelector=type("CUSTOM_DEVICE"),entityName.startsWith("psql")' 
-H 'Authorization: Api-Token TOKEN' 
-H 'Content-Type: application/json' 
--data-raw '{
  "tags": [
  {
    "key": "testing-tag"
  }
  ]
}'

:) 未完待续……

LEo at 00:12

0 人点赞