Skip to content

Commit 6cc1887

Browse files
committed
conntrack_exporter
1 parent b6eb32a commit 6cc1887

8 files changed

Lines changed: 184 additions & 1 deletion

File tree

gen/k8s/prom/nat-6x.yml

Lines changed: 43 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
include_cookbook 'ruby'
2+
package 'git'
3+
4+
directory '/opt/conntrack_exporter' do
5+
owner 'root'
6+
group 'root'
7+
mode '0755'
8+
end
9+
10+
remote_file '/opt/conntrack_exporter/Gemfile' do
11+
owner 'root'
12+
group 'root'
13+
mode '0644'
14+
end
15+
16+
remote_file '/opt/conntrack_exporter/Gemfile.lock' do
17+
owner 'root'
18+
group 'root'
19+
mode '0644'
20+
end
21+
22+
execute 'bundle install' do
23+
cwd '/opt/conntrack_exporter'
24+
command <<EOF
25+
set -e
26+
bundle config set --local deployment true
27+
bundle install
28+
(ruby -v && cat Gemfile.lock) | sha256sum >.bundle/hash
29+
EOF
30+
not_if '(ruby -v && cat Gemfile.lock) | sha256sum -c .bundle/hash'
31+
notifies :restart, 'service[conntrack_exporter]'
32+
end
33+
34+
remote_file '/etc/systemd/system/conntrack_exporter.service' do
35+
owner 'root'
36+
group 'root'
37+
mode '0644'
38+
notifies :run, 'execute[systemctl daemon-reload]', :immediately
39+
notifies :restart, 'service[conntrack_exporter]'
40+
end
41+
42+
service 'conntrack_exporter' do
43+
action [:enable, :start]
44+
end
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
[Unit]
2+
Description=Export conntrack metrics
3+
Documentation=https://github.com/hanazuki/conntrack_exporter
4+
5+
[Service]
6+
Type=exec
7+
WorkingDirectory=/opt/conntrack_exporter
8+
ExecStart=/usr/bin/bundle exec conntrack_exporter -b tcp://0.0.0.0:9466
9+
10+
DynamicUser=yes
11+
User=conntrack_exporter
12+
CapabilityBoundingSet=CAP_NET_ADMIN
13+
AmbientCapabilities=CAP_NET_ADMIN
14+
LogsDirectory=conntrack_exporter
15+
ProtectHome=yes
16+
ProtectProc=invisible
17+
SystemCallFilter=@system-service
18+
19+
[Install]
20+
WantedBy=multi-user.target
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
source 'https://rubygems.org'
2+
3+
git 'https://github.com/hanazuki/conntrack_exporter' do
4+
gem 'conntrack_exporter'
5+
end
6+
7+
git 'https://github.com/hanazuki/nl' do
8+
gem 'ynl'
9+
gem 'nl'
10+
end
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
GIT
2+
remote: https://github.com/hanazuki/conntrack_exporter
3+
revision: 564d365f2fed04ac94ea15ac6c375950ad64db19
4+
specs:
5+
conntrack_exporter (0.1.0)
6+
prometheus-client
7+
puma
8+
sinatra
9+
ynl
10+
11+
GIT
12+
remote: https://github.com/hanazuki/nl
13+
revision: f22660cb976b024e56fd7664219c437b32444e55
14+
specs:
15+
nl (0.1.0)
16+
ynl (0.1.0)
17+
nl (= 0.1.0)
18+
yaml
19+
20+
GEM
21+
remote: https://rubygems.org/
22+
specs:
23+
base64 (0.2.0)
24+
logger (1.7.0)
25+
mustermann (3.0.3)
26+
ruby2_keywords (~> 0.0.1)
27+
nio4r (2.7.4)
28+
prometheus-client (4.2.4)
29+
base64
30+
puma (6.6.0)
31+
nio4r (~> 2.0)
32+
rack (3.1.13)
33+
rack-protection (4.1.1)
34+
base64 (>= 0.1.0)
35+
logger (>= 1.6.0)
36+
rack (>= 3.0.0, < 4)
37+
rack-session (2.1.0)
38+
base64 (>= 0.1.0)
39+
rack (>= 3.0.0)
40+
ruby2_keywords (0.0.5)
41+
sinatra (4.1.1)
42+
logger (>= 1.6.0)
43+
mustermann (~> 3.0)
44+
rack (>= 3.0.0, < 4)
45+
rack-protection (= 4.1.1)
46+
rack-session (>= 2.0.0, < 3)
47+
tilt (~> 2.0)
48+
tilt (2.6.0)
49+
yaml (0.4.0)
50+
51+
PLATFORMS
52+
ruby
53+
x86_64-linux
54+
55+
DEPENDENCIES
56+
conntrack_exporter!
57+
nl!
58+
ynl!
59+
60+
BUNDLED WITH
61+
2.6.2

itamae/roles/plat/default.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
include_cookbook 'xtables'
1717
include_cookbook 'xlat'
1818
include_cookbook 'bird'
19+
include_cookbook 'conntrack-exporter'
1920

2021
package 'conntrack'
2122

itamae/roles/plat/templates/etc/nftables/plat.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ table inet plat {
7171
ip6 nexthdr icmpv6 accept
7272

7373
ip saddr { 10.33.0.0/23, 10.33.128.0/18 } tcp dport { ssh } accept
74-
ip saddr { 10.33.128.0/18 } tcp dport { 9100, 9324 } accept
74+
ip saddr { 10.33.128.0/18 } tcp dport { 9100, 9324, 9466 } accept
7575
ip6 saddr { 2001:df0:8500:ca00::/64, 2001:df0:8500:caa0::/64, 2406:da14:dfe:c000::/56 } tcp dport { ssh } accept
7676

7777
ip saddr 10.33.22.0/24 tcp dport { bgp } accept

k8s/prom/nat-6x.jsonnet

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ local jobs = [
1111
port:: 9324,
1212
metadata+: { name: 'nat-6x-bird' },
1313
},
14+
{
15+
port:: 9466,
16+
metadata+: { name: 'nat-6x-conntrack' },
17+
},
1418
];
1519
[
1620
{

0 commit comments

Comments
 (0)