Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DDING-001] node exporter 설치 및 연결 테스트 #141

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions .github/workflows/prod-server-deployer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ name: prod-server-deployer
on:
push:
branches:
- main
- chore/DDING-001

jobs:
build:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -53,6 +54,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 +74,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-docker-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
ports:
- "9100:9100"
volumes:
- "/:/host:ro,rslave"
command:
- '--path.rootfs=/host'
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public SecurityFilterChain filterChain(HttpSecurity http, JwtAuthService authSer
.permitAll()
.requestMatchers(API_PREFIX + "/admin/**").hasRole("ADMIN")
.requestMatchers(API_PREFIX + "/club/**").hasRole("CLUB")
.requestMatchers(actuatorPath).hasRole("ADMIN")
.requestMatchers(actuatorPath + "/**").permitAll()
.requestMatchers(GET,
API_PREFIX + "/clubs/**",
API_PREFIX + "/notices/**",
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-docker-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
3 changes: 3 additions & 0 deletions src/main/resources/application-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ server:

management:
endpoints:
enabled-by-default: false
web:
exposure:
include: info, health
Expand All @@ -58,3 +59,5 @@ management:
enabled: true
server:
port: 9090
security:
enabled: false
Loading