|
| 1 | +--- |
| 2 | +Author: |
| 3 | + - Xinyang YU |
| 4 | +Author Profile: |
| 5 | + - https://linkedin.com/in/xinyang-yu |
| 6 | +tags: |
| 7 | + - devops |
| 8 | +Creation Date: 2024-11-10, 14:50 |
| 9 | +Last Date: 2024-11-12T13:38:05+08:00 |
| 10 | +References: |
| 11 | +draft: |
| 12 | +description: |
| 13 | +--- |
| 14 | +## 1. Install Prometheus |
| 15 | +--- |
| 16 | +- Install [[Prometheus]] with `brew install prometheus`, the default configuration file is located at: `/usr/local/etc/prometheus.yml` |
| 17 | +- Start Prometheus: `prometheus --config.file=/usr/local/etc/prometheus.yml`. This command runs Prometheus in the foreground, listening on port `9090`. Visit [http://localhost:9090](http://localhost:9090) in your browser to access the Prometheus Web UI |
| 18 | +- Alternatively, start Prometheus as a background service: |
| 19 | + - Start: `brew services start prometheus` |
| 20 | + - Stop: `brew services stop prometheus` |
| 21 | + |
| 22 | +>[!help] What is `brew services`? |
| 23 | +> Refer to [[Launchd]] for more details. |
| 24 | +## 2. Install Node Exporter |
| 25 | +--- |
| 26 | +- Install Node Exporter with `brew install node_exporter` |
| 27 | +- Start Node Exporter as a background service: `brew services start node_exporter`. Node Exporter exposes metrics on port `9100`: `http://localhost:9100/metrics` |
| 28 | + |
| 29 | +### 2.1. Configure Prometheus to Scrape Node Exporter |
| 30 | +- Edit your Prometheus configuration file and add the following scrape configuration under `scrape_configs`: |
| 31 | + |
| 32 | +```yaml |
| 33 | +scrape_configs: |
| 34 | + - job_name: 'node_exporter' |
| 35 | + static_configs: |
| 36 | + - targets: ['localhost:9100'] |
| 37 | +``` |
| 38 | +
|
| 39 | +- Restart Prometheus with `brew services restart prometheus` |
| 40 | + |
| 41 | +## 3. Grafana Visualisation |
| 42 | +--- |
| 43 | +- Install Grafana with `brew install grafana` |
| 44 | +- Start Grafana as a background service: `brew services start grafana` |
| 45 | + - Grafana will be accessible at: [http://localhost:3000](http://localhost:3000) |
| 46 | + - Default login credentials: username - `admin`, password - `admin` |
| 47 | +- For more information refers to [here](https://grafana.com/docs/grafana/latest/setup-grafana/installation/mac/) |
| 48 | +- Add Prometheus as a data source, using `http://localhost:9090` as the URL |
| 49 | +- Import the ["Node Exporter Full" dashboard](https://grafana.com/grafana/dashboards/1860-node-exporter-full/) from Grafana Labs: |
0 commit comments