From 571e5982cc82c4fbefff0d463895a029a68921fe Mon Sep 17 00:00:00 2001 From: Paul Norman Date: Tue, 3 Dec 2024 00:43:07 -0800 Subject: [PATCH] vectortile: Run tilekiln prometheus endpoint --- cookbooks/vectortile/recipes/default.rb | 28 ++++++++++++++++++- .../vectortile/inspec/prometheus_spec.rb | 8 ++++++ .../vectortile/inspec/tilekiln_spec.rb | 8 ++---- 3 files changed, 37 insertions(+), 7 deletions(-) create mode 100644 test/integration/vectortile/inspec/prometheus_spec.rb diff --git a/cookbooks/vectortile/recipes/default.rb b/cookbooks/vectortile/recipes/default.rb index 99211975e..1015b38e2 100644 --- a/cookbooks/vectortile/recipes/default.rb +++ b/cookbooks/vectortile/recipes/default.rb @@ -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 @@ -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] @@ -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", +} diff --git a/test/integration/vectortile/inspec/prometheus_spec.rb b/test/integration/vectortile/inspec/prometheus_spec.rb new file mode 100644 index 000000000..cb41b1bb9 --- /dev/null +++ b/test/integration/vectortile/inspec/prometheus_spec.rb @@ -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 diff --git a/test/integration/vectortile/inspec/tilekiln_spec.rb b/test/integration/vectortile/inspec/tilekiln_spec.rb index d44562d4c..5face1904 100644 --- a/test/integration/vectortile/inspec/tilekiln_spec.rb +++ b/test/integration/vectortile/inspec/tilekiln_spec.rb @@ -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