Skip to content

Commit be34507

Browse files
committed
prometheus
- Prometheus on macos - Prometheus data storage
1 parent 164748e commit be34507

File tree

2 files changed

+57
-3
lines changed

2 files changed

+57
-3
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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:

content/Tools/Prometheus.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ Author Profile:
66
tags:
77
- devops
88
Creation Date: 2024-11-06, 14:39
9-
Last Date: 2024-11-07T16:51:48+08:00
9+
Last Date: 2024-11-12T13:36:05+08:00
1010
References:
1111
draft:
1212
description:
1313
---
1414
## Abstract
1515
---
16-
- The **standard monitoring tool** used in **container and microservices infrastructure**
16+
- The **standard monitoring tool** used in **container** and **microservices infrastructure**
1717

1818
>[!question] Why we need Prometheus?
1919
> **Hundreds of interconnected processes** serve users in these environments. If one process fails, it can trigger a **cascade of failures in other processes**, making it **difficult to pinpoint the root cause** from the end user's perspective. Prometheus provides visibility into the application and infrastructure of these hundreds of processes, **enabling proactive identification of issues instead of reactive debugging**. With Prometheus, we can continuously monitor processes, receive alerts about crashes, and even configure alerts for predefined thresholds.
@@ -93,7 +93,12 @@ scrape_configs:
9393
- [[Prometheus]] evalutes the rules and push alerts to Prometheus alert manager which will fire the alerts to different notification channel like email
9494

9595
### Prometheus Data Storage
96-
- [[Prometheus]] stores **time series data** on a local disk-based time series database, but it can also optionally integrate with remote storage systems. The data is stored in a **custom time series format**, so we can't write it directly into a [[Database Paradigms#Relational|relational database]]
96+
- [[Prometheus]] stores **time series data** in a time-series database (TSDB) on the local [[File System|filesystem]], but it can also optionally integrate with remote storage systems. The data is stored in a **custom time series format**, so we can't write it directly into a [[Database Paradigms#Relational|relational database]]
97+
98+
>[!important]
99+
> By default, this data is stored in the **`data/`** directory within Prometheus's working directory. You can customize this location by modifying the **`--storage.tsdb.path`** flag when starting Prometheus.
100+
>
101+
> To control how long Prometheus retains data, use the **`--storage.tsdb.retention.time`** flag. This flag accepts a duration value (e.g., **`15d`** for 15 days).
97102

98103
### Prometheus PromQL
99104
- The query format used to obtain data from the [[#Prometheus Data Storage]], used by data visulisation tool like Grafana to create nice dashboards

0 commit comments

Comments
 (0)