# `Hemdal.Config.Backend.Json`
[🔗](https://github.com/altenwald/hemdal/blob/v1.4.0/lib/hemdal/config/backend/json.ex#L1)

Configuration backend reader using JSON. See `Hemdal.Config.Backend` for
further information.

The backend is needing the configuration (see `Application` or `Config`)
to know where the JSON file is located. You can write in the configuration
an entry like this:

```elixir
# config/config.exs
import Config

config :hemdal, Hemdal.Config,
  hosts_file: "hosts.json",
  alerts_file: "alerts.json"
```

The hosts file is intended to configure all of the necessary hosts to be
accessible to run the checks and the alerts are the configuration for each
check.

An example of the hosts file is as follows:

```json
[
  {
    "id": "2a8572d4-ceb3-4200-8b29-dd1f21b50e54",
    "name": "localhost",
    "module": "Hemdal.Host.Local",
    "max_workers": 1
  }
]
```

And an example for the alerts file is as follows:

```json
[
  {
    "id": "52d13d6d-f217-4152-965d-cf5f488ceac4",
    "name": "valid alert check",
    "host_id": "2a8572d4-ceb3-4200-8b29-dd1f21b50e54",
    "command": {
      "name": "get ok status",
      "type": "line",
      "command": "echo '["OK", "valid one!"]'"
    }
  }
]
```

If you want to know more about what are the parameters you can use,
see `Hemdal.Config.Alert` and `Hemdal.Config.Host` for further information.

# `get_all_alerts`

```elixir
@spec get_all_alerts() :: [Hemdal.Config.Alert.t()]
```

Get all of the alerts. It's reading the alerts file specified in the
configuration and the hosts file to create the full information for
the alert.

# `get_all_hosts`

```elixir
@spec get_all_hosts() :: [Hemdal.Config.Host.t()]
```

Get all of the hosts. It's reading the hosts file specified in the
configuration and returning it as a list of `Hemdal.Config.Host`
elements.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
