add grafana loki config
This commit is contained in:
6
pom.xml
6
pom.xml
@@ -169,6 +169,12 @@
|
|||||||
<artifactId>spring-boot-starter-mail</artifactId>
|
<artifactId>spring-boot-starter-mail</artifactId>
|
||||||
<version>3.1.5</version>
|
<version>3.1.5</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!-- Maven -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.loki4j</groupId>
|
||||||
|
<artifactId>loki-logback-appender</artifactId>
|
||||||
|
<version>2.0.1</version> <!-- Use the latest version -->
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package zw.qantra.tm.domain.controllers;
|
package zw.qantra.tm.domain.controllers;
|
||||||
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.security.core.Authentication;
|
import org.springframework.security.core.Authentication;
|
||||||
@@ -19,6 +21,19 @@ public class TestController {
|
|||||||
private final EmailService emailService;
|
private final EmailService emailService;
|
||||||
private final TransactionService transactionService;
|
private final TransactionService transactionService;
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(TestController.class);
|
||||||
|
|
||||||
|
@GetMapping("/test-logs")
|
||||||
|
public String testLogs() {
|
||||||
|
logger.trace("This is a TRACE log");
|
||||||
|
logger.debug("This is a DEBUG log");
|
||||||
|
logger.info("This is an INFO log");
|
||||||
|
logger.warn("This is a WARN log");
|
||||||
|
logger.error("This is an ERROR log");
|
||||||
|
|
||||||
|
return "Logs sent to OpenTelemetry!";
|
||||||
|
}
|
||||||
|
|
||||||
@PostMapping("/dbtest")
|
@PostMapping("/dbtest")
|
||||||
public ResponseEntity<Object> dbtest(@RequestBody Transaction transaction) {
|
public ResponseEntity<Object> dbtest(@RequestBody Transaction transaction) {
|
||||||
transactionService.save(transaction);
|
transactionService.save(transaction);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
spring.application.name=tm
|
spring.application.name=qpay-tm
|
||||||
debug=false
|
debug=false
|
||||||
|
|
||||||
logging.level.org.springframework.boot.autoconfigure=INFO
|
logging.level.org.springframework.boot.autoconfigure=INFO
|
||||||
@@ -70,3 +70,8 @@ powertel.clientid=zesa_prepaid_usd
|
|||||||
|
|
||||||
ecocash.apikey=OUzGezwTgktLg_9v0I48I6WUM4LVLGFl
|
ecocash.apikey=OUzGezwTgktLg_9v0I48I6WUM4LVLGFl
|
||||||
ecocash.url=https://developers.ecocash.co.zw/api/ecocash_pay/api/v2/payment/instant/c2b/sandbox
|
ecocash.url=https://developers.ecocash.co.zw/api/ecocash_pay/api/v2/payment/instant/c2b/sandbox
|
||||||
|
|
||||||
|
management.tracing.enabled=true
|
||||||
|
management.tracing.sampling.probability=1.0
|
||||||
|
management.otlp.tracing.endpoint=http://62.171.179.108:10428/insert/opentelemetry/v1/traces
|
||||||
|
management.otlp.logging.endpoint=http://62.171.179.108:9428/insert/opentelemetry/v1/logs
|
||||||
|
|||||||
@@ -26,14 +26,31 @@
|
|||||||
</encoder>
|
</encoder>
|
||||||
</appender>
|
</appender>
|
||||||
|
|
||||||
|
<appender name="LOKI" class="com.github.loki4j.logback.Loki4jAppender">
|
||||||
|
<labels>
|
||||||
|
app=qpay-tm
|
||||||
|
host=${HOSTNAME}
|
||||||
|
</labels>
|
||||||
|
<http>
|
||||||
|
<url>http://62.171.179.108:3100/loki/api/v1/push</url> <!-- Replace with your Loki URL -->
|
||||||
|
</http>
|
||||||
|
<format>
|
||||||
|
<message>
|
||||||
|
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level [%thread] %logger{36} - %msg%n</pattern>
|
||||||
|
</message>
|
||||||
|
</format>
|
||||||
|
</appender>
|
||||||
|
|
||||||
<!-- Root logger configuration -->
|
<!-- Root logger configuration -->
|
||||||
<root level="INFO">
|
<root level="INFO">
|
||||||
|
<appender-ref ref="LOKI"/>
|
||||||
<appender-ref ref="CONSOLE" />
|
<appender-ref ref="CONSOLE" />
|
||||||
<appender-ref ref="FILE" />
|
<appender-ref ref="FILE" />
|
||||||
</root>
|
</root>
|
||||||
|
|
||||||
<!-- Specific logger for your application -->
|
<!-- Specific logger for your application -->
|
||||||
<logger name="zw.qantra.tm" level="INFO" additivity="false">
|
<logger name="zw.qantra.tm" level="INFO" additivity="false">
|
||||||
|
<appender-ref ref="LOKI"/>
|
||||||
<appender-ref ref="CONSOLE" />
|
<appender-ref ref="CONSOLE" />
|
||||||
<appender-ref ref="FILE" />
|
<appender-ref ref="FILE" />
|
||||||
</logger>
|
</logger>
|
||||||
|
|||||||
Reference in New Issue
Block a user