Skip to content

Commit

Permalink
vectortile: Run tilekiln prometheus endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
pnorman committed Dec 3, 2024
1 parent 2125253 commit 571e598
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 7 deletions.
28 changes: 27 additions & 1 deletion cookbooks/vectortile/recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
python_package "tilekiln" do
python_virtualenv tilekiln_directory
python_version "3"
version "0.6.3"
version "0.6.5"
end

template "/srv/vector.openstreetmap.org/html/index.html" do
Expand Down Expand Up @@ -189,6 +189,13 @@
end
end

postgresql_table "tile_stats" do
cluster node[:vectortile][:database][:cluster]
database "tiles"
schema "tilekiln"
owner "tilekiln"
end

(0..14).each do |zoom|
postgresql_table "shortbread_v1_z#{zoom}" do
cluster node[:vectortile][:database][:cluster]
Expand Down Expand Up @@ -294,3 +301,22 @@
"--database-name=spirit"
]
end

systemd_service "tilekiln-prometheus" do
description "Tilekiln vector tile server"
user "tilekiln"
after "postgresql.service"
wants "postgresql.service"
sandbox :enable_network => true
restrict_address_families "AF_UNIX"
exec_start "#{tilekiln_directory}/bin/tilekiln prometheus --bind-host #{node[:prometheus][:address]} --storage-dbname tiles"
end

service "tilekiln-prometheus" do
action [:enable, :start]
end

node.default[:prometheus][:exporters][10013] = {
:name => "tilekiln",
:address => "#{node[:prometheus][:address]}:10013",
}
8 changes: 8 additions & 0 deletions test/integration/vectortile/inspec/prometheus_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
describe service("tilekiln-prometheus") do
it { should be_enabled }
it { should be_running }
end

describe port(10013) do
it { should be_listening }
end
8 changes: 2 additions & 6 deletions test/integration/vectortile/inspec/tilekiln_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,10 @@
its("status") { should cmp 200 }
end

describe json(:content => http("https://localhost/shortbread_v1/tilejson.json", :ssl_verify => false)) do
describe json(:content => http("https://localhost/shortbread_v1/tilejson.json", :ssl_verify => false).body) do
its(["tiles"]) { should eq(["https://vector.openstreetmap.org/shortbread_v1/{z}/{x}/{y}.mvt"]) }
end

# There are no tiles so everything should return a 404
describe http("https://localhost/shortbread_v1/0/0/0.mvt", :ssl_verify => false) do
its("status") { should cmp 404 }
end
describe http("https://localhost/shortbread_v1/16/0/0.mvt", :ssl_verify => false) do
its("status") { should cmp 404 }
its("status") { should cmp 410 }
end

0 comments on commit 571e598

Please sign in to comment.