大网数据广告活动
服务器运维问答

How can I make an alert by reply code in Datadog?

· 52CE 我爱测

Help is needed. I want to make alarms if the site gives 401 502 and so on, errors. On the server is an agent who sends different pieces in the datadog. There is such module http_check, and at it like as there is such function. ht…

问题原文

原帖链接 · James M · CC BY-SA 3.0

Help is needed. I want to make alarms if the site gives 401 502 and so on, errors. On the server is an agent who sends different pieces in the datadog. There is such module http_check, and at it like as there is such function.

http_response_status_code - A string or Python regular expression for an HTTP status code. This check will report DOWN for any status code that does not match. This defaults to 1xx, 2xx and 3xx HTTP status codes. For example: 401 or 4\d\d

Here is my http_check.yml

init_config:
instances:
  - name: My first service
    url: https://example.com
    collect_response_time: true
    timeout: 1
    skip_event: true
    http_response_status_code: 502
    check_certificate_expiration: true
    disable_ssl_validation: false
    days_warning: 7
    days_critical: 3
    tags:
      - url:example.com
      - env:production

Actually I try to shut down nginx and watch that it would send the status. I do not see anything. The task in general is to monitor the sites and alert if something has fallen off.

已采纳解答

原帖链接 · James M · CC BY-SA 3.0

Developers from datadog knows about this problem. To solve this task we need using a custom check like this - http_check.py

Then we need restart agent on host and imitate a error. In events datadog we will see http://example.com returned a status of 503 after 30.0 seconds

After that we can create alerts. This custom check send all codes, except 200.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2017-05-04)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。