Skip to content

Commit

Permalink
Merge pull request #42 from sophie0730/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
sophie0730 authored Dec 25, 2023
2 parents f3c3d70 + cd3a62a commit 3a58e7f
Show file tree
Hide file tree
Showing 26 changed files with 1,363 additions and 2,482 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,5 @@ dashboard-graph_example.json
dashboard-table_example.json
server_exporter.js
nginx_exporter.js

out.mjs
148 changes: 140 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
# PulseTracker

This document provides step-by-step instructions to set up PulseTracker on your Linux environment. Please ensure you follow each step carefully for a successfuly installation.

## Prerequisites
- Please install Docker in you Linux Environment.
- You need to install the below Linux command:

Please make sure your Linux environment is prepared before you start the installation process.

1. Docker Installation:

PulseTracker requires Docker. If you haven't installed Docker yet, please follow the instructions provided in the Docker document:

- Please install Docker in you Linux Environment first.
You can refer to the below document for install process.
https://docs.docker.com/engine/install/ubuntu/

- Please install the below Linux command:
```
sudo apt-get update
sudo apt-get install sysstat
Expand All @@ -15,10 +27,14 @@ sudo apt install ntp
sudo systemctl start ntp
sudo systemctl enable ntp
sudo ntpdate -u pool.ntp.org
```

## How to Use
- If you would like to use `nginx_exporter`, please install Nginx in your machine first.

- Please add port 4000, 9100, 9101, 8086 and 6379 in the inbounding rules on the security groups if you are using AWS EC2 services.

## Install

- Download the compressed file from Github releases.
You can refer to Github releases and download your preffered version
```
Expand All @@ -31,11 +47,12 @@ tar xvf [package_name].tar
```

- Use docker compose to setup InfluxDB and Redis
If you have already installed these two services on your machine, you can modify `docker-compose.yml` as you needed.
```
docker compose up
docker compose up -d
```

- Please sign in InfluxDB([YOUR HOST]:8086) to create a bucket and API token. They will be used for storing your data.
- Please sign in InfluxDB([YOUR HOST]:8086) to create a organization, bucket and API token. They will be used for storing your data.

- Edit .env.template according to your InfluxDB settings. Please remember to rename it to .env after editing all the required information.

Expand All @@ -45,9 +62,12 @@ docker compose up

- Execute exporters (system and nginx application)
```
./exporter
./server_exporter
```
```
These two exporters will be running on port 9100 and 9101 by default.
./nginx_exporter
```
These two exporters will be running on port 9100(server) and 9101(nginx) by default.

- Execute PulseTracker server
```
Expand All @@ -56,4 +76,116 @@ These two exporters will be running on port 9100 and 9101 by default.

Now, you are able to use PulseTracker application on your machine.

## Config Files
Please refer to the corresponding examples for each config file.

- docker-compose.yml

If you want to modify Docker setting for InfluxDB or Redis services, please refer to this file.

- Pulse.yml
```
global:
store_timeout: 10 # set store metrices worker every 10 seconds. unit: second
alert_timeout: 10 #set alert worker every 10 seconds. unit: second
# Alertmanager configuration
alerting:
static_configs:
receivers:
- target: "[email protected]" # Set your recepients' email
# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
# The default name of alerting rule file is alert.yml
rule_files:
- "alert.yml"
# If your influxDB or redis are on other ports, please modify the below option
influx_db:
execute_path: "/usr/local/bin/influxd"
port: 8086
redis:
port: 6379
# A scrape configuration containing exactly one endpoint to scrape:
# If your maching is built in other IPs, please replace "localhost" to your IP. e.g. 52.62.225.143:4000
#Please do not modify the first job_name "pulsetracker_server". The default target is [YOUR HOST]:4000
# You can add your servers according to the below format.
scrape_configs:
# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
- job_name: "pulsetracker_server"
scheme: http
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
static_configs:
targets: "localhost:4000"
- job_name: 'system'
scheme: http
static_configs:
targets: "localhost:9100"
metrics_path: '/metrics'
- job_name: 'nginx-application'
scheme: http
static_configs:
targets: "localhost:9101"
metrics_path: '/metrics'
```

- alert.yml
```
groups:
# Please add your alerting rules
- name: # The title of alerting rule
rules:
- alert: # The title of alerting rule
expr: # The alerting rule. Please follow influxDB query.
for: # The duration of
annotations:
summary: # The summary of this rule.
# For example
groups:
- name: server_is_down
rules:
- alert: server_is_down
expr: 'fn: (r) => r.item == "up" and r._value == 0'
for: 15s
annotations:
summary: Server(s) are down.
```

- .env
```
# Please follow the below example
#INFLUXDB_URL based on your host and port
INFLUXDB_URL='http://52.62.225.143:8086'
# ORG and BUCKET based on your setting on InfluxDB
ORG='personal'
BUCKET='pulse_tracker'
# You can named what you want for MEASUREMENT and ALERT_MEASUREMENT
MEASUREMENT='metrices'
ALERT_MEASUREMENT='alert'
# The API token you set on InfluxDB
TOKEN=''
# (optional) If you want to set email and Line message function
# Please use SMTP server (e.g. Mailgun) and Line Notify service
EMAIL_USER='[email protected]'
EMAIL_TOKEN=''
LINE_URL='https://notify-api.line.me/api/notify'
LINE_TOKEN=''
```

- dashboard-table.json and dashboard-graph.json

The json files which store dashboard data. Please do not edit or remove them.

2 changes: 0 additions & 2 deletions server/Exporter-nginx.js

This file was deleted.

2 changes: 0 additions & 2 deletions server/Exporter-server.js

This file was deleted.

42 changes: 0 additions & 42 deletions server/PulseTracker.js

This file was deleted.

5 changes: 1 addition & 4 deletions server/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ app.use('/api/1.0', [fetchRouter, alertRouter, dashboardRouter]);
app.use((req, res) => {
res.status(404).send('PAGE NOT FOUND');
});
// socket io

// socket io
const server = createServer(app);
const io = new Server(server, {
cors: {
Expand All @@ -40,9 +40,6 @@ const io = new Server(server, {
},
allowEIO3: true,
});
// io.on('connection', () => {
// console.log('connected');
// });

export { io };
export default io;
Expand Down
Loading

0 comments on commit 3a58e7f

Please sign in to comment.