Skip to content

Commit

Permalink
use chapters instead of parts to allow sub-headings
Browse files Browse the repository at this point in the history
  • Loading branch information
ibizaman authored and ibizaman committed Dec 7, 2023
1 parent 13b756b commit 5a3e072
Show file tree
Hide file tree
Showing 9 changed files with 118 additions and 127 deletions.
7 changes: 0 additions & 7 deletions docs/blocks/monitoring/alerts-requests-error-budger.md

This file was deleted.

64 changes: 0 additions & 64 deletions docs/blocks/monitoring/configuration.md

This file was deleted.

9 changes: 0 additions & 9 deletions docs/blocks/monitoring/dashboard-errors.md

This file was deleted.

6 changes: 0 additions & 6 deletions docs/blocks/monitoring/dashboard-performance.md

This file was deleted.

115 changes: 109 additions & 6 deletions docs/blocks/monitoring/default.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,113 @@ This block sets up the monitoring stack for Self Host Blocks. It is composed of:
- Prometheus as the database for metrics.
- Loki as the database for logs.

```{=include=} parts
configuration.md
provisioning.md
dashboard-errors.md
dashboard-performance.md
alerts-requests-error-budger.md
## Configuration {#blocks-monitoring-configuration}

```nix
shb.monitoring = {
enable = true;
subdomain = "grafana";
inherit domain;
contactPoints = [ "[email protected]" ];
adminPasswordFile = config.sops.secrets."monitoring/admin_password".path;
secretKeyFile = config.sops.secrets."monitoring/secret_key".path;
};
sops.secrets."monitoring/admin_password" = {
sopsFile = ./secrets.yaml;
mode = "0400";
owner = "grafana";
group = "grafana";
restartUnits = [ "grafana.service" ];
};
sops.secrets."monitoring/secret_key" = {
sopsFile = ./secrets.yaml;
mode = "0400";
owner = "grafana";
group = "grafana";
restartUnits = [ "grafana.service" ];
};
```

With that, Grafana, Prometheus, Loki and Promtail are setup! You can access `Grafana` at
`grafana.example.com` with user `admin` and password ``.

I recommend adding a STMP server configuration so you receive alerts by email:

```nix
shb.monitoring.smtp = {
from_address = "grafana@$example.com";
from_name = "Grafana";
host = "smtp.mailgun.org";
port = 587;
username = "[email protected]";
passwordFile = config.sops.secrets."monitoring/smtp".path;
};
sops.secrets."monitoring/secret_key" = {
sopsFile = ./secrets.yaml;
mode = "0400";
owner = "grafana";
group = "grafana";
restartUnits = [ "grafana.service" ];
};
```

Since all logs are now stored in Loki, you can probably reduce the systemd journal retention
time with:

```nix
# See https://www.freedesktop.org/software/systemd/man/journald.conf.html#SystemMaxUse=
services.journald.extraConfig = ''
SystemMaxUse=2G
SystemKeepFree=4G
SystemMaxFileSize=100M
MaxFileSec=day
'';
```

## Provisioning {#blocks-monitoring-provisioning}

Self Host Blocks will create automatically the following resources:

- For Grafana:
- datasources
- dashboards
- contact points
- notification policies
- alerts
- For Prometheus, the following exporters and related scrapers:
- node
- smartctl
- nginx
- For Loki, the following exporters and related scrapers:
- systemd

Those resources are namespaced as appropriate under the Self Host Blocks namespace:

[](./assets/folder.png)

## Errors Dashboard {#blocks-monitoring-error-dashboard}

This dashboard is meant to be the first stop to understand why a service is misbehaving.

![](./assets/dashboards_Errors_1.png)
![](./assets/dashboards_Errors_2.png)

The yellow and red dashed vertical bars correspond to the [Requests Error Budget
Alert](#blocks-monitoring-budget-alerts) firing.

## Performance Dashboard {#blocks-monitoring-performance-dashboard}

This dashboard is meant to be the first stop to understand why a service is performing poorly.

![Performance Dashboard Top Part](./assets/dashboards_Performance_1.png)
![Performance Dashboard Bottom Part](./assets/dashboards_Performance_2.png)

## Requests Error Budget Alert {#blocks-monitoring-budget-alerts}

This alert will fire when the ratio between number of requests getting a 5XX response from a service
and the total requests to that service exceeds 1%.

![](./assets/alert_rules_5xx_1.png)
![](./assets/alert_rules_5xx_2.png)
20 changes: 0 additions & 20 deletions docs/blocks/monitoring/provisioning.md

This file was deleted.

12 changes: 6 additions & 6 deletions docs/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,12 @@ in stdenv.mkDerivation {
${optionsDocs.optionsJSON}/share/doc/nixos/options.json
find . -name "*.md" -print0 | \
while IFS= read -r -d ''' f; do
substituteInPlace "''${f}" \
--replace \
'@REPO@' \
"${lib.debug.traceVal ghRoot}"
done
while IFS= read -r -d ''' f; do
substituteInPlace "''${f}" \
--replace \
'@REPO@' \
"${ghRoot}"
done
nixos-render-docs manual html \
--manpage-urls ${manpage-urls} \
Expand Down
10 changes: 1 addition & 9 deletions docs/manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,10 @@
preface.md
```

```{=include=} parts html:into-file=//blocks-monitoring.html
```{=include=} chapters html:into-file=//blocks-monitoring.html
blocks/monitoring/default.md
```

```{=include=} appendix html:into-file=//options.html
options.md
```

<!-- ```{=include=} appendix html:into-file=//nixos-options.html -->
<!-- nixos-options.md -->
<!-- ``` -->

<!-- ```{=include=} appendix html:into-file=//nix-darwin-options.html -->
<!-- nix-darwin-options.md -->
<!-- ``` -->
2 changes: 2 additions & 0 deletions docs/preface.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Preface {#preface}

::: {.note}
This document is the complete manual for Self Host Blocks, the building blocks for self-hosting with battery included.
:::

Self Host Blocks is hosted on [GitHub](https://github.com/ibizaman/selfhostblocks). If you encounter
problems or bugs then please report them on the [issue
Expand Down

0 comments on commit 5a3e072

Please sign in to comment.