-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnode-0-configmap.yaml
667 lines (555 loc) · 23.9 KB
/
node-0-configmap.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
apiVersion: v1
kind: ConfigMap
metadata:
name: node-0-configmap
namespace: astrid-kube
data:
logstash.yml: |
config.reload:
automatic: true
interval: 5s
http.host: "0.0.0.0"
pipelines.yml: |
- pipeline.id: bau
path.config: "/usr/share/logstash/pipeline/polycube_bau.conf"
- pipeline.id: bau_and_warn
path.config: "/usr/share/logstash/pipeline/polycube_bau_and_warn.conf"
- pipeline.id: dns_bau
path.config: "/usr/share/logstash/pipeline/polycube_dns_bau.conf"
- pipeline.id: dns_warn
path.config: "/usr/share/logstash/pipeline/polycube_dns_warn.conf"
polycube_bau.conf: |
input {
http{
host => "127.0.0.1"
port => 30001
}
}
filter {
prune {
whitelist_names => "ingress-metrics"
}
mutate {
add_field => {
"timestamp" => "123456789"
"node_id" => "node1:Genoa RtA"
#"use_case" => [ {
# "id" => "NTP"
# "bau" => [ 0 ]
#} ]
}
}
ruby {
init => '
@old_bau = [0]
@tmp_bau = [0]
'
code => '
bau = []
warn = [ 0 ]
timestamp = 0
event_code = event.get( "ingress-metrics" )
if event_code != nil
event_code.each do |elem|
if elem[ "name" ] == "ntp_packets_total"
@tmp_bau = elem[ "value" ]
bau << ( @tmp_bau[0] - @old_bau[0] )
if bau[0] < 0
bau[0] = 0
end
@old_bau = @tmp_bau
timestamp = elem[ "timestamp" ].to_s
end
end
event.set( "timestamp", timestamp )
event.set( "use_case", [ Hash[ "id", "NTP", "bau", bau, "warn", warn ] ] )
event.remove( "ingress-metrics" )
json_message = event.to_json
new_json_message = "\""
json_message.each_char { |c|
if c == "\""
new_json_message << "\\"
end
new_json_message << c
}
new_json_message << "\""
event.set( "message", new_json_message )
event.set( "host", "" )
else
event.cancel
end
'
}
}
output {
kafka {
codec => plain
topic_id => "AstridProxyReadData"
bootstrap_servers => "kafka-service:9092"
message_key => '"%{[timestamp]}"'
#event['message'] => "event['message']"
}
}
polycube_bau_and_warn.conf : |
input {
http{
host => "127.0.0.1"
port => 30002
}
}
filter {
prune {
whitelist_names => "ingress-metrics"
}
mutate {
add_field => {
"timestamp" => "123456789"
"node_id" => "node1:Genoa RtA"
#"use_case" => [ {
# "id" => "NTP"
# "bau" => [ 0 ]
# "warn" => [ 0 ]
#} ]
}
}
ruby {
init => '
@old_bau = [0]
@tmp_bau = [0]
@old_warn = [0]
@tmp_warn = [0]
'
code => '
bau = []
warn = []
timestamp = 0
event_code = event.get( "ingress-metrics" )
if event_code != nil
event_code.each do |elem|
if elem[ "name" ] == "ntp_packets_total"
@tmp_bau = elem[ "value" ]
bau << ( @tmp_bau[0] - @old_bau[0] )
if bau[0] < 0
bau[0] = 0
end
@old_bau = @tmp_bau
timestamp = elem[ "timestamp" ].to_s
end
if elem[ "name" ] == "ntp_mode_private_packets_total"
@tmp_warn = elem[ "value"]
warn << ( @tmp_warn[0] - @old_warn[0] )
if warn[0] < 0
warn[0] = 0
end
@old_warn = @tmp_warn
timestamp = elem[ "timestamp" ].to_s
end
end
event.set( "timestamp", timestamp )
event.set( "use_case", [ Hash[ "id", "NTP", "bau", bau, "warn", warn ] ] )
event.remove( "ingress-metrics" )
json_message = event.to_json
new_json_message = "\""
json_message.each_char { |c|
if c == "\""
new_json_message << "\\"
end
new_json_message << c
}
new_json_message << "\""
event.set( "message", new_json_message )
event.set( "host", "" )
else
event.cancel
end
'
}
}
output {
kafka {
codec => plain
topic_id => "AstridProxyReadData"
bootstrap_servers => "kafka-service:9092"
message_key => '"%{[timestamp]}"'
#event['message'] => "event['message']"
}
}
polycube_dns_bau.conf: |
input {
http{
host => "127.0.0.1"
port => 30003
}
}
filter {
prune {
whitelist_names => "ingress-metrics"
}
mutate {
add_field => {
"timestamp" => "123456789"
"node_id" => "node1:Genoa RtA"
#"use_case" => [ {
# "id" => "NTP"
# "bau" => [ 0 ]
#} ]
}
}
ruby {
init => '
@old_bau = [0]
@tmp_bau = [0]
'
code => '
bau = []
warn = [ 0 ]
timestamp = 0
event_code = event.get( "ingress-metrics" )
if event_code != nil
event_code.each do |elem|
if elem[ "name" ] == "Total DNS packets"
@tmp_bau = elem[ "value" ]
bau << ( @tmp_bau[0] - @old_bau[0] )
if bau[0] < 0
bau[0] = 0
end
@old_bau = @tmp_bau
timestamp = elem[ "timestamp" ].to_s
end
end
event.set( "timestamp", timestamp )
event.set( "use_case", [ Hash[ "id", "DNS", "bau", bau, "warn", warn ] ] )
event.remove( "ingress-metrics" )
json_message = event.to_json
new_json_message = "\""
json_message.each_char { |c|
if c == "\""
new_json_message << "\\"
end
new_json_message << c
}
new_json_message << "\""
event.set( "message", new_json_message )
event.set( "host", "" )
else
event.cancel
end
'
}
}
output {
kafka {
codec => plain
topic_id => "AstridProxyReadData"
bootstrap_servers => "kafka-service:9092"
message_key => '"%{[timestamp]}"'
#event['message'] => "event['message']"
}
}
polycube_dns_warn.conf : |
input {
http{
host => "127.0.0.1"
port => 30004
}
}
filter {
prune {
whitelist_names => "ingress-metrics"
}
mutate {
add_field => {
"timestamp" => "123456789"
"node_id" => "node1:Genoa RtA"
#"use_case" => [ {
# "id" => "NTP"
# "bau" => [ 0 ]
# "warn" => [ 0 ]
#} ]
}
}
ruby {
init => '
@old_bau = [0]
@tmp_bau = [0]
@old_warn = [0]
@tmp_warn = [0]
'
code => '
bau = []
warn = []
timestamp = 0
event_code = event.get( "ingress-metrics" )
if event_code != nil
event_code.each do |elem|
if elem[ "name" ] == "Total DNS packets"
@tmp_bau = elem[ "value" ]
bau << ( @tmp_bau[0] - @old_bau[0] )
if bau[0] < 0
bau[0] = 0
end
@old_bau = @tmp_bau
timestamp = elem[ "timestamp" ].to_s
end
if elem[ "name" ] == "Total DNS queries of type ANY"
@tmp_warn = elem[ "value"]
warn << ( @tmp_warn[0] - @old_warn[0] )
if warn[0] < 0
warn[0] = 0
end
@old_warn = @tmp_warn
timestamp = elem[ "timestamp" ].to_s
end
end
event.set( "timestamp", timestamp )
event.set( "use_case", [ Hash[ "id", "DNS", "bau", bau, "warn", warn ] ] )
event.remove( "ingress-metrics" )
json_message = event.to_json
new_json_message = "\""
json_message.each_char { |c|
if c == "\""
new_json_message << "\\"
end
new_json_message << c
}
new_json_message << "\""
event.set( "message", new_json_message )
event.set( "host", "" )
else
event.cancel
end
'
}
}
output {
kafka {
codec => plain
topic_id => "AstridProxyReadData"
bootstrap_servers => "kafka-service:9092"
message_key => '"%{[timestamp]}"'
#event['message'] => "event['message']"
}
}
scheduler.sh : |
#!/bin/sh
set -e
polling=$POLLING_TIME
polling_time_file=/usr/share/scheduler/pollingtime.txt
previous_stat=0
ntp_bau_port=30001
ntp_bau_and_warn_port=30002
dns_bau_port=30003
dns_bau_and_warn_port=30004
read_and_send() {
response_dynmon=$(curl -s 'http://localhost:9000/polycube/v1/dynmon' --max-time 2)
for cube in $( echo $response_dynmon | jq '.[] | select( type=="object" ) | .name ' -r )
do
metrics=$(curl -s "http://localhost:9000/polycube/v1/dynmon/${cube}/metrics" --max-time 2 )
map_counter=0
map_type=""
for map in $( echo $metrics | jq '."ingress-metrics"[].name ' | sed "s/\ /-/g" )
do
map_counter=$(( $map_counter + 1 ))
if echo $map | grep -iqF "dns";then
map_type="DNS"
fi
if echo $map | grep -iqF "ntp";then
map_type="NTP"
fi
done
port=0
if [[ $map_type == "NTP" ]]; then
if [[ $map_counter == 1 ]]; then
port=$ntp_bau_port
fi
if [[ $map_counter == 2 ]]; then
port=$ntp_bau_and_warn_port
fi
fi
if [[ $map_type == "DNS" ]]; then
if [[ $map_counter == 1 ]]; then
port=$dns_bau_port
fi
if [[ $map_counter == 2 ]]; then
port=$dns_bau_and_warn_port
fi
fi
echo $map_type"-"$map_counter" - response: "$metrics
if [[ $port != 0 ]]; then
curl -H "content-type: application/json" -XPUT -s "http://127.0.0.1:${port}" -d "${metrics}"
fi
done
return
}
while true
do
if [ -f "$polling_time_file" ];
then
actual_stat=`stat $polling_time_file -c %Y`
if [ $actual_stat -ne $previous_stat ];
then
polling=`cat $polling_time_file`
previous_stat=$actual_stat
fi
else
mkdir -p /usr/share/scheduler/
echo "$polling" > $polling_time_file
fi
read_and_send &
echo "wait for "$polling" second..."
sleep $polling
done
packetbeat.yml : |
# =============================== Network device ===============================
# Select the network interface to sniff the data. On Linux, you can use the
# "any" keyword to sniff on all connected interfaces.
packetbeat.interfaces.device: eth0
# The network CIDR blocks that are considered "internal" networks for
# the purpose of network perimeter boundary classification. The valid
# values for internal_networks are the same as those that can be used
# with processor network conditions.
#
# For a list of available values see:
# https://www.elastic.co/guide/en/beats/packetbeat/current/defining-processors.html#condition-network
packetbeat.interfaces.internal_networks:
- private
# =================================== Flows ====================================
# Set `enabled: false` or comment out all options to disable flows reporting.
packetbeat.flows:
# Set network flow timeout. Flow is killed if no packet is received before being
# timed out.
timeout: 30s
# Configure reporting period. If set to -1, only killed flows will be reported
period: 5s
# =========================== Transaction protocols ============================
packetbeat.protocols:
- type: icmp
# Enable ICMPv4 and ICMPv6 monitoring. The default is true.
enabled: true
- type: amqp
# Configure the ports where to listen for AMQP traffic. You can disable
# the AMQP protocol by commenting out the list of ports.
ports: [5672]
- type: cassandra
# Configure the ports where to listen for Cassandra traffic. You can disable
# the Cassandra protocol by commenting out the list of ports.
ports: [9042]
- type: dhcpv4
# Configure the DHCP for IPv4 ports.
ports: [67, 68]
- type: dns
# Configure the ports where to listen for DNS traffic. You can disable
# the DNS protocol by commenting out the list of ports.
ports: [53]
- type: http
# Configure the ports where to listen for HTTP traffic. You can disable
# the HTTP protocol by commenting out the list of ports.
ports: [80, 8080, 8000, 5000, 8002]
- type: memcache
# Configure the ports where to listen for memcache traffic. You can disable
# the Memcache protocol by commenting out the list of ports.
ports: [11211]
- type: mysql
# Configure the ports where to listen for MySQL traffic. You can disable
# the MySQL protocol by commenting out the list of ports.
ports: [3306,3307]
- type: pgsql
# Configure the ports where to listen for Pgsql traffic. You can disable
# the Pgsql protocol by commenting out the list of ports.
ports: [5432]
- type: redis
# Configure the ports where to listen for Redis traffic. You can disable
# the Redis protocol by commenting out the list of ports.
ports: [6379]
- type: thrift
# Configure the ports where to listen for Thrift-RPC traffic. You can disable
# the Thrift-RPC protocol by commenting out the list of ports.
ports: [9090]
- type: mongodb
# Configure the ports where to listen for MongoDB traffic. You can disable
# the MongoDB protocol by commenting out the list of ports.
ports: [27017]
- type: nfs
# Configure the ports where to listen for NFS traffic. You can disable
# the NFS protocol by commenting out the list of ports.
ports: [2049]
- type: tls
# Configure the ports where to listen for TLS traffic. You can disable
# the TLS protocol by commenting out the list of ports.
ports:
- 443 # HTTPS
- 993 # IMAPS
- 995 # POP3S
- 5223 # XMPP over SSL
- 8443
- 8883 # Secure MQTT
- 9243 # Elasticsearch
- type: sip
# Configure the ports where to listen for SIP traffic. You can disable
# the SIP protocol by commenting out the list of ports.
ports: [5060]
# ======================= Elasticsearch template setting =======================
setup.template.settings:
index.number_of_shards: 1
#index.codec: best_compression
#_source.enabled: false
# ================================== General ===================================
# The name of the shipper that publishes the network data. It can be used to group
# all the transactions sent by a single shipper in the web interface.
#name: upf1
# A list of tags to include in every event. In the default configuration file
# the forwarded tag causes Packetbeat to not add any host fields. If you are
# monitoring a network tap or mirror port then add the forwarded tag.
#tags: [forwarded]
# Optional fields that you can specify to add additional information to the
# output.
#fields:
# env: staging
fields_under_root: false
fields:
log_topic: PacketBeatTest
# =================================== Kibana ===================================
# Starting with Beats version 6.0.0, the dashboards are loaded via the Kibana API.
# This requires a Kibana endpoint configuration.
setup.kibana:
# Kibana Host
# Scheme and port can be left out and will be set to the default (http and 5601)
# In case you specify and additional path, the scheme is required: http://localhost:5601/path
# IPv6 addresses should always be defined as: https://[2001:db8::1]:5601
#host: "localhost:5601"
# Kibana Space ID
# ID of the Kibana Space into which the dashboards should be loaded. By default,
# the Default Space will be used.
#space.id:
# ================================== Outputs ===================================
# ------------------------------ Logstash Output -------------------------------
output.kafka:
# initial brokers for reading cluster metadata
hosts: ["kafka-service.astrid-kube:9092"]
# message topic selection + partitioning
#topic: '%{[fields.log_topic]}-%{[host.name]}'
#topic: '%{[log_topic]}'
#topic: PacketBeatTest
topic: PacketBeatData
partition.round_robin:
reachable_only: false
required_acks: 1
compression: gzip
max_message_bytes: 1000000
# ================================= Processors =================================
processors:
- # Add forwarded to tags when processing data from a network tap or mirror.
if.contains.tags: forwarded
then:
- drop_fields:
fields: [host]
else:
- add_host_metadata: ~
- add_cloud_metadata: ~
- add_docker_metadata: ~
- detect_mime_type:
field: http.request.body.content
target: http.request.mime_type
- detect_mime_type:
field: http.response.body.content
target: http.response.mime_type