Skip to content

Commit 03b67a3

Browse files
pfrcksAmol Agrawal
and
Amol Agrawal
authored
Telegraf agent config for DS/RS (#847)
* add telegraf config options to configmap Co-authored-by: Amol Agrawal <[email protected]>
1 parent 811d42d commit 03b67a3

File tree

7 files changed

+131
-10
lines changed

7 files changed

+131
-10
lines changed

Documentation/AgentSettings/ReadMe.md

+18-1
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,26 @@ Note that this can only be achieved using helm chart today.
1818
```
1919
agent-settings: |-
2020
# prometheus scrape fluent bit settings for high scale
21-
# buffer size should be greater than or equal to chunk size else we set it to chunk size.
21+
# buffer size should be greater than or equal to chunk size else we set it to chunk size.
22+
# settings scoped to prometheus sidecar container. all values in mb
2223
[agent_settings.prometheus_fbit_settings]
2324
tcp_listener_chunk_size = 10
2425
tcp_listener_buffer_size = 10
2526
tcp_listener_mem_buf_limit = 200
27+
28+
# prometheus scrape fluent bit settings for high scale
29+
# buffer size should be greater than or equal to chunk size else we set it to chunk size.
30+
# settings scoped to daemonset container. all values in mb
31+
# [agent_settings.node_prometheus_fbit_settings]
32+
# tcp_listener_chunk_size = 1
33+
# tcp_listener_buffer_size = 1
34+
# tcp_listener_mem_buf_limit = 10
35+
36+
# prometheus scrape fluent bit settings for high scale
37+
# buffer size should be greater than or equal to chunk size else we set it to chunk size.
38+
# settings scoped to replicaset container. all values in mb
39+
# [agent_settings.cluster_prometheus_fbit_settings]
40+
# tcp_listener_chunk_size = 1
41+
# tcp_listener_buffer_size = 1
42+
# tcp_listener_mem_buf_limit = 10
2643
```

build/common/installer/scripts/tomlparser-agent-config.rb

+83
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,21 @@
5757
@fbitTailMemBufLimitMBs = 0
5858
@fbitTailIgnoreOlder = ""
5959

60+
# Checking to see if this is the daemonset or replicaset to parse config accordingly
61+
@controllerType = ENV["CONTROLLER_TYPE"]
62+
@daemonset = "daemonset"
63+
# Checking to see if container is not prometheus sidecar.
64+
# CONTAINER_TYPE is populated only for prometheus sidecar container.
65+
@containerType = ENV["CONTAINER_TYPE"]
66+
67+
@promFbitChunkSize = 0
68+
@promFbitBufferSize = 0
69+
@promFbitMemBufLimit = 0
70+
71+
@promFbitChunkSizeDefault = "32k" #kb
72+
@promFbitBufferSizeDefault = "64k" #kb
73+
@promFbitMemBufLimitDefault = "10m" #mb
74+
6075
def is_number?(value)
6176
true if Integer(value) rescue false
6277
end
@@ -178,6 +193,35 @@ def populateSettingValuesFromConfigMap(parsedConfig)
178193
end
179194
end
180195
end
196+
197+
prom_fbit_config = nil
198+
if !@controllerType.nil? && !@controllerType.empty? && @controllerType.strip.casecmp(@daemonset) == 0 && @containerType.nil?
199+
prom_fbit_config = parsedConfig[:agent_settings][:node_prometheus_fbit_settings]
200+
elsif !@controllerType.nil? && !@controllerType.empty? && @controllerType.strip.casecmp(@daemonset) != 0
201+
prom_fbit_config = parsedConfig[:agent_settings][:cluster_prometheus_fbit_settings]
202+
end
203+
204+
if !prom_fbit_config.nil?
205+
chunk_size = prom_fbit_config[:tcp_listener_chunk_size]
206+
if !chunk_size.nil? && is_number?(chunk_size) && chunk_size.to_i > 0
207+
@promFbitChunkSize = chunk_size.to_i
208+
puts "Using config map value: AZMON_FBIT_CHUNK_SIZE = #{@promFbitChunkSize.to_s + "m"}"
209+
end
210+
buffer_size = prom_fbit_config[:tcp_listener_buffer_size]
211+
if !buffer_size.nil? && is_number?(buffer_size) && buffer_size.to_i > 0
212+
@promFbitBufferSize = buffer_size.to_i
213+
puts "Using config map value: AZMON_FBIT_BUFFER_SIZE = #{@promFbitBufferSize.to_s + "m"}"
214+
if @promFbitBufferSize < @promFbitChunkSize
215+
@promFbitBufferSize = @promFbitChunkSize
216+
puts "Setting Fbit buffer size equal to chunk size since it is set to less than chunk size - AZMON_FBIT_BUFFER_SIZE = #{@promFbitBufferSize.to_s + "m"}"
217+
end
218+
end
219+
mem_buf_limit = prom_fbit_config[:tcp_listener_mem_buf_limit]
220+
if !mem_buf_limit.nil? && is_number?(mem_buf_limit) && mem_buf_limit.to_i > 0
221+
@promFbitMemBufLimit = mem_buf_limit.to_i
222+
puts "Using config map value: AZMON_FBIT_MEM_BUF_LIMIT = #{@promFbitMemBufLimit.to_s + "m"}"
223+
end
224+
end
181225
end
182226
rescue => errorStr
183227
puts "config::error:Exception while reading config settings for agent configuration setting - #{errorStr}, using defaults"
@@ -226,6 +270,24 @@ def populateSettingValuesFromConfigMap(parsedConfig)
226270
file.write("export FBIT_TAIL_IGNORE_OLDER=#{@fbitTailIgnoreOlder}\n")
227271
end
228272

273+
if @promFbitChunkSize > 0
274+
file.write("export AZMON_FBIT_CHUNK_SIZE=#{@promFbitChunkSize.to_s + "m"}\n")
275+
else
276+
file.write("export AZMON_FBIT_CHUNK_SIZE=#{@promFbitChunkSizeDefault}\n")
277+
end
278+
279+
if @promFbitBufferSize > 0
280+
file.write("export AZMON_FBIT_BUFFER_SIZE=#{@promFbitBufferSize.to_s + "m"}\n")
281+
else
282+
file.write("export AZMON_FBIT_BUFFER_SIZE=#{@promFbitBufferSizeDefault}\n")
283+
end
284+
285+
if @promFbitMemBufLimit > 0
286+
file.write("export AZMON_FBIT_MEM_BUF_LIMIT=#{@promFbitMemBufLimit.to_s + "m"}\n")
287+
else
288+
file.write("export AZMON_FBIT_MEM_BUF_LIMIT=#{@promFbitMemBufLimitDefault}\n")
289+
end
290+
229291
# Close file after writing all environment variables
230292
file.close
231293
else
@@ -262,6 +324,27 @@ def get_command_windows(env_variable_name, env_variable_value)
262324
commands = get_command_windows("FBIT_TAIL_IGNORE_OLDER", @fbitTailIgnoreOlder)
263325
file.write(commands)
264326
end
327+
if @promFbitChunkSize > 0
328+
commands = get_command_windows("AZMON_FBIT_CHUNK_SIZE", @promFbitChunkSize.to_s + "m")
329+
file.write(commands)
330+
else
331+
commands = get_command_windows("AZMON_FBIT_CHUNK_SIZE", @promFbitChunkSizeDefault)
332+
file.write(commands)
333+
end
334+
if @promFbitBufferSize > 0
335+
commands = get_command_windows("AZMON_FBIT_BUFFER_SIZE", @promFbitBufferSize.to_s + "m")
336+
file.write(commands)
337+
else
338+
commands = get_command_windows("AZMON_FBIT_BUFFER_SIZE", @promFbitBufferSizeDefault)
339+
file.write(commands)
340+
end
341+
if @promFbitMemBufLimit > 0
342+
commands = get_command_windows("AZMON_FBIT_MEM_BUF_LIMIT", @promFbitMemBufLimit.to_s + "m")
343+
file.write(commands)
344+
else
345+
commands = get_command_windows("AZMON_FBIT_MEM_BUF_LIMIT", @promFbitMemBufLimitDefault)
346+
file.write(commands)
347+
end
265348
# Close file after writing all environment variables
266349
file.close
267350
puts "****************End Config Processing********************"

build/linux/installer/conf/td-agent-bit-rs.conf

+3-3
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@
4141
Tag oms.container.perf.telegraf.*
4242
Listen 0.0.0.0
4343
Port 25226
44-
Chunk_Size 32
45-
Buffer_Size 64
46-
Mem_Buf_Limit 10m
44+
Chunk_Size ${AZMON_FBIT_CHUNK_SIZE}
45+
Buffer_Size ${AZMON_FBIT_BUFFER_SIZE}
46+
Mem_Buf_Limit ${AZMON_FBIT_MEM_BUF_LIMIT}
4747

4848
[OUTPUT]
4949
Name oms

build/linux/installer/conf/td-agent-bit.conf

+3-3
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@
7373
Tag oms.container.perf.telegraf.*
7474
Listen 0.0.0.0
7575
Port 25226
76-
Chunk_Size 32
77-
Buffer_Size 64
78-
Mem_Buf_Limit 5m
76+
Chunk_Size ${AZMON_FBIT_CHUNK_SIZE}
77+
Buffer_Size ${AZMON_FBIT_BUFFER_SIZE}
78+
Mem_Buf_Limit ${AZMON_FBIT_MEM_BUF_LIMIT}
7979

8080
[FILTER]
8181
Name grep

build/windows/installer/conf/fluent-bit.conf

+3-3
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@
4646
Tag oms.container.perf.telegraf.*
4747
Listen 0.0.0.0
4848
Port 25229
49-
Chunk_Size 32
50-
Buffer_Size 64
51-
Mem_Buf_Limit 5m
49+
Chunk_Size ${AZMON_FBIT_CHUNK_SIZE}
50+
Buffer_Size ${AZMON_FBIT_BUFFER_SIZE}
51+
Mem_Buf_Limit ${AZMON_FBIT_MEM_BUF_LIMIT}
5252

5353
[FILTER]
5454
Name grep

kubernetes/container-azm-ms-agentconfig.yaml

+17
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,28 @@ data:
148148
agent-settings: |-
149149
# prometheus scrape fluent bit settings for high scale
150150
# buffer size should be greater than or equal to chunk size else we set it to chunk size.
151+
# settings scoped to prometheus sidecar container. all values in mb
151152
[agent_settings.prometheus_fbit_settings]
152153
tcp_listener_chunk_size = 10
153154
tcp_listener_buffer_size = 10
154155
tcp_listener_mem_buf_limit = 200
155156
157+
# prometheus scrape fluent bit settings for high scale
158+
# buffer size should be greater than or equal to chunk size else we set it to chunk size.
159+
# settings scoped to daemonset container. all values in mb
160+
# [agent_settings.node_prometheus_fbit_settings]
161+
# tcp_listener_chunk_size = 1
162+
# tcp_listener_buffer_size = 1
163+
# tcp_listener_mem_buf_limit = 10
164+
165+
# prometheus scrape fluent bit settings for high scale
166+
# buffer size should be greater than or equal to chunk size else we set it to chunk size.
167+
# settings scoped to replicaset container. all values in mb
168+
# [agent_settings.cluster_prometheus_fbit_settings]
169+
# tcp_listener_chunk_size = 1
170+
# tcp_listener_buffer_size = 1
171+
# tcp_listener_mem_buf_limit = 10
172+
156173
# The following settings are "undocumented", we don't recommend uncommenting them unless directed by Microsoft.
157174
# They increase the maximum stdout/stderr log collection rate but will also cause higher cpu/memory usage.
158175
## Ref for more details about Ignore_Older - https://docs.fluentbit.io/manual/v/1.7/pipeline/inputs/tail

source/plugins/go/src/telemetry.go

+4
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,10 @@ func SendContainerLogPluginMetrics(telemetryPushIntervalProperty string) {
194194
if fbitTailMemBufLimitMBs != "" {
195195
telemetryDimensions["FbitMemBufLimitSizeMBs"] = fbitTailMemBufLimitMBs
196196
}
197+
telemetryDimensions["PromFbitChunkSize"] = os.Getenv("AZMON_FBIT_CHUNK_SIZE")
198+
telemetryDimensions["PromFbitBufferSize"] = os.Getenv("AZMON_FBIT_BUFFER_SIZE")
199+
telemetryDimensions["PromFbitMemBufLimit"] = os.Getenv("AZMON_FBIT_MEM_BUF_LIMIT")
200+
197201
SendEvent(eventNameDaemonSetHeartbeat, telemetryDimensions)
198202
flushRateMetric := appinsights.NewMetricTelemetry(metricNameAvgFlushRate, flushRate)
199203
TelemetryClient.Track(flushRateMetric)

0 commit comments

Comments
 (0)