Skip to content

Commit 0e7dada

Browse files
committed
Modify configurations in the logging module
1 parent c6d29d1 commit 0e7dada

File tree

3 files changed

+178
-49
lines changed

3 files changed

+178
-49
lines changed

nomad/origin/logs-collector.hcl

Lines changed: 66 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ job "logs-collector" {
3939
config {
4040
network_mode = "host"
4141
image = "timberio/vector:0.34.X-alpine"
42-
42+
auth_soft_fail = true
4343
ports = [
4444
"health",
4545
"logs",
@@ -72,30 +72,77 @@ data_dir = "alloc/data/vector/"
7272
enabled = true
7373
address = "0.0.0.0:44313"
7474
75-
[sources.envd]
75+
[sources.http_server]
7676
type = "http_server"
7777
address = "0.0.0.0:30006"
78-
encoding = "json"
78+
encoding = "ndjson"
7979
path_key = "_path"
8080
81-
[transforms.add_source_envd]
81+
[transforms.add_source_http_server]
8282
type = "remap"
83-
inputs = ["envd"]
83+
inputs = ["http_server"]
8484
source = """
8585
del(."_path")
86-
.service = "envd"
8786
.sandboxID = .instanceID
87+
.timestamp = parse_timestamp(.timestamp, format: "%+") ?? now()
88+
# Normalize keys
89+
if exists(.sandbox_id) {
90+
.sandboxID = .sandbox_id
91+
}
92+
if exists(.build_id) {
93+
.buildID = .build_id
94+
}
95+
if exists(.env_id) {
96+
.envID = .env_id
97+
}
98+
if exists(.team_id) {
99+
.teamID = .team_id
100+
}
101+
if exists(."template.id") {
102+
.templateID = ."template.id"
103+
del(."template.id")
104+
}
105+
if exists(."sandbox.id") {
106+
.sandboxID = ."sandbox.id"
107+
del(."sandbox.id")
108+
}
109+
if exists(."build.id") {
110+
.buildID = ."build.id"
111+
del(."build.id")
112+
}
113+
if exists(."env.id") {
114+
.envID = ."env.id"
115+
del(."env.id")
116+
}
117+
if exists(."team.id") {
118+
.teamID = ."team.id"
119+
del(."team.id")
120+
}
121+
122+
# Apply defaults if not already set
88123
if !exists(.envID) {
89124
.envID = "unknown"
90125
}
91126
if !exists(.category) {
92127
.category = "default"
93128
}
129+
if !exists(.teamID) {
130+
.teamID = "unknown"
131+
}
132+
if !exists(.sandboxID) {
133+
.sandboxID = "unknown"
134+
}
135+
if !exists(.buildID) {
136+
.buildID = "unknown"
137+
}
138+
if !exists(.service) {
139+
.service = "envd"
140+
}
94141
"""
95142
96143
[transforms.internal_routing]
97144
type = "route"
98-
inputs = [ "add_source_envd" ]
145+
inputs = [ "add_source_http_server" ]
99146
100147
[transforms.internal_routing.route]
101148
internal = '.internal == true'
@@ -107,23 +154,33 @@ source = '''
107154
del(.internal)
108155
'''
109156
157+
# Enable debugging of logs to the console
158+
# [sinks.console_loki]
159+
# type = "console"
160+
# inputs = ["remove_internal"]
161+
# encoding.codec = "json"
162+
110163
[sinks.local_loki_logs]
111164
type = "loki"
112165
inputs = [ "remove_internal" ]
113166
endpoint = "http://loki.service.consul:3100"
114167
encoding.codec = "json"
168+
# This is recommended behavior for Loki 2.4.0 and newer and is default in Vector 0.39.0 and newer
169+
# https://vector.dev/docs/reference/configuration/sinks/loki/#out_of_order_action
170+
# https://vector.dev/releases/0.39.0/
171+
out_of_order_action = "accept"
115172
116173
[sinks.local_loki_logs.labels]
117174
source = "logs-collector"
118175
service = "{{ service }}"
119176
teamID = "{{ teamID }}"
120177
envID = "{{ envID }}"
178+
buildID = "{{ buildID }}"
121179
sandboxID = "{{ sandboxID }}"
122180
category = "{{ category }}"
123181
124-
125182
EOH
126183
}
127184
}
128185
}
129-
}
186+
}

nomad/origin/loki.hcl

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ job "loki" {
2121
path = "/ready"
2222
interval = "20s"
2323
timeout = "2s"
24-
port = "loki"
24+
port = "3100"
2525
}
2626
}
2727

@@ -31,7 +31,7 @@ job "loki" {
3131
config {
3232
network_mode = "host"
3333
image = "grafana/loki:2.9.8"
34-
34+
auth_soft_fail = true
3535
args = [
3636
"-config.file",
3737
"local/loki-config.yml",
@@ -67,38 +67,40 @@ storage_config:
6767
tsdb_shipper:
6868
active_index_directory: /loki/tsdb-shipper-active
6969
cache_location: /loki/tsdb-shipper-cache
70-
cache_ttl: 24h
70+
cache_ttl: 1h
7171
shared_store: aws
7272
7373
chunk_store_config:
7474
chunk_cache_config:
7575
embedded_cache:
7676
enabled: true
77-
max_size_mb: 512
78-
ttl: 1h
77+
max_size_mb: 2048
78+
ttl: 30m
7979
8080
query_range:
8181
align_queries_with_step: true
8282
cache_results: true
83-
max_retries: 5
83+
max_retries: 2
8484
results_cache:
8585
cache:
8686
embedded_cache:
8787
enabled: true
88-
max_size_mb: 256
89-
ttl: 1h
88+
max_size_mb: 2048
89+
ttl: 30m
9090
9191
ingester_client:
9292
grpc_client_config:
9393
max_recv_msg_size: 104857600 # 100 Mb
9494
max_send_msg_size: 104857600 # 100 Mb
9595
9696
ingester:
97-
chunk_idle_period: 30m
97+
chunk_idle_period: 10m
9898
chunk_encoding: snappy
99+
max_chunk_age: 15m
99100
chunk_target_size: 1048576 # 1MB
100101
wal:
101102
dir: /loki/wal
103+
enabled: false
102104
flush_on_shutdown: true
103105
104106
schema_config:
@@ -127,7 +129,8 @@ limits_config:
127129
per_stream_rate_limit: "80MB"
128130
per_stream_rate_limit_burst: "240MB"
129131
max_streams_per_user: 0
130-
max_global_streams_per_user: 10000
132+
split_queries_by_interval: 30m
133+
max_global_streams_per_user: 0
131134
unordered_writes: true
132135
reject_old_samples_max_age: 168h
133136
EOF

0 commit comments

Comments
 (0)