Skip to content

Commit ae0cbf4

Browse files
authored
Merge pull request #361 from stateful/T-monitoring-stack
docs: add monitoring guide
2 parents f123fd5 + 504ec10 commit ae0cbf4

23 files changed

+278
-0
lines changed

docs/configuration/runme-gist.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Runme Gist
2+
3+
Would you love to share or store your plain texts or code snippets securely with others in your team without needing a full repository or document?
4+
Runme Gist makes this possible and prioritizes your information's sensitivity by keeping sensitive information secret. In this section, we will explain how Runme Gist works.
5+
6+
## **What is Runme Gist?**
7+
8+
Runme Gist combines GitHub Gist with Runme capabilities to run, share, and store plain texts or code snippets in your Markdown file. What makes Runme Gist powerful is its ability to capture outputs and mask sensitive data without copying and pasting or integrating a third-party tool. You have everything done inside your Markdown file. Amazing right?
9+
10+
## **Installation**
11+
12+
- To utilize the Runme Gist feature, ensure the [Runme extension](../installation/installrunme) is installed in your VS Code. If you already have Runme installed in your VS Code, ensure you are upgraded to v3.4.0.
13+
- Set Runme as your [default Markdown viewer](../installation/installrunme) to ensure all Markdown files in your code editor are automatically opened as a Runme notebook.
14+
15+
## **Setting Up Runme Gist**
16+
17+
As stated earlier, Runme Gist combines GitHub Gist with Runme capabilities to enable you to securely run, share, and store code snippets. In this section, we will explain how Runme Gist works using a step-by-step guide.
18+
19+
1. Open your Markdown File
20+
Create a `README.md` file and open it in your VS Code. If you already have the file you want to use, open it in VS Code.
21+
2. Run Cells
22+
Run your notebook cells, and ensure the [auto-save feature](../configuration/auto-save) is turned on to save your outputs without manual intervention.
23+
24+
![runme gist Autosave ](../../static/img/configuration-page/runme-gist-autosave.png)
25+
26+
3. View Sessions Output
27+
Session output is a Runme feature that stores your generated cell outputs to a separate file to enable you access the output whenever you need. See the [Session output](../configuration/auto-save#session-outputs) guide.
28+
29+
To view your session output, click “Sessions Outputs” to inspect the locally recorded session. Alternatively, you can find it on the left-hand side of your VS Code right inside your current working directory.
30+
31+
![Runme gist session output](../../static/img/configuration-page/runme-gist-sessionoutput.png)
32+
33+
The Session Outputs feature is only available when the autosave is enabled and the Runme cell is run.
34+
35+
4. Toggle Between Mask and Unmask
36+
You can decide if you want your session outputs to be masked or unmasked.
37+
The masked and unmasked options are how Runme keeps your sensitive information secret. If you want to keep your sensitive information secret, you should toggle the mask option otherwise, choose the unmasked option.
38+
Otherwise, Runme uses the open-source `data-guardian` library to mask sensitive information on a best-effort basis.
39+
40+
![Runme gist unmask](../../static/img/configuration-page/runme-gist-unmask.png)
41+
42+
## **Creating and Managing Gist with Runme using Secret Gists**
43+
44+
GitHub Gist is a service provided by GitHub that allows users to share code snippets, notes, and other small pieces of text with others. With a single click, you can push your Runme Session Output to GitHub Gist from your Markdown file.
45+
To do this, click on “Generate Gist”.
46+
47+
![Runme gist](../../static/img/configuration-page/runme-gist.png)
48+
49+
Runme will first prompt you to log into your GitHub account and grant write access to your Gist. After a successful login, a notification containing a link to the Runme Gist hosted on your GitHub will be displayed.
50+
51+
The link is generated as a “Secret Gist,” which will stay private as long as you keep it private. Ensure you secure the link cautiously before pushing your sessions to GitHub Gist.
52+
Lastly, use the Runme mask feature to keep your sensitive pieces secured.
53+
54+
## **Visual Representation of Runme Gist**
55+
56+
Here is a video that showcases the power of Runme Gist.
57+
58+
<video autoPlay loop muted playsInline controls>
59+
<source src="/videos/Runme-gist.mp4" type="video/mp4" />
60+
<source src="/videos/Runme-gist.webm" type="video/webm" />
61+
</video>
62+
63+
Congratulations! You have successfully learned how to use the Runme Gist feature.
64+
65+
Note that session output files can be kept offline and locally.
66+
You can read about that [here](https://runme.dev/blog/runme-v3-pipeline-logs-and-artifacts). If you love this feature, kindly give [Runme a star](https://github.com/stateful/runme/stargazers) on GitHub.
67+

docs/guide/monitoring-stack.md

Lines changed: 211 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,211 @@
1+
# How to Set Up a Monitoring Stack For Your Application by Leveraging Runme
2+
3+
A monitoring stack is a set of tools that collect, process, and visualize data from various sources to improve the performance and security of systems and applications.
4+
5+
Most often, instructions which define setting up and configuration of monitoring stack procedures are set in multiple documents which can be overwhelming. This is where Runme comes in! Runme provides a platform that helps you document all the standardized processes needed to set up and configure your monitoring stack, centralizing your procedures and processes in an interactive runbook accessible to you and your team.
6+
7+
With Runme, you create a set of predefined procedures and instructions for installing and configuring all dependencies needed for your monitoring stack, such as [Prometheus](https://prometheus.io/), [Grafana](https://grafana.com/) and others.
8+
9+
In this guide, we will walk you through configuring a monitoring stack and creating a Runbook for your application setup and configuration using Runme.
10+
11+
## Prerequisites
12+
13+
To follow up on the steps in this guide, ensure you have the following:
14+
15+
- Runme Extension: Install the [Runme extension](https://marketplace.visualstudio.com/items?itemName=stateful.runme) in your VS Code editor. You can make Runme your [default Markdown viewer](https://docs.runme.dev/installation/installrunme#how-to-set-vs-code-as-your-default-markdown-viewer), ensuring all your Markdown files are automatically opened as a Runme Notebook. Additionally, it provides other client interfaces where you can run your Markdown file. See the [Runme installation](https://docs-runme-jg6ocbnyb-stateful.vercel.app/installation/) guide.
16+
- Clone Repository: We have provided an example repo to help you follow this tutorial. Clone the [repository here](https://github.com/stateful/blog-examples/tree/main/kubernetes/monitoring-stack). If you are a Linux user, navigate to the [Linux file](https://github.com/stateful/blog-examples/blob/main/kubernetes/monitoring-stack/linux.md). For Mac users, see the [Mac file](https://github.com/stateful/blog-examples/blob/main/kubernetes/monitoring-stack/mac.md).
17+
This guide focuses on the Linux README.md file; other operating systems also work.
18+
19+
## Install a Node Exporter
20+
21+
A [Node Exporter](https://github.com/prometheus/node_exporter) allows for detailed monitoring of system-level metrics like CPU usage, memory usage, disk, and network activity, providing valuable insights into the health and performance of the underlying infrastructure.
22+
23+
To install a Node Exporter in Runme, navigate to the “[Install Node Exporter](https://github.com/stateful/blog-examples/blob/main/kubernetes/monitoring-stack/linux.md#install-node-exporter)” section in the cloned repository, enter the command in your Runme cell, and click on run.
24+
25+
![install node exporter](../../static/img/guide-page/runme-install-exporter.png)
26+
27+
Runme uses its [environment variable prompt feature](https://docs.runme.dev/getting-started/features#environment-variable-prompts) to prompt users to enter a value for the version and the platform. Runme will store these values, so you no longer need to enter them when working on this project.
28+
29+
![env prompt for node exporter](../../static/img/guide-page/node-exporter-env-prompt.png)
30+
31+
## Configure Your Node Exporter In Your Runbook
32+
33+
To configure your Node Exporter, you must follow three steps.
34+
35+
Step One: Set Up Node Exporter as a Service
36+
37+
Create a `systemd` service file that ensures the Node Exporter is properly configured as a background service. This will allow it to continuously collect and export system metrics to Prometheus for monitoring and analysis. To do this, navigate to the “[Setup Node Exporter as a Service](https://github.com/stateful/blog-examples/blob/main/kubernetes/monitoring-stack/linux.md#setup-node-exporter-as-a-service)” section in your cloned repository and run the command in your Runme cell.
38+
39+
```sh
40+
cat <<EOF > sudo tee /etc/systemd/system/node_exporter.service > /dev/null
41+
[Unit]
42+
Description=Prometheus Node Exporter
43+
After=network.target
44+
45+
[Service]
46+
ExecStart=/usr/local/bin/node_exporter
47+
48+
[Install]
49+
WantedBy=default.target
50+
51+
EOF
52+
53+
```
54+
55+
**Output**:
56+
57+
![Node exporter service](../../static/img/guide-page/create-node-exporter-service.png)
58+
59+
Step Two: Run Node Exporter as a Service
60+
61+
In this step, you are required to run your Node Exporter service, check its status, and restart it if necessary. To do this, navigate to the “[Run Node Exporter as a Service](https://github.com/stateful/blog-examples/blob/main/kubernetes/monitoring-stack/linux.md#run-node-exporter-as-a-service)” section and run the command in your Runme cell.
62+
63+
```sh
64+
sudo cp -rf ${PWD}/node_exporter/node_exporter.service /etc/systemd/system/
65+
66+
sudo systemctl daemon-reload
67+
68+
sudo systemctl enable node_exporter
69+
echo "node exporter enable"
70+
71+
sudo systemctl start node_exporter
72+
echo "node_exporter has started."
73+
74+
75+
sudo systemctl status node_exporter
76+
77+
sudo systemctl restart node_exporter
78+
```
79+
80+
**Output**:
81+
82+
![node exporter service](../../static/img/guide-page/runme-node-exporter-service.png)
83+
84+
## Install Prometheus
85+
86+
In a monitoring stack, Prometheus gathers metrics, monitors system and application health, generates alerts based on a predefined rule, and provides insights into system and application performance and availability.
87+
88+
To install Prometheus in Runme, navigate to the “[Install Prometheus](https://github.com/stateful/blog-examples/blob/main/kubernetes/monitoring-stack/linux.md#install-prometheus)” section in your cloned repository, enter and run the command in your Runme cell.
89+
90+
![Install prometheus](../../static/img/guide-page/install-promtheus.png)
91+
92+
Runme will leverage its environment prompt feature to prompt you to input the version of Prometheus you want to install. Once you input the version, you will have an output similar to the one above.
93+
94+
## Configure your Prometheus
95+
96+
To configure your Prometheus, you will be required to follow three steps:
97+
98+
Step One: Setup your Prometheus configuration
99+
Create a Prometheus configuration file that specifies how Prometheus should collect metrics from the Node Exporter. To do this, navigate to the section on “[Setting up Prometheus Configuration](https://github.com/stateful/blog-examples/blob/main/kubernetes/monitoring-stack/linux.md#setup-your-prometheus-configuration)”, enter the command, and run it in your Runme cell.
100+
101+
```sh
102+
cat <<EOF > ${PWD}/prometheus/prometheus.yml
103+
global:
104+
scrape_interval: 15s
105+
evaluation_interval: 15s
106+
scrape_configs:
107+
- job_name: 'node_'
108+
metrics_path: /metrics
109+
static_configs:
110+
- targets:
111+
- 10.90.2.1:9116
112+
EOF
113+
```
114+
115+
**Output**:
116+
117+
![promtheus yaml file](../../static/img/guide-page/runme-promtheus-yaml-file.png)
118+
119+
Step Two: Set up Prometheus as a service
120+
Create a `systemd` service file for the Prometheus Agent Mode, which will facilitate federation and data collection from multiple Prometheus instances or remote targets. To do this, navigate to the “[Setting up prometheus as a Service](https://github.com/stateful/blog-examples/blob/main/kubernetes/monitoring-stack/linux.md#setup-prometheus-as-a-service)” section, enter the command, and run it in your Runme cell.
121+
122+
```sh
123+
cat <<EOF > ${PWD}/prometheus/prometheus.service
124+
[Unit]
125+
Description=Prometheus Agent Mode
126+
After=network-online.target
127+
[Service]
128+
User=${USER}
129+
WorkingDirectory=${PWD}
130+
ExecStart=${PWD}/prometheus/prometheus --config.file=${PWD}/prometheus/prometheus.yml --enable-feature=agent
131+
[Install]
132+
WantedBy=multi-user.target
133+
EOF
134+
```
135+
136+
**Output**:
137+
138+
![prometheus service](../../static/img/guide-page/create-promtheus-service.png)
139+
140+
Step Three: Run Prometheus as a Service
141+
Now, run Prometheus as a service. To do this, navigate to the “[Run Prometheus as a Service](https://github.com/stateful/blog-examples/blob/main/kubernetes/monitoring-stack/linux.md#run-prometheus-as-a-service)” section, enter the command, and run it in your Runme cell.
142+
143+
![prometheus](../../static/img/guide-page/prometheus-service-runme.png)
144+
145+
Step four: Open the app
146+
147+
Run the code below in your Runme cell, it will open the prometheus User Interface page.
148+
149+
```sh
150+
open http://localhost:9090
151+
```
152+
153+
## Install Grafana
154+
155+
Grafana provides a user-friendly interface for visualizing and analyzing metrics, logs, and other monitoring data in your monitoring stack. To install Grafana for your monitoring stack, navigate to the “[Install Grafana](https://github.com/stateful/blog-examples/blob/main/kubernetes/monitoring-stack/linux.md#install-grafana)” section and run the command in your Runme cell.
156+
157+
![Install Grafaba](../../static/img/guide-page/install-grafana-runme.png)
158+
159+
Open the App:
160+
161+
You installed Grafana on your local machine using Runme in the previous step. Now, you need to open the Grafana user interface on your local machine. To do this, enter the command below in your Runme cell and run the command.
162+
163+
```sh
164+
open http://localhost:3000
165+
```
166+
167+
## Install Alertmanager
168+
169+
An Alertmanager is a component of a monitoring stack that handles alerts sent by monitoring tools like Prometheus. It is responsible for grouping, deduplication, and routing alerts to the appropriate recipients. To install an Alertmanager and make it a part of your monitoring stack, navigate to the “[Install Alertmanager](https://github.com/stateful/blog-examples/blob/main/kubernetes/monitoring-stack/linux.md#install-alert-manager)” section in the cloned repository, enter the command in your Runme cell, and run it.
170+
171+
![Install Alertmanager](../../static/img/guide-page/alertmanager-runme.png)
172+
173+
You can edit your `alertmanager.yml` file to define the alerting configurations, notification integrations, and routing rules. To do that, run this command in your Runme cell `nano /etc/alertmanager/alertmanager.yml`
174+
175+
## Configure and Run Your Alertmanager
176+
177+
You will follow three steps to configure and run your Alertmanager.
178+
179+
Step One: Set Up Alertmanager as a Service
180+
Create a `systemd` service file for Alertmanager, specify its description, user-startup command, and target for activation. To do this, navigate to the “[Setup Alertmanager as a Service](https://github.com/stateful/blog-examples/blob/main/kubernetes/monitoring-stack/linux.md#setup-alert-manager-as-a-service)” section, enter the command, and run it in your Runme cell.
181+
182+
![alertmanager](../../static/img/guide-page/Alertmanager.service.png)
183+
184+
Step Two: Run Alertmanager as a Service
185+
Now, you can run your Alertmanager as a service. To do this, navigate to the “[Run Alert as a Service](https://github.com/stateful/blog-examples/blob/main/kubernetes/monitoring-stack/linux.md#run-alert-manager-as-a-service)” section, enter the command in your Runme cell, and run it.
186+
187+
![alertmanager-service](../../static/img/guide-page/runme-alertmanager.png)
188+
189+
Step Three: Open the app
190+
191+
To open the Alertmanager page on your local machine, run the command below in your Runme cell.
192+
193+
```sh
194+
open http://localhost:9093
195+
```
196+
197+
## Why use Runme
198+
199+
Rather than having your codes, commands, or processes in separate files or performing a task repeatedly, Runme enables you to have everything inside your Markdown file, which can be automated whenever you need to run this process.
200+
Some key features of Runme that make it a choice platform for your monitoring stack include:
201+
202+
- Environment Variable Prompts
203+
As you can see from the procedure above, the [environment variable prompt](https://docs.runme.dev/getting-started/features#environment-variable-prompts) is one feature that makes it a choice platform for this task. This feature comes in handy when your runbooks need user-specific values. It allows you to input values directly within your notebook environment, thus making your task execution more efficient.
204+
- Run Sections
205+
Runme makes [running the script by section](https://docs.runme.dev/configuration/cellsection) possible. For example, in your monitoring-stack notebook, you can choose to run each section (“Node Exporter,” “Prometheus,” “Grafana”) rather than individual cells. This feature makes running this task easier and faster.
206+
- Auto-Save
207+
Runme makes saving your outputs easier without manual intervention by triggering the [auto-save feature](https://docs.runme.dev/configuration/auto-save). This way, you can focus on your task and run your commands without worrying about losing your outputs.
208+
- Share Runbook With Members of Your Team
209+
Runme makes sharing of outputs from an executed cell with team members easy. You only need to leverage Runme’s autosave feature to save your output, and you have unlocked the access to share that output with your team members.
210+
211+
These are just a few features of Runme. We continually work to improve your experience with Runme by providing you with more features and updates to enhance your documentation and automation processes. To explore other features of Runme, see the [Runme guide](https://docs.runme.dev/) for comprehensive details.
159 KB
Loading
159 KB
Loading
341 KB
Loading
303 KB
Loading
73.9 KB
Loading
158 KB
Loading
107 KB
Loading
117 KB
Loading

0 commit comments

Comments
 (0)