|
1 | | -# Availability Probing |
2 | | -//TODO |
| 1 | +# Availability |
3 | 2 |
|
4 | | -HTTP Probers are setup to scrape the real endpoints exposed by our services, and we can calculate a percentage uptime and latency based on those. |
| 3 | +This guide explains how to configure HTTP probers using Blackbox Exporter to monitor the availability of your services. These probers generate uptime and latency metrics, which can then be visualized in Grafana. |
5 | 4 |
|
6 | | -See the [Reference](../reference/understanding-metrics.md) for more details. |
| 5 | +See the [Reference](../reference/understanding-metrics.md) for an explanation of the metrics this generates. |
7 | 6 |
|
| 7 | +--- |
8 | 8 |
|
9 | | -## Adding Probers |
10 | | -- `site/prometheus/scrape-configs/probers/*.yml`. |
11 | | -Add yaml files to this folder as probe targets. Any yml files put into this directory, for example "probe.example.yml", will be used as targets to probe for availability using blackbox exporter. Add any URLs that you want to measure the availability of. |
| 9 | +## How to Add New Probers |
12 | 10 |
|
13 | | -```yaml |
14 | | -# Prober yml |
15 | | -- targets: |
16 | | - - https://google.com/something |
17 | | - labels: |
18 | | - name: google-homepage # Mandatory - the name of the service being probed |
19 | | - job: override_job # (Optional. Default is "probe-cogstack-availability") Customise a job to enable grouping in the dashboard |
20 | | - ip_address: "123.0.0.1" # (Optional) The IP address |
21 | | - host: a_hostname # (Optional) A readable hostname |
22 | | - custom_label: a_custom_label # (Optional) Any other label |
23 | | - |
| 11 | +To add a new prober target: |
| 12 | + |
| 13 | +1. Navigate to the folder: |
| 14 | + |
| 15 | + ``` |
| 16 | + prometheus/scrape-configs/probers/ |
| 17 | + ``` |
| 18 | + |
| 19 | +2. Create a new YAML file (e.g., `probe.my-services.yml`) with the following structure: |
| 20 | + |
| 21 | + ``` |
| 22 | + # probe.my-services.yml |
| 23 | + - targets: |
| 24 | + - https://myservice.example.com/health |
| 25 | + labels: |
| 26 | + name: my-service # Mandatory - the name of the service being probed |
| 27 | + job: my-services # Mandatory - used to group probes in dashboards |
| 28 | + ip_address: "10.0.0.12" # Optional - IP of the host being probed |
| 29 | + host: service-hostname # Optional - Human-readable hostname |
| 30 | + region: eu-west # Optional - Any additional metadata label |
| 31 | + ``` |
| 32 | + |
| 33 | +3. Ensure the folder is mounted in docker under `/etc/prometheus/cogstack/site/prometheus/scrape-configs/probers`, which it should be by default if you've followed the setup guids. Any valid `.yml` files in this folder will be automatically picked up and used as Blackbox targets. |
| 34 | + |
| 35 | +--- |
| 36 | + |
| 37 | +## Advanced Setup |
| 38 | + |
| 39 | +### How to add Auth to the prober or further configurations |
| 40 | + |
| 41 | +To define how a probe behaves (e.g., add basic auth, headers, timeout, method), we will configure a module in the Blackbox Exporter config. |
| 42 | + |
| 43 | +#### Create a Blackbox Exporter Config file |
| 44 | +You will need to create a new file, and then mount it over the existing provided vconfig |
| 45 | + |
| 46 | + |
| 47 | +1. Create a new file: |
| 48 | + |
| 49 | + ``` |
| 50 | + prometheus/blackbox-exporter/custom-blackbox-config.yml |
| 51 | + ``` |
| 52 | + |
| 53 | +2. Add the existing defaults |
| 54 | + |
| 55 | +``` |
| 56 | +modules: |
| 57 | + http_get_200: |
| 58 | + prober: http |
| 59 | + timeout: 5s |
| 60 | + http: |
| 61 | + valid_http_versions: ["HTTP/1.1", "HTTP/2.0"] |
| 62 | + valid_status_codes: [200] # Defaults to 2xx |
| 63 | + method: GET |
| 64 | + preferred_ip_protocol: "ip4" # defaults to "ip6" |
| 65 | + tls_config: |
| 66 | + insecure_skip_verify: true |
| 67 | +``` |
| 68 | + |
| 69 | +3. Add your own module to the modules in that file |
24 | 70 | ``` |
| 71 | + http_2xx_custom: |
| 72 | + prober: http |
| 73 | + timeout: 5s |
| 74 | + http: |
| 75 | + valid_http_versions: ["HTTP/1.1", "HTTP/2.0"] |
| 76 | + valid_status_codes: [200] # Defaults to 2xx |
| 77 | + method: GET |
| 78 | + preferred_ip_protocol: "ip4" # defaults to "ip6" |
| 79 | + tls_config: |
| 80 | + insecure_skip_verify: true |
| 81 | + basic_auth: |
| 82 | + username: my-user |
| 83 | + password: example-pass |
| 84 | +``` |
| 85 | + |
| 86 | +This example adds a module named `http_2xx_custom` that adds some basic auth credentials |
| 87 | + |
| 88 | +--- |
| 89 | + |
| 90 | +#### Reference the new module in your prober config |
| 91 | + |
| 92 | +In your probe YAML file, reference the module in the `module` field of the `labels` section: |
| 93 | + |
| 94 | +``` |
| 95 | + - targets: |
| 96 | + - https://myservice.example.com/health |
| 97 | + labels: |
| 98 | + name: my-service |
| 99 | + module: http_2xx_custom # Optional - overrides the default Blackbox module |
| 100 | +``` |
| 101 | + |
| 102 | +#### Mount the config file |
| 103 | +You lastly need to mount the new config file and refer to it in docker compose |
| 104 | + |
| 105 | +``` |
| 106 | + blackbox-exporter: |
| 107 | + image: cogstacksystems/cogstack-observability-blackbox-exporter:latest |
| 108 | + restart: unless-stopped |
| 109 | + networks: |
| 110 | + - observability |
| 111 | + volumes: |
| 112 | + - ./prometheus/blackbox-exporter:/config |
| 113 | + command: |
| 114 | + - "--config.file=/config/custom-blackbox-config.yml" |
| 115 | +``` |
| 116 | + |
| 117 | +--- |
| 118 | + |
| 119 | +## Notes |
| 120 | + |
| 121 | +* Changes will take effect on the next Prometheus reload or container restart. |
| 122 | +* Jobs with the same `job` label are grouped in dashboards to simplify analysis. |
| 123 | +* Job labels need to line up with defined SLOs to enable Alerting |
| 124 | +* Probers can be used for both external URLs, and direct to local docker containers. For example, we probe grafana on "cogstack-observability-grafana-1:3000/". If you want to probe local docker containers, note that the network has to line up |
| 125 | + |
25 | 126 |
|
26 | | -## Configuring Probers |
27 | | -- How to setup custom exporter module |
28 | | -- How to use the module in my yml |
| 127 | +## External links |
| 128 | +For full Blackbox Exporter documentation, see: |
29 | 129 |
|
| 130 | +- [Prometheus Blackbox Exporter](https://github.com/prometheus/blackbox_exporter) |
0 commit comments