diff --git a/README.md b/README.md index f61ccf3..ab17a1b 100644 --- a/README.md +++ b/README.md @@ -78,6 +78,29 @@ endpoints: - CREATE_INCIDENT public_incidents: true frequency: 5 + - name: POST-API + url: http://www.example.com/api/login + method: POST + header: + Content-Type: application/json + data: '{ "username": "ping", "password": "pong"}' + timeout: 1 # seconds + expectation: + - type: HTTP_STATUS + status_range: 200-205 + incident: MAJOR + - type: LATENCY + threshold: 1 + - type: REGEX + regex: ".*token.*" + threshold: 10 + allowed_fails: 0 + component_id: 2 + action: + - CREATE_INCIDENT + public_incidents: true + latency_unit: ms + frequency: 5 cachet: api_url: http://status.cachethq.io/api/v1 token: diff --git a/cachet_url_monitor/configuration.py b/cachet_url_monitor/configuration.py index 5682f93..754373f 100755 --- a/cachet_url_monitor/configuration.py +++ b/cachet_url_monitor/configuration.py @@ -50,6 +50,7 @@ class Configuration(object): endpoint_url: str endpoint_timeout: int endpoint_header: Dict[str, str] + endpoint_data: str allowed_fails: int component_id: int @@ -91,6 +92,7 @@ def __init__(self, config, endpoint_index: int, client: CachetClient, webhooks: self.endpoint_timeout = self.endpoint.get("timeout") or 1 self.endpoint_header = self.endpoint.get("header") or None self.allowed_fails = self.endpoint.get("allowed_fails") or 0 + self.endpoint_data = self.endpoint.get("data") or None self.component_id = self.endpoint["component_id"] self.metric_id = self.endpoint.get("metric_id") @@ -158,11 +160,11 @@ def evaluate(self): """ try: if self.endpoint_header is None: - self.request = requests.request(self.endpoint_method, self.endpoint_url, timeout=self.endpoint_timeout) + self.request = requests.request(self.endpoint_method, self.endpoint_url, timeout=self.endpoint_timeout, data=self.endpoint_data) else: self.request = requests.request( self.endpoint_method, self.endpoint_url, timeout=self.endpoint_timeout, headers=self.endpoint_header, - verify=not self.endpoint['insecure'] if 'insecure' in self.endpoint else True + verify=not self.endpoint['insecure'] if 'insecure' in self.endpoint else True, data=self.endpoint_data ) self.current_timestamp = int(time.time())