[Elastic] 초간단 모니터링 시스템 만들기
Elastic 2021. 9. 29. 17:54구성요소)
- Elasticsearch
- Kibana
- Elastic Agents
Basic 용으로 Security Disabled 하고 사용 합니다. (Security 적용 하실 분은 API Key 생성과 User/Password 구성 하시면 됩니다.)
Elasticsearch + Kibana Security Disabled)
- elasticsearch.yml
- kibana.yml
xpack.security.enabled: false
Elastic Agents 설치)
https://www.elastic.co/guide/en/fleet/current/elastic-agent-installation.html
Standalone 으로 구성하고 설치가 필요한 장비에 설치 하면 됩니다.
(Fleet 구성은 테스트 해보지 않았구요. 필요 시 해보겠습니다.)
$ sudo ./elastic-agent install
EA Start & Stop on Mac)
- Start
$ sudo launchctl load /Library/LaunchDaemons/co.elastic.elastic-agent.plist
- Stop
$ sudo launchctl unload /Library/LaunchDaemons/co.elastic.elastic-agent.plist
Dashboard & Visualize)
Kibana 를 이용하시면 됩니다.
Alert)
이건 Elasticsearch 로 RESTful API 요청해서 Rule 에 따른 알람을 보내면 됩니다.
보통, WAS 로 구현해서 Slack 으로 보내거나, Scheduler 를 이용해서 Script 를 실행시켜 Slack 으로 보내거나 합니다.
[SpringBoot] Application 실행 시 특정 작업 실행 시키기
ITWeb/개발일반 2021. 9. 27. 12:39아래 세 가지 방법으로 실행 시킬 수 있습니다.
@Component
public class RunAfterApplicationStart implements ApplicationRunner {
@Override
public void run(ApplicationArguments args) {
// 실행 코드
}
}
@Component
public class RunAfterApplicationStart implements CommandLineRunner {
@Override
public void run(String... args) {
// 실행 코드
}
}
@Component
public class RunAfterApplicationStart {
@EventListener(ApplicationReadyEvent.class)
public void hello() {
// 실행 코드
}
}
[SpringBoot] 깡통 프로젝트 생성 후 실행 시 에러 (Error creating bean with name 'dataSource' defined in class path resource)
ITWeb/개발일반 2021. 9. 16. 17:26springboot 프로젝트 만들어야 할 때 이용 합니다.
필요한 dependency 추가해 주고 로컬로 다운로드 받아 바로 실행 시켜 봅니다.
근데 깡통임에도 불구하고 에러가 발생을 했습니다.
mybatis 를 추가 했을 경우 application.yml 에 datasource 관련 설정을 하지 않게 되면 발생 하는 에러 입니다.
아래와 같이 설정을 추가 하고 build.gradle 에 mysql connector lib 도 추가해 주고 실행 하면 에러가 없어 집니다.
[error logs]
2021-09-16 17:24:18.201 WARN 76669 --- [ restartedMain] ConfigServletWebServerApplicationContext :
Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]:
Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException:
Failed to instantiate [com.zaxxer.hikari.HikariDataSource]:
Factory method 'dataSource' threw exception;
nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException:
Failed to determine a suitable driver class
2021-09-16 17:24:18.205 INFO 76669 --- [ restartedMain] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
[application.yml]
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/...
username: ${USER}
password: ${PASSWORD}
[build.gradle]
implementation group: 'mysql', name: 'mysql-connector-java', version: '8.0.26'
[Gradle] 6.x 에서 7.x 로 넘어 오면서 runtime, compile.
ITWeb/개발일반 2021. 9. 15. 17:51아래와 같이 변경 해서 사용 하면 됩니다.
- Gradle 6.x 에서 Gradle 7.x 로 넘어 오면서 runtime, compile.
[6.x]
task copyDependencies(type: Copy) {
into "$buildDir/libs/deps"
from configurations.runtime
}
[7.x]
task copyDependencies(type: Copy) {
into "$buildDir/libs/deps"
from configurations.runtimeClasspath
}
[6.x]
jar {
manifest {
attributes 'Main-Class': 'Main.class',
'Class-Path': configurations.compile.files.collect { "deps/$it.name" }.join(' ')
}
archiveName 'dictionary.jar'
from {
configurations.runtime.collect { it.isDirectory() ? it : zipTree(it) }
}
}
[7.x]
jar {
manifest {
attributes 'Main-Class': 'Main.class',
'Class-Path': configurations.compileClasspath.files.collect { "deps/$it.name" }.join(' ')
}
archiveName 'dictionary.jar'
}