From bbe194d9e5d3a5c2c4512ffeba47592697f3835f Mon Sep 17 00:00:00 2001 From: Hippolyte HENRY Date: Sat, 17 Mar 2018 17:15:09 +0100 Subject: [PATCH] [network checks] Kill `skip_event` option (#1054) --- .../datadog_checks/dns_check/dns_check.py | 2 - http_check/CHANGELOG.md | 4 +- http_check/README.md | 7 +- http_check/conf.yaml.example | 6 -- .../datadog_checks/http_check/__init__.py | 2 +- .../datadog_checks/http_check/http_check.py | 79 +------------------ http_check/manifest.json | 2 +- snmp/datadog_checks/snmp/snmp.py | 1 - tcp_check/CHANGELOG.md | 7 ++ tcp_check/README.md | 4 - tcp_check/conf.yaml.example | 6 -- .../datadog_checks/tcp_check/__init__.py | 2 +- .../datadog_checks/tcp_check/tcp_check.py | 58 +------------- tcp_check/manifest.json | 2 +- tcp_check/test/test_tcp_check.py | 41 +--------- 15 files changed, 21 insertions(+), 202 deletions(-) diff --git a/dns_check/datadog_checks/dns_check/dns_check.py b/dns_check/datadog_checks/dns_check/dns_check.py index 6b0be98e85aaa..dbf5580a632e6 100644 --- a/dns_check/datadog_checks/dns_check/dns_check.py +++ b/dns_check/datadog_checks/dns_check/dns_check.py @@ -128,8 +128,6 @@ def _get_tags(self, instance): def report_as_service_check(self, sc_name, status, instance, msg=None): tags = self._get_tags(instance) - instance['skip_event'] = True - if status == Status.UP: msg = None diff --git a/http_check/CHANGELOG.md b/http_check/CHANGELOG.md index 8c47d2cb7e6ec..f3b294e13dfec 100644 --- a/http_check/CHANGELOG.md +++ b/http_check/CHANGELOG.md @@ -1,6 +1,6 @@ # CHANGELOG - http_check -1.4.1 / Unreleased +2.0.0 / Unreleased ================== ### Changes @@ -8,6 +8,7 @@ * [BUGFIX] Make import of default certificate file relative rather than absolute Fixes loading problem on Windows, and/or allows check to be installed in other location +* [DEPRECATION] Remove the `skip_event` option from the check. See [#1054][] 1.4.0 / 2018-02-13 ================== @@ -78,3 +79,4 @@ [#758]: https://github.com/DataDog/integrations-core/issues/758 [@xkrt]: https://github.com/xkrt [#905]:https://github.com/DataDog/integrations-core/pull/905 +[#1054]:https://github.com/DataDog/integrations-core/pull/1054 diff --git a/http_check/README.md b/http_check/README.md index 42700acde6c7c..0c1f0bbdc08c3 100644 --- a/http_check/README.md +++ b/http_check/README.md @@ -25,10 +25,8 @@ instances: # days_warning: 28 # default 14 # days_critical: 14 # default 7 # timeout: 3 # in seconds. Default is 1. - skip_event: true # Default is false, i.e. emit events instead of service checks. Recommend to set to true. - name: Example website (staging) url: http://staging.example.com/ - skip_event: true ``` The HTTP check has more configuration options than many checks — many more than are shown above. Most options are opt-in, e.g. the Agent will not check SSL validation unless you configure the requisite options. Notably, the Agent _will_ check for soon-to-expire SSL certificates by default. @@ -54,7 +52,6 @@ See the [sample http_check.yaml](https://github.com/DataDog/integrations-core/bl | `check_certificate_expiration` | When `check_certificate_expiration` is enabled, the service check will check the expiration date of the SSL certificate. Note that this will cause the SSL certificate to be validated, regardless of the value of the `disable_ssl_validation` setting. | | `days_warning` & `days_critical` | When `check_certificate_expiration` is enabled, these settings will raise a warning or critical alert when the SSL certificate is within the specified number of days from expiration. | | `headers` | This parameter allows you to send additional headers with the request. Please see the [example YAML file](https://github.com/DataDog/integrations-core/blob/master/http_check/conf.yaml.example) for additional information and caveats. | -| `skip_event` | When enabled, the check will not create an event. This is useful to avoid duplicates with a server side service check. This defaults to `false`. | | `skip_proxy` | If set, the check will bypass proxy settings and attempt to reach the check url directly. This defaults to `false`. | | `allow_redirects` | This setting allows the service check to follow HTTP redirects and defaults to `true`. | `tags` | A list of arbitrary tags that will be associated with the check. For more information about tags, please see our [Guide to tagging](/guides/tagging/) and blog post, [The power of tagged metrics](https://www.datadoghq.com/blog/the-power-of-tagged-metrics/) | @@ -92,9 +89,7 @@ See [metadata.csv](https://github.com/DataDog/integrations-core/blob/master/http ### Events -Older versions of the HTTP check only emitted events to reflect site status, but now the check supports service checks, too. However, emitting events is still the default behavior. Set `skip_event` to true for all configured instances to submit service checks instead of events. - -The Agent will soon deprecate `skip_event`, i.e. the HTTP check will only support service checks. +The HTTP check does not include any event at this time. ### Service Checks diff --git a/http_check/conf.yaml.example b/http_check/conf.yaml.example index d38eeec8dd1c2..901f6b0aa47ec 100644 --- a/http_check/conf.yaml.example +++ b/http_check/conf.yaml.example @@ -117,12 +117,6 @@ instances: # Host: alternative.host.example.com # X-Auth-Token: SOME-AUTH-TOKEN - # The (optional) skip_event parameter will instruct the check to not - # create any event to avoid duplicates with a server side service check. - # This default to False. - # - skip_event: true - # The (optional) skip_proxy parameter would bypass any proxy settings enabled # and attempt to reach the the URL directly. # If no proxy is defined at any level, this flag bears no effect. diff --git a/http_check/datadog_checks/http_check/__init__.py b/http_check/datadog_checks/http_check/__init__.py index 3042f9c0f7033..8d1589ce568f1 100644 --- a/http_check/datadog_checks/http_check/__init__.py +++ b/http_check/datadog_checks/http_check/__init__.py @@ -2,6 +2,6 @@ HTTPCheck = http_check.HTTPCheck -__version__ = "1.4.1" +__version__ = "2.0.0" __all__ = ['http_check'] diff --git a/http_check/datadog_checks/http_check/http_check.py b/http_check/datadog_checks/http_check/http_check.py index 40bd630914b4c..c0cfa8acc3a4c 100644 --- a/http_check/datadog_checks/http_check/http_check.py +++ b/http_check/datadog_checks/http_check/http_check.py @@ -27,7 +27,7 @@ match_hostname # project -from checks.network_checks import EventType, NetworkCheck, Status +from checks.network_checks import NetworkCheck, Status from config import _is_affirmative from util import headers as agent_headers @@ -359,83 +359,6 @@ def send_status_down(loginfo, message): return service_checks - # FIXME: 5.3 drop this function - def _create_status_event(self, sc_name, status, msg, instance): - # Create only this deprecated event for old check - if sc_name != self.SC_STATUS: - return - # Get the instance settings - url = instance.get('url', None) - name = instance.get('name', None) - nb_failures = self.statuses[name][sc_name].count(Status.DOWN) - nb_tries = len(self.statuses[name][sc_name]) - tags = instance.get('tags', []) - tags_list = [] - tags_list.extend(tags) - - # Only add the URL tag if it's not already present - if not filter(re.compile('^url:').match, tags_list): - tags_list.append('url:%s' % url) - - # Get a custom message that will be displayed in the event - custom_message = instance.get('message', "") - if custom_message: - custom_message += " \n" - - # Let the possibility to override the source type name - instance_source_type_name = instance.get('source_type', None) - if instance_source_type_name is None: - source_type = "%s.%s" % (NetworkCheck.SOURCE_TYPE_NAME, name) - else: - source_type = "%s.%s" % (NetworkCheck.SOURCE_TYPE_NAME, instance_source_type_name) - - # Get the handles you want to notify - notify = instance.get('notify', self.init_config.get('notify', [])) - notify_message = "" - if notify: - notify_list = [] - for handle in notify: - notify_list.append("@%s" % handle.strip()) - notify_message = " ".join(notify_list) + " \n" - - if status == Status.DOWN: - # format the HTTP response body into the event - if isinstance(msg, tuple): - code, reason, content = msg - - # truncate and html-escape content - if len(content) > 200: - content = content[:197] + '...' - - msg = u"%d %s\n\n%s" % (code, reason, content) - msg = msg.rstrip() - - title = "[Alert] %s reported that %s is down" % (self.hostname, name) - alert_type = "error" - msg = u"%s %s %s reported that %s (%s) failed %s time(s) within %s last attempt(s)."\ - " Last error: %s" % (notify_message, custom_message, self.hostname, - name, url, nb_failures, nb_tries, msg) - event_type = EventType.DOWN - - else: # Status is UP - title = "[Recovered] %s reported that %s is up" % (self.hostname, name) - alert_type = "success" - msg = u"%s %s %s reported that %s (%s) recovered" \ - % (notify_message, custom_message, self.hostname, name, url) - event_type = EventType.UP - - return { - 'timestamp': int(time.time()), - 'event_type': event_type, - 'host': self.hostname, - 'msg_text': msg, - 'msg_title': title, - 'alert_type': alert_type, - "source_type_name": source_type, - "event_object": name, - "tags": tags_list - } - def report_as_service_check(self, sc_name, status, instance, msg=None): instance_name = self.normalize(instance['name']) url = instance.get('url', None) diff --git a/http_check/manifest.json b/http_check/manifest.json index 4bcb74b0bba5b..b713cff592b75 100644 --- a/http_check/manifest.json +++ b/http_check/manifest.json @@ -11,7 +11,7 @@ "mac_os", "windows" ], - "version": "1.4.1", + "version": "2.0.0", "guid": "eb133a1f-697c-4143-bad3-10e72541fa9c", "public_title": "Datadog-HTTP Check Integration", "categories":["web", "network"], diff --git a/snmp/datadog_checks/snmp/snmp.py b/snmp/datadog_checks/snmp/snmp.py index 91aee6dc14cf1..4182b3202462c 100644 --- a/snmp/datadog_checks/snmp/snmp.py +++ b/snmp/datadog_checks/snmp/snmp.py @@ -59,7 +59,6 @@ def __init__(self, name, init_config, agentConfig, instances): for instance in instances: if 'name' not in instance: instance['name'] = self._get_instance_key(instance) - instance['skip_event'] = True self.generators = {} diff --git a/tcp_check/CHANGELOG.md b/tcp_check/CHANGELOG.md index 8e5b90197061f..e319f2673671e 100644 --- a/tcp_check/CHANGELOG.md +++ b/tcp_check/CHANGELOG.md @@ -1,5 +1,12 @@ # CHANGELOG - tcp_check +2.0.0 / Unreleased +================== + +### Changes + +* [DEPRECATION] Remove the `skip_event` option from the check. See [#1054][] + 1.0.0 / 2017-03-22 ================== diff --git a/tcp_check/README.md b/tcp_check/README.md index 91b149ed3e393..f47169a945444 100644 --- a/tcp_check/README.md +++ b/tcp_check/README.md @@ -20,7 +20,6 @@ instances: - name: SSH check host: jumphost.example.com # or an IPv4/IPv6 address port: 22 - skip_event: true # if false, the Agent will emit both events and service checks for this port; recommended true (i.e. only submit service checks) collect_response_time: true # to collect network.tcp.response_time. Default is false. ``` @@ -31,7 +30,6 @@ Configuration Options * `port` (Required) - Port to be checked. This will be included as a tag: `url::`. * `timeout` (Optional) - Timeout for the check. Defaults to 10 seconds. * `collect_response_time` (Optional) - Defaults to false. If this is not set to true, no response time metric will be collected. If it is set to true, the metric returned is `network.tcp.response_time`. -* `skip_event` (Optional) - Defaults to false. Set to true to skip creating an event. This option will be removed in a future version and will default to true. * `tags` (Optional) - Tags to be assigned to the metric. [Restart the Agent](https://docs.datadoghq.com/agent/faq/agent-commands/#start-stop-restart-the-agent) to start sending TCP service checks and response times to Datadog. @@ -71,8 +69,6 @@ The TCP check does not include any event at this time. Returns DOWN if the Agent cannot connect to the configured `host` and `port`, otherwise UP. -Older versions of the TCP check only emitted events to reflect changes in connectivity. This was eventually deprecated in favor of service checks, but you can still have the check emit events by setting `skip_event: false`. - To create alert conditions on this service check in the Datadog app, click **Network** on the [Create Monitor](https://app.datadoghq.com/monitors#/create) page, not **Integration**. ## Troubleshooting diff --git a/tcp_check/conf.yaml.example b/tcp_check/conf.yaml.example index d1a51c4429c56..209acfce53c67 100644 --- a/tcp_check/conf.yaml.example +++ b/tcp_check/conf.yaml.example @@ -17,12 +17,6 @@ instances: # - customtag1 # - customtag2 - # The (optional) skip_event parameter will instruct the check to not - # create any event to avoid duplicates with a server side service check. - # This default to False. - # - skip_event: true - # - name: My second service # host: 127.0.0.1 # port: 80 diff --git a/tcp_check/datadog_checks/tcp_check/__init__.py b/tcp_check/datadog_checks/tcp_check/__init__.py index 252fa6dc7e6d7..e1b4ceb3814ea 100644 --- a/tcp_check/datadog_checks/tcp_check/__init__.py +++ b/tcp_check/datadog_checks/tcp_check/__init__.py @@ -2,6 +2,6 @@ TCPCheck = tcp_check.TCPCheck -__version__ = "1.0.0" +__version__ = "2.0.0" __all__ = ['tcp_check'] diff --git a/tcp_check/datadog_checks/tcp_check/tcp_check.py b/tcp_check/datadog_checks/tcp_check/tcp_check.py index 5fed1a7284168..cae14d2d97f38 100644 --- a/tcp_check/datadog_checks/tcp_check/tcp_check.py +++ b/tcp_check/datadog_checks/tcp_check/tcp_check.py @@ -7,7 +7,7 @@ import time # project -from checks.network_checks import EventType, NetworkCheck, Status +from checks.network_checks import NetworkCheck, Status class BadConfException(Exception): @@ -100,62 +100,6 @@ def _check(self, instance): self.log.debug("%s:%s is UP" % (addr, port)) return Status.UP, "UP" - # FIXME: 5.3 remove that - def _create_status_event(self, sc_name, status, msg, instance): - # Get the instance settings - host = instance.get('host', None) - port = instance.get('port', None) - name = instance.get('name', None) - nb_failures = self.statuses[name][sc_name].count(Status.DOWN) - nb_tries = len(self.statuses[name][sc_name]) - - # Get a custom message that will be displayed in the event - custom_message = instance.get('message', "") - if custom_message: - custom_message += " \n" - - # Let the possibility to override the source type name - instance_source_type_name = instance.get('source_type', None) - if instance_source_type_name is None: - source_type = "%s.%s" % (NetworkCheck.SOURCE_TYPE_NAME, name) - else: - source_type = "%s.%s" % (NetworkCheck.SOURCE_TYPE_NAME, instance_source_type_name) - - # Get the handles you want to notify - notify = instance.get('notify', self.init_config.get('notify', [])) - notify_message = "" - if notify: - notify_list = [] - for handle in notify: - notify_list.append("@%s" % handle.strip()) - notify_message = " ".join(notify_list) + " \n" - - if status == Status.DOWN: - title = "[Alert] %s reported that %s is down" % (self.hostname, name) - alert_type = "error" - msg = """%s %s %s reported that %s (%s:%s) failed %s time(s) within %s last attempt(s). - Last error: %s""" % (notify_message, - custom_message, self.hostname, name, host, port, nb_failures, nb_tries, msg) - event_type = EventType.DOWN - - else: # Status is UP - title = "[Recovered] %s reported that %s is up" % (self.hostname, name) - alert_type = "success" - msg = "%s %s %s reported that %s (%s:%s) recovered." % (notify_message, - custom_message, self.hostname, name, host, port) - event_type = EventType.UP - - return { - 'timestamp': int(time.time()), - 'event_type': event_type, - 'host': self.hostname, - 'msg_text': msg, - 'msg_title': title, - 'alert_type': alert_type, - "source_type_name": source_type, - "event_object": name, - } - def report_as_service_check(self, sc_name, status, instance, msg=None): instance_name = self.normalize(instance['name']) host = instance.get('host', None) diff --git a/tcp_check/manifest.json b/tcp_check/manifest.json index d24befd706edb..fe185379fc1f1 100644 --- a/tcp_check/manifest.json +++ b/tcp_check/manifest.json @@ -11,7 +11,7 @@ "mac_os", "windows" ], - "version": "1.0.0", + "version": "2.0.0", "guid": "c514029e-0ed8-4c9f-abe5-2fd4096726ba", "public_title": "Datadog-TCP Check Integration", "categories":["network", "web"], diff --git a/tcp_check/test/test_tcp_check.py b/tcp_check/test/test_tcp_check.py index 755a658948a95..03af7f68486fe 100644 --- a/tcp_check/test/test_tcp_check.py +++ b/tcp_check/test/test_tcp_check.py @@ -16,41 +16,26 @@ 'host': '127.0.0.1', 'port': 65530, 'timeout': 1.5, - 'name': 'DownService', - 'skip_event': True + 'name': 'DownService' }, { 'host': '126.0.0.1', 'port': 65530, 'timeout': 1.5, 'name': 'DownService2', - 'tags': ['test1'], - 'skip_event': True + 'tags': ['test1'] }, { 'host': 'datadoghq.com', 'port': 80, 'timeout': 1.5, 'name': 'UpService', - 'tags': ['test2'], - 'skip_event': True + 'tags': ['test2'] }, { 'host': 'datadoghq.com', 'port': 80, 'timeout': 1, 'name': 'response_time', 'tags': ['test3'], - 'collect_response_time': True, - 'skip_event': True - }] -} - -CONFIG_EVENTS = { - 'init_config': {}, - 'instances': [{ - 'host': '127.0.0.1', - 'port': 65530, - 'timeout': 1.5, - 'name': 'DownService', - 'skip_event': False + 'collect_response_time': True }] } @@ -62,24 +47,6 @@ class TCPCheckTest(AgentCheckTest): def tearDown(self): self.check.stop() - def test_event_deprecation(self): - """ - Deprecate events usage for service checks. - """ - # Run the check - self.run_check(CONFIG_EVENTS) - - # Overrides self.service_checks attribute when values are available - self.warnings = self.wait_for_async('get_warnings', 'warnings', len(CONFIG_EVENTS['instances']), RESULTS_TIMEOUT) - - # Assess warnings - self.assertWarning( - "Using events for service checks is deprecated in " - "favor of monitors and will be removed in future versions of the " - "Datadog Agent.", - count=len(CONFIG_EVENTS['instances']) - ) - def test_check(self): """ Check coverage.