Skip to content

Commit 394344b

Browse files
author
sudo-Tiz
committed
upgrade cadvisor documentation
1 parent 55fab67 commit 394344b

File tree

4 files changed

+136
-20
lines changed

4 files changed

+136
-20
lines changed

docs/services/cadvisor.md

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
# cAdvisor
2+
3+
This playbook can configure [cAdvisor](https://github.com/google/cadvisor)
4+
5+
## Dependencies
6+
7+
This service requires the following other services:
8+
9+
- (optionally) [Traefik](traefik.md) - a reverse-proxy server for exposing cadvisor publicly
10+
- (optionally) [Prometheus](./prometheus.md) - a database for storing metrics
11+
- (optionally) [Grafana](./grafana.md) - a web UI that can query the prometheus datasource (connection) and display the logs
12+
13+
## Configuration
14+
15+
To enable this service, add the following configuration to your `vars.yml` file and re-run the [installation](../installing.md) process:
16+
17+
```yaml
18+
########################################################################
19+
# #
20+
# cadvisor #
21+
# #
22+
########################################################################
23+
24+
cadvisor_enabled: true
25+
# You will have to mount specific folders depending on your need
26+
# cadvisor_container_extra_arguments:
27+
# - "--mount type=bind,source=/,destination=/rootfs,readonly"
28+
# - "--mount type=bind,source=/sys,destination=/sys,readonly"
29+
# - "--mount type=bind,source=/var/lib/docker/,destination=/var/lib/docker,readonly"
30+
# - "--mount type=bind,source=/dev/disk/,destination=/dev/disk,readonly"
31+
32+
########################################################################
33+
# #
34+
# /cadvisor #
35+
# #
36+
########################################################################
37+
```
38+
39+
See the full list of options in the [default/main.yml](default/main.yml) file
40+
41+
cAdvisor can scrape metrics from system and containers. These metrics can be :
42+
43+
- Displayed on the cAdvisor Web UI
44+
- Exposed to a metric-storage server like [Prometheus](./prometheus.md).
45+
46+
## Exposing publicly the Web UI
47+
48+
To expose cAdvisor to the web, you need to assign a hostname in `cadvisor_hostname` and optionally a path-prefix.
49+
50+
```yaml
51+
# To expose the metrics publicly, enable and configure the lines below:
52+
cadvisor_hostname: mash.example.com
53+
cadvisor_path_prefix: /
54+
55+
# To protect the metrics with HTTP Basic Auth, enable and configure the lines below.
56+
# See: https://doc.traefik.io/traefik/middlewares/http/basicauth/#users
57+
cadvisor_container_labels_traefik_middleware_basic_auth_enabled: true
58+
cadvisor_container_labels_traefik_middleware_basic_auth_users: ""
59+
```
60+
61+
### Exposing metrics publicly
62+
63+
Unless you're scraping the cadvisor metrics from a local [Prometheus](prometheus.md) instance, as described in [Integrating with Prometheus](cadvisor.md#), you will probably wish to expose the metrics publicly so that a remote Prometheus instance can fetch them. When exposing publicly, it's natural to set up [HTTP Basic Authentication](https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication) **or anyone would be able to read your metrics**.
64+
65+
```yaml
66+
cadvisor_container_labels_metrics_enabled: true
67+
68+
# To expose the metrics publicly, enable and configure the lines below:
69+
<!-- cadvisor_hostname: mash.example.com -->
70+
<!-- cadvisor_path_prefix: /metrics/mash-cadvisor -->
71+
72+
# To protect the metrics with HTTP Basic Auth, enable and configure the lines below.
73+
# See: https://doc.traefik.io/traefik/middlewares/http/basicauth/#users
74+
cadvisor_container_labels_metrics_middleware_basic_auth_enabled: true
75+
cadvisor_container_labels_metrics_middleware_basic_auth_users: ""
76+
```
77+
78+
## Integrating with Prometheus
79+
80+
cAdvisor can expose its metrics to [Prometheus](./prometheus.md).
81+
82+
### Prerequesites
83+
84+
The bare minimium is to ensure Prometheus can reach cadvisor.
85+
86+
- If cadvisor is on a different host than Prometheus, refer to section [Expose metrics publicly](cadvisor.md#)
87+
- If cadvisor is on the same host than prometheus, refer to section [Ensure Prometheus is on the same container network as cadvisor.](cadvisor.md#)
88+
89+
### Ensure Prometheus is on the same container network as cAdvisor.
90+
91+
If you are using MASH playbook, cadvisor should already be connected to prometheus container network
92+
93+
If cadvisor and prometheus do not share a network, you will have to
94+
95+
- Either connect Prometheus container network to cadvisor by editing `prometheus_container_additional_networks_auto`
96+
- Either connect cadvisor container network to Prometheus by editing `cadvisor_container_additional_networks_custom`
97+
98+
Exemple:
99+
100+
```yaml
101+
prometheus_container_additional_networks:
102+
- "{{ cadvisor_container_network }}"
103+
```
104+
105+
### Write the scrape config for prometheus
106+
107+
# Healthcheck
108+
109+
```yaml
110+
cadvisor_environment_variables_extension: |
111+
112+
# CADVISOR_HEALTHCHECK_URL=http://localhost:8080/cadvisor/healthz
113+
```
114+
115+
## Usage
116+
117+
After [installing](../installing.md), refer to the documentation of [cAdvisor](https://github.com/google/cadvisor).

docs/supported-services.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
| [authentik](https://goauthentik.io/) | An open-source Identity Provider focused on flexibility and versatility. | [Link](services/authentik.md) |
1212
| [borgbackup](https://www.borgbackup.org/) (via [borgmatic](https://torsion.org/borgmatic/)) | A deduplicating backup program with optional compression and encryption| [Link](services/backup-borg.md) |
1313
| [Calibre-Web](https://github.com/janeczku/calibre-web) | Web app for browsing, reading and downloading eBooks stored in a [Calibre](https://calibre-ebook.com/) database | [Link](services/calibre-web.md) |
14+
| [cAdvisor](https://github.com/google/cadvisor) | Analyzes resource usage and performance characteristics of running containers. | [Link](services/cadvisor.md) |
1415
| [Changedetection.io](https://github.com/dgtlmoon/changedetection.io) | A simple website change detection and restock monitoring solution. | [Link](services/changedetection.md) |
1516
| [ClickHouse](https://clickhouse.com/) | An open-source column-oriented DBMS for online analytical processing (OLAP) that allows users to generate analytical reports using SQL queries in real-time. | [Link](services/clickhouse.md) |
1617
| [Collabora Online](https://www.collaboraoffice.com/) | Your Private Office Suite In The Cloud | [Link](services/collabora-online.md) |

templates/group_vars_mash_servers

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1610,39 +1610,33 @@ wetty_container_labels_traefik_tls_certResolver: "{{ devture_traefik_certResolve
16101610

16111611
cadvisor_enabled: false
16121612

1613-
cadvisor_identifier: "{{ mash_playbook_service_identifier_prefix }}prometheus-node-exporter"
1614-
1615-
cadvisor_hostname: "{{ mash_playbook_metrics_exposure_hostname }}"
1616-
cadvisor_path_prefix: "{{ mash_playbook_metrics_exposure_path_prefix }}/{{ cadvisor_identifier }}"
1617-
1618-
cadvisor_base_path: "{{ mash_playbook_base_path }}/{{ mash_playbook_service_base_directory_name_prefix }}prometheus-node-exporter"
1613+
cadvisor_identifier: "{{ mash_playbook_service_identifier_prefix }}cadvisor"
16191614

16201615
cadvisor_uid: "{{ mash_playbook_uid }}"
16211616
cadvisor_gid: "{{ mash_playbook_gid }}"
16221617

1623-
cadvisor_container_additional_networks: |
1624-
{{
1625-
([mash_playbook_reverse_proxyable_services_additional_network] if mash_playbook_reverse_proxyable_services_additional_network else [])
1626-
}}
1627-
16281618
# Only enable Traefik labels if a hostname is set (indicating that this will be exposed publicly)
16291619
cadvisor_container_labels_traefik_enabled: "{{ mash_playbook_traefik_labels_enabled and cadvisor_hostname }}"
16301620
cadvisor_container_labels_traefik_docker_network: "{{ mash_playbook_reverse_proxyable_services_additional_network }}"
16311621
cadvisor_container_labels_traefik_entrypoints: "{{ devture_traefik_entrypoint_primary }}"
16321622
cadvisor_container_labels_traefik_tls_certResolver: "{{ devture_traefik_certResolver_primary }}"
16331623

1624+
cadvisor_container_labels_metrics_enabled: "{{ prometheus_enabled | default(false) or mash_playbook_metrics_exposure_enabled }}"
1625+
cadvisor_container_labels_metrics_hostname: "{{ mash_playbook_metrics_exposure_hostname }}"
1626+
cadvisor_container_labels_metrics_path_prefix: "{{ mash_playbook_metrics_exposure_path_prefix }}/{{ cadvisor_identifier }}"
1627+
cadvisor_container_labels_metrics_traefik_middleware_basic_auth_enabled: "{{ mash_playbook_metrics_exposure_http_basic_auth_enabled }}"
1628+
cadvisor_container_labels_metrics_traefik_middleware_basic_auth_users: "{{ mash_playbook_metrics_exposure_http_basic_auth_users }}"
16341629
cadvisor_container_labels_metrics_middleware_basic_auth_enabled: "{{ mash_playbook_metrics_exposure_http_basic_auth_enabled }}"
16351630
cadvisor_container_labels_metrics_middleware_basic_auth_users: "{{ mash_playbook_metrics_exposure_http_basic_auth_users }}"
16361631

1637-
cadvisor_container_extra_arguments_auto:
1638-
- "--mount type=bind,source=/,destination=/rootfs,readonly"
1639-
- "--mount type=bind,source=/var/run,destination=/var/run,readonly"
1640-
- "--mount type=bind,source=/sys,destination=/sys,readonly"
1641-
- "--mount type=bind,source=/var/lib/docker/,destination=/var/lib/docker,readonly"
1642-
- "--mount type=bind,source=/dev/disk/,destination=/dev/disk,readonly"
1643-
- "--mount type=bind,source=/dev/kmsg,target=/dev/kmsg"
1644-
1645-
1632+
cadvisor_container_additional_networks_auto: |
1633+
{{
1634+
(
1635+
([mash_playbook_reverse_proxyable_services_additional_network] if mash_playbook_reverse_proxyable_services_additional_network else [])
1636+
+
1637+
([prometheus_container_network] if (prometheus_enabled | default(false) and prometheus_container_network | default('') != cadvisor_container_network) else [])
1638+
) | unique
1639+
}}
16461640

16471641
cadvisor_process_extra_arguments_auto:
16481642
- "--url_base_prefix={{ cadvisor_container_labels_traefik_path_prefix }}"

templates/setup.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,10 @@
131131
- role: galaxy/calibre-web
132132
# /role-specific:calibre-web
133133

134+
# role-specific:cadvisor
135+
- role: galaxy/cadvisor
136+
# /role-specific:cadvisor
137+
134138
# role-specific:clickhouse
135139
- role: galaxy/clickhouse
136140
# /role-specific:clickhouse

0 commit comments

Comments
 (0)