Skip to content

Commit

Permalink
[DEV-000] node-exporter 설치를 위한 compose 스크립트 작성
Browse files Browse the repository at this point in the history
  • Loading branch information
wonjunYou committed Sep 30, 2024
1 parent e722307 commit 016dcb7
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 17 deletions.
9 changes: 2 additions & 7 deletions .github/workflows/prod-server-deployer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: prod-server-deployer
on:
push:
branches:
- main
- chore/DEV-77
jobs:
build:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -53,6 +53,7 @@ jobs:
cp build/libs/*.jar deploy/application.jar
cp Procfile deploy/Procfile
cp -r promtail deploy/promtail
cp -r nodeexporter deploy/nodeexporter
cp -r .ebextensions deploy/.ebextensions
cp -r .platform deploy/.platform
cd deploy && zip -r deploy.zip .
Expand All @@ -72,9 +73,3 @@ jobs:

- name: Test with Gradle
run: ./gradlew test --no-daemon

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
file: ./build/reports/jacoco/test/jacocoTestReport.xml
13 changes: 13 additions & 0 deletions nodeexporter/node-exporter-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: '3.8'

services:
node-exporter:
image: quay.io/prometheus/node-exporter:latest
container_name: node-exporter
restart: always
network_mode: "host"
pid: "host"
volumes:
- "/:/host:ro,rslave"
command:
- '--path.rootfs=/host'
1 change: 0 additions & 1 deletion promtail/promtail-docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
version: '3'

services:

promtail:
image: grafana/promtail:2.9.1
container_name: promtail
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,30 @@
package ddingdong.ddingdongBE.common.runner;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Component;

import java.io.BufferedReader;
import java.io.InputStreamReader;

@Component
@Profile("prod")
@Slf4j
public class PromtailDockerComposeRunner implements ApplicationRunner {
public class MonitoringApplicationRunner implements ApplicationRunner {

@Override
public void run(ApplicationArguments args) throws Exception {
log.info("Running PromtailDockerComposeRunner");
log.info("Running Promtail & Node Exporter");

ProcessBuilder processBuilder = new ProcessBuilder();
processBuilder.command("docker-compose", "-f", "/var/app/current/promtail/promtail-docker-compose.yml", "up", "-d");
processBuilder.command(
"docker-compose",
"-f", "/var/app/current/promtail/promtail-docker-compose.yml",
"-f", "/var/app/current/nodeexporter/node-exporter-compose.yml",
"up",
"-d"
);

Process process = processBuilder.start();

Expand All @@ -40,9 +45,9 @@ public void run(ApplicationArguments args) throws Exception {
int exitCode = process.waitFor();
if (exitCode == 0) {
log.info("Promtail started successfully using Docker Compose.");
log.info("promtial is tracking info level log");
log.warn("promtial is tracking warn level log");
log.error("promtial is tracking error level log");
log.info("promtail is tracking info level log");
log.warn("promtail is tracking warn level log");
log.error("promtail is tracking error level log");
} else {
log.error("Failed to start Promtail. Exit code: {}", exitCode);
}
Expand Down

0 comments on commit 016dcb7

Please sign in to comment.