Skip to content

Commit 9d6c971

Browse files
authored
Merge pull request #213 from kyuengmanKim/refactor/code-updates
Refactor/log code updates
2 parents e5baf9e + 979e374 commit 9d6c971

File tree

12 files changed

+186
-138
lines changed

12 files changed

+186
-138
lines changed

java-module/ansible/playbooks/install-agent/roles/agent/agent-install-files/cmp-agent/fluent-bit/etc/fluent-bit.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,5 @@
5454
name loki
5555
host ${LOKI_HOST}
5656
match syslog
57-
labels host=${HOSTNAME}, uuid=${UUID}, credential_id=${credential_id}, cloud_service=${cloud_service}, type=${type}
57+
labels host=${HOSTNAME}, NS_ID=${NS_ID}, MCI_ID=${MCI_ID}, VM_ID=${VM_ID}
5858
label_keys $service, $level, $source

java-module/docker-compose.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ networks:
66

77
volumes:
88
grafana_shared_config:
9+
shared_logs:
910

1011
services:
1112
mc-observability-manager:
@@ -82,6 +83,7 @@ services:
8283
volumes:
8384
- ./mc-o11y-manager/config:/config
8485
- ./mc-o11y-manager/applog:/applog
86+
- shared_logs:/applog/mc-o11y-manager:rw
8587
- grafana_shared_config:/grafana_config:ro
8688
# - ./manager-conf:/etc/mc-observability-agent/conf:rw
8789
healthcheck:
@@ -549,6 +551,7 @@ services:
549551
- OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=${OTEL_EXPORTER_OTLP_TRACES_ENDPOINT:-http://mc-observability-tempo:4318/v1/traces}
550552
volumes:
551553
- ../python/insight/log:/mc-insight/log
554+
- shared_logs:/mc-insight/log:rw
552555
networks:
553556
- internal_network
554557
- external_network
@@ -767,3 +770,33 @@ services:
767770
init: true
768771
networks:
769772
- internal_network
773+
774+
mc-observability-log-collector:
775+
image: fluent/fluent-bit:3.2.4
776+
container_name: mc-observability-log-collector
777+
restart: always
778+
networks:
779+
- internal_network
780+
- external_network
781+
depends_on:
782+
mc-observability-loki:
783+
condition: service_healthy
784+
environment:
785+
- TZ=Asia/Seoul
786+
- LOKI_HOST=mc-observability-loki
787+
- LOKI_PORT=3100
788+
volumes:
789+
- shared_logs:/logs:ro
790+
- ./log-conf/fluent-bit.conf:/fluent-bit/etc/fluent-bit.conf:ro
791+
- ./log-conf/parsers.conf:/fluent-bit/etc/parsers.conf:ro
792+
- ./log-conf/extract_component.lua:/fluent-bit/etc/extract_component.lua:ro
793+
command:
794+
- /fluent-bit/bin/fluent-bit
795+
- -c
796+
- /fluent-bit/etc/fluent-bit.conf
797+
healthcheck:
798+
test: ["CMD-SHELL", "wget --quiet --spider http://127.0.0.1:2020/api/v1/health || exit 1"]
799+
interval: 10s
800+
timeout: 5s
801+
retries: 3
802+
start_period: 10s
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
function extract_component(tag, timestamp, record)
2+
if record["attributes"] and record["attributes"]["component"] then
3+
record["component"] = record["attributes"]["component"]
4+
end
5+
return 1, timestamp, record
6+
end
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
[SERVICE]
2+
flush 5
3+
daemon Off
4+
log_level info
5+
parsers_file /fluent-bit/etc/parsers.conf
6+
HTTP_Server On
7+
HTTP_Listen 0.0.0.0
8+
HTTP_PORT 2020
9+
10+
[INPUT]
11+
name tail
12+
tag mc-observability-manager.logs
13+
path /logs/mc-o11y-manager.log
14+
parser json
15+
read_from_head false
16+
refresh_interval 5
17+
18+
[INPUT]
19+
name tail
20+
tag mc-observability-insight.logs
21+
path /logs/mc-observability-insight.log
22+
parser json
23+
read_from_head false
24+
refresh_interval 5
25+
26+
[FILTER]
27+
Name modify
28+
Match_Regex ^mc-observability-.*\.logs$
29+
Add system mc-observability
30+
31+
[FILTER]
32+
Name lua
33+
Match *
34+
script /fluent-bit/etc/extract_component.lua
35+
call extract_component
36+
37+
[OUTPUT]
38+
name loki
39+
match *
40+
host ${LOKI_HOST}
41+
port ${LOKI_PORT}
42+
label_keys $system, $severity_text, $component
43+
line_format json
44+
auto_kubernetes_labels off
45+
remove_keys component

java-module/log-conf/parsers.conf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[PARSER]
2+
Name json
3+
Format json
4+
Time_Key timestamp
5+
Time_Format %Y-%m-%dT%H:%M:%S.%LZ
6+
Time_Keep On

java-module/mc-o11y-manager/src/main/resources/logback-spring.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<file>${LOG_PATH}/${APPLICATION_NAME}/${LOG_FILE_NAME}.log</file>
2323
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
2424
<pattern>
25-
{"timestamp": "%d{yyyy-MM-dd'T'HH:mm:ss.SSS'Z'}","trace_id": "%X{trace_id}","span_id": "%X{span_id}","trace_flags": "%X{trace_flags}","severity_text": "%level", "attributes": {"component": "%X{component}","code.function": "%C.%M","code.file": "%F", "code.lineno": "%L"},"body": "%message"} \n
25+
{"timestamp": "%d{yyyy-MM-dd'T'HH:mm:ss.SSS'Z'}","trace_id": "%X{trace_id}","span_id": "%X{span_id}","trace_flags": "%X{trace_flags}","severity_text": "%level", "attributes": {"component": "mc-observability-manager","code.function": "%C.%M","code.file": "%F", "code.lineno": "%L"},"body": "%message"} \n
2626
</pattern>
2727
</encoder>
2828
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">

java-module/scripts/init.sh

Lines changed: 0 additions & 61 deletions
This file was deleted.

java-module/scripts/install-manager.sh

Lines changed: 0 additions & 32 deletions
This file was deleted.

python/insight/app/core/mcp/grafana_mcp_context.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,7 @@ async def astart(self):
3535
return self.session
3636

3737
except Exception as e:
38-
logger.error(f"Failed to start Grafana MCP context: {e}")
39-
import traceback
40-
41-
traceback.print_exc()
38+
logger.exception(f"Failed to start Grafana MCP context: {e}")
4239
await self.astop()
4340
raise
4441

python/insight/app/core/mcp/influxdb_mcp_context.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,7 @@ async def astart(self):
3535
return self.session
3636

3737
except Exception as e:
38-
logger.error(f"Failed to start InfluxDB MCP context: {e}")
39-
import traceback
40-
41-
traceback.print_exc()
38+
logger.exception(f"Failed to start InfluxDB MCP context: {e}")
4239
await self.astop()
4340
raise
4441

0 commit comments

Comments
 (0)