add grafana loki config

This commit is contained in:
2025-11-29 19:39:14 +02:00
parent 40f3f1b7f6
commit 43488069e9
4 changed files with 44 additions and 1 deletions

View File

@@ -1,6 +1,8 @@
package zw.qantra.tm.domain.controllers;
import lombok.RequiredArgsConstructor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.Authentication;
@@ -19,6 +21,19 @@ public class TestController {
private final EmailService emailService;
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")
public ResponseEntity<Object> dbtest(@RequestBody Transaction transaction) {
transactionService.save(transaction);

View File

@@ -1,4 +1,4 @@
spring.application.name=tm
spring.application.name=qpay-tm
debug=false
logging.level.org.springframework.boot.autoconfigure=INFO
@@ -70,3 +70,8 @@ powertel.clientid=zesa_prepaid_usd
ecocash.apikey=OUzGezwTgktLg_9v0I48I6WUM4LVLGFl
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

View File

@@ -26,14 +26,31 @@
</encoder>
</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 level="INFO">
<appender-ref ref="LOKI"/>
<appender-ref ref="CONSOLE" />
<appender-ref ref="FILE" />
</root>
<!-- Specific logger for your application -->
<logger name="zw.qantra.tm" level="INFO" additivity="false">
<appender-ref ref="LOKI"/>
<appender-ref ref="CONSOLE" />
<appender-ref ref="FILE" />
</logger>