diff --git a/CHANGES.md b/CHANGES.md index ad722ef..46bf0d8 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,9 @@ # Changelog +## 1.0.2 + +* Fix `monitors.get_all_monitors` action to filter results based on `group_states` and `monitor_tags` parameters + ## 1.0.1 * Update metrics.query_ts_points action with the correct class: `DatadogQueryTSPoints` diff --git a/actions/lib/base.py b/actions/lib/base.py index e1d3b29..b2d8049 100644 --- a/actions/lib/base.py +++ b/actions/lib/base.py @@ -26,7 +26,8 @@ def run(self, **kwargs): args = {k: v for k, v in kwargs.items() if str(v).strip() and v is not None} out = self._run(**args) - errors = out.get("errors") - if errors: - return (False, errors) + if isinstance(out, dict): + errors = out.get("errors", None) + if errors: + return (False, errors) return (True, out) diff --git a/actions/lib/monitors.py b/actions/lib/monitors.py index 43620c0..8f9f3b7 100644 --- a/actions/lib/monitors.py +++ b/actions/lib/monitors.py @@ -18,8 +18,12 @@ def _run(self, **kwargs): class DatadogGetAllMonitors(DatadogBaseAction): - def _run(self): - return api.Monitor.get_all() + def _run(self, **kwargs): + monitor_tags_raw = kwargs.pop("tags","") + group_states_raw = kwargs.pop("group_states","") + monitor_tags = [tag.strip() for tag in monitor_tags_raw.split(",")] if monitor_tags_raw else None + group_states = [state.strip() for state in group_states_raw] if group_states_raw else None + return api.Monitor.get_all(monitor_tags=monitor_tags, group_states=group_states, **kwargs) class DatadogGetMonitor(DatadogBaseAction): diff --git a/actions/monitors.get_all_monitors.yaml b/actions/monitors.get_all_monitors.yaml index 4c09b4d..1031f17 100644 --- a/actions/monitors.get_all_monitors.yaml +++ b/actions/monitors.get_all_monitors.yaml @@ -11,7 +11,7 @@ parameters: tags: type: string required: false - description: "A comma separated list indicating what tags, if any, should be used to filter the list of monitors by scope" + description: "A comma separated list indicating what tags, if any, should be used to filter the list of monitors by scope. Example: 'env:prod,service:abc'" cls: default: DatadogGetAllMonitors immutable: true diff --git a/pack.yaml b/pack.yaml index 6f3ffc8..58750e4 100644 --- a/pack.yaml +++ b/pack.yaml @@ -6,7 +6,7 @@ keywords: - monitoring - alerting - saas -version: 1.0.1 +version: 1.0.2 author: Lisa Bekdache email: lisa.bekdache@dailymotion.com python_versions: