Skip to content

Commit

Permalink
Merge pull request #92 from resilientdb/grafna
Browse files Browse the repository at this point in the history
Grafna
  • Loading branch information
cjcchen authored Oct 26, 2023
2 parents 8bf935c + 3376ebe commit 5144638
Show file tree
Hide file tree
Showing 6 changed files with 118 additions and 15 deletions.
34 changes: 34 additions & 0 deletions monitoring/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Download Prometheus
wget https://github.com/prometheus/prometheus/releases/download/v2.47.0/prometheus-2.47.0.linux-amd64.tar.gz
tar xvf prometheus-2.47.0.linux-amd64.tar.gz
mv prometheus-2.47.0.linux-amd64 prometheus

# Download node_exporter
wget https://github.com/prometheus/node_exporter/releases/download/v1.6.1/node_exporter-1.6.1.linux-amd64.tar.gz
tar xvf node_exporter-1.6.1.linux-amd64.tar.gz

# Download and Install grafana
wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add -
sudo add-apt-repository "deb https://packages.grafana.com/oss/deb stable main"
sudo apt update
sudo apt install grafana

# Start Prometheus
cp prometheus.yml prometheus/

#Start grafana
sudo service grafana-server start

#Start Prometheus
./prometheus

#Start exporter in each node where the service is running
./node_exporter

#Running Prometheus or Exporter in dark
nohup ./prometheus & 2>&1
nohup ./node_exporter & 2>&1

More details:
https://blog.resilientdb.com/2022/12/06/NexResGrafanaDashboardInstallation.html

55 changes: 55 additions & 0 deletions monitoring/prometheus/prometheus.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# my global config
global:
scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
# scrape_timeout is set to the global default (10s).

# Alertmanager configuration
alerting:
alertmanagers:
- static_configs:
- targets:
# - alertmanager:9093

# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
# - "first_rules.yml"
# - "second_rules.yml"

# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
- job_name: "prometheus"
static_configs:
- targets: ["localhost:9090"]
- job_name: "node_exporter1"
static_configs:
- targets: ["172.31.52.247:9100"]
- job_name: "node_exporter2"
static_configs:
- targets: ["172.31.54.193:9100"]
- job_name: "node_exporter3"
static_configs:
- targets: ["172.31.55.48:9100"]
- job_name: "node_exporter4"
static_configs:
- targets: ["172.31.53.140:9100"]
- job_name: "node_exporter5"
static_configs:
- targets: ["172.31.57.186:9100"]
- job_name: "cpp_client1"
static_configs:
- targets: ["172.31.52.247:8090"]
- job_name: "cpp_client2"
static_configs:
- targets: ["172.31.54.193:8090"]
- job_name: "cpp_client3"
static_configs:
- targets: ["172.31.55.48:8090"]
- job_name: "cpp_client4"
static_configs:
- targets: ["172.31.53.140:8090"]
- job_name: "cpp_client5"
static_configs:
- targets: ["172.31.57.186:8090"]
10 changes: 5 additions & 5 deletions scripts/deploy/config/kv_server.conf
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
iplist=(
172.31.14.56
172.31.5.62
172.31.8.207
172.31.12.105
172.31.3.13
172.31.52.247
172.31.54.193
172.31.55.48
172.31.53.140
172.31.57.186
)

key=~/.ssh/your_key
3 changes: 2 additions & 1 deletion scripts/deploy/script/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ server_path=`echo "$server" | sed 's/:/\//g'`
server_path=${server_path:1}
server_name=`echo "$server" | awk -F':' '{print $NF}'`
server_bin=${server_name}
grafna_port=8090

bin_path=${BAZEL_WORKSPACE_PATH}/bazel-bin/${server_path}
output_path=${script_path}/deploy/config_out
Expand Down Expand Up @@ -102,7 +103,7 @@ for ip in ${deploy_iplist[@]};
do
private_key="cert/node_"${idx}".key.pri"
cert="cert/cert_"${idx}".cert"
run_one_cmd "nohup ./${server_bin} server.config ${private_key} ${cert} > ${server_bin}.log 2>&1 &" &
run_one_cmd "nohup ./${server_bin} server.config ${private_key} ${cert} ${grafna_port} > ${server_bin}.log 2>&1 &" &
((count++))
((idx++))
done
Expand Down
16 changes: 7 additions & 9 deletions service/kv/kv_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,14 @@ int main(int argc, char** argv) {
char* config_file = argv[1];
char* private_key_file = argv[2];
char* cert_file = argv[3];
char* logging_dir = nullptr;

if (argc >= 6) {
logging_dir = argv[5];
}
if (argc == 5){
std::string grafana_port = argv[4];
std::string grafana_address = "0.0.0.0:"+grafana_port;

if (argc >= 5) {
auto monitor_port = Stats::GetGlobalStats(5);
monitor_port->SetPrometheus(argv[4]);
LOG(ERROR) << "prot:" << argv[4];
auto monitor_port = Stats::GetGlobalStats(5);
monitor_port->SetPrometheus(grafana_address);
LOG(ERROR) << "monitoring prot:" << grafana_address;
}

std::unique_ptr<ResDBConfig> config =
Expand All @@ -89,6 +87,6 @@ int main(int argc, char** argv) {
auto server = GenerateResDBServer(
config_file, private_key_file, cert_file,
std::make_unique<KVExecutor>(NewState(cert_file, config_data)),
logging_dir);
nullptr);
server->Run();
}
15 changes: 15 additions & 0 deletions service/tools/kv/server_tools/start_kv_service_monitoring.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
killall -9 kv_service

SERVER_PATH=./bazel-bin/service/kv/kv_service
SERVER_CONFIG=service/tools/config/server/server.config
WORK_PATH=$PWD
CERT_PATH=${WORK_PATH}/service/tools/data/cert/
GRAFANA_PORT=8090

bazel build //service/kv:kv_service $@
nohup $SERVER_PATH $SERVER_CONFIG $CERT_PATH/node1.key.pri $CERT_PATH/cert_1.cert 8090 > server0.log &
nohup $SERVER_PATH $SERVER_CONFIG $CERT_PATH/node2.key.pri $CERT_PATH/cert_2.cert 8091 > server1.log &
nohup $SERVER_PATH $SERVER_CONFIG $CERT_PATH/node3.key.pri $CERT_PATH/cert_3.cert 8092 > server2.log &
nohup $SERVER_PATH $SERVER_CONFIG $CERT_PATH/node4.key.pri $CERT_PATH/cert_4.cert 8093 > server3.log &

nohup $SERVER_PATH $SERVER_CONFIG $CERT_PATH/node5.key.pri $CERT_PATH/cert_5.cert 8094 > client.log &

0 comments on commit 5144638

Please sign in to comment.