Ddog v0.1.0 Ddog.Monitor View Source

Link to this section Summary

Functions

Call receives an action atom to manage Datadog monitor and returns {:ok, HTTPoison.Response.body} when successful and {:error, HTTPoison.Response.Body} when error. Possible values are: :list_all which returns all monitors, :search which accepts a list of tags and returns a list of monitors that matches the tags, :set_monitor_downtime which accepts SetMonitorDowntime struct and set monitor downtime, :cancel_monitor_downtime_by_scope which accepts a scope to cancel monitor downtime.

Accepts a list of map of monitors and returns a list of map of id, name, metrics, status and tags.

Link to this section Functions

Call receives an action atom to manage Datadog monitor and returns {:ok, HTTPoison.Response.body} when successful and {:error, HTTPoison.Response.Body} when error. Possible values are: :list_all which returns all monitors, :search which accepts a list of tags and returns a list of monitors that matches the tags, :set_monitor_downtime which accepts SetMonitorDowntime struct and set monitor downtime, :cancel_monitor_downtime_by_scope which accepts a scope to cancel monitor downtime.

Returns {:ok, %HTTPoison.Response.Body{}}.

## Examples

  iex> Monitor.call(:list_all)
  {:ok, %HTTPoison.Response.Body{}}


  iex> Monitor.call(
    :search,
    %{
      query: Ddog.Helper.build_query("env:test localhost")
    })
  {:ok, %HTTPoison.Response.Body{}}

  iex> Monitor.call(
    :set_monitor_downtime,
    %Ddog.Monitor.Downtime{
        monitor_tags: Ddog.Helper.build_query("env:test localhost"),
        scope: "env:test",
        end: end_downtime,
        message: "scheduled upgrade"
    })
  {:ok, %HTTPoison.Response.Body{}}

  iex> Monitor.call(
    :cancel_monitor_downtime_by_scope,
    %Ddog.Monitor.Downtime{
        scope: "env:test"
    })
  {:ok, %HTTPoison.Response.Body{}}
Link to this function

get_monitor_details(map) View Source

Accepts a list of map of monitors and returns a list of map of id, name, metrics, status and tags.

Returns [%{ id: id, name: "name", metrics: "metrics", status: "status", tags: ["tags"], scopes: ["scopes"] }

## Examples

  iex> Monitor.get_monitor_details(%{"monitors" => [{
      "type": "service check",
      "tags": [
        "monitor_id:host_is_up",
        "env:test",
      ],
      "status": "OK",
      "scopes": [
        "env:test"
      ],
      "name": "localhost",
      "metrics": [
        "datadog.agent.up"
      ],
      "classification": "host",
      ...
      ...
      ...}]
  [{
    id: 1,
    name: "localhost",
    metrics: "datadog.agent.up",
    status: "OK",
    tags: ["env:test", "monitor_id:host_is_up"],
    scopes: ["env:test"]
  }]