- name: prometheus-server
run_list:
- recipe[prometheus::server]
- attributes:
- prometheus:
- promscale: true
- name: python
run_list:
- recipe[python::default]
- name: tilelog
run_list:
- recipe[tilelog::default]
- - name: timescaledb
- run_list:
- - recipe[timescaledb::default]
- name: tools
run_list:
- recipe[tools::default]
+++ /dev/null
-#
-# Cookbook:: apt
-# Recipe:: timescaledb
-#
-# Copyright:: 2022, Tom Hughes
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-include_recipe "apt"
-include_recipe "apt::postgresql"
-
-platform_name = if platform?("debian")
- "debian"
- else
- "ubuntu"
- end
-
-apt_repository "timescaledb" do
- uri "https://packagecloud.io/timescale/timescaledb/#{platform_name}"
- components ["main"]
- key "https://packagecloud.io/timescale/timescaledb/gpgkey"
-end
default[:prometheus][:snmp] = {}
default[:prometheus][:metrics] = {}
default[:prometheus][:files] = []
-default[:prometheus][:promscale] = true
depends "git"
depends "hardware"
depends "networking"
-depends "timescaledb"
include_recipe "apache"
include_recipe "apt::grafana"
-include_recipe "apt::timescaledb"
include_recipe "networking"
-include_recipe "timescaledb"
passwords = data_bag_item("prometheus", "passwords")
tokens = data_bag_item("prometheus", "tokens")
subscribes :extract, "remote_file[#{cache_dir}/karma-linux-amd64.tar.gz]", :immediately
end
-promscale_version = "0.17.0"
-promscale_extension_version = "0.8.0-1"
-
-database_version = node[:timescaledb][:database_version]
-database_cluster = "#{database_version}/main"
-
-package %W[
- prometheus
- promscale-extension-postgresql-#{database_version}
-]
-
-package "promscale-extension-postgresql-#{database_version}" do
- version promscale_extension_version
-end
-
-apt_preference "promscale-extension-postgresql" do
- pin "version #{promscale_extension_version}"
- pin_priority "1100"
-end
-
-postgresql_user "prometheus" do
- cluster database_cluster
- superuser true
-end
-
-postgresql_database "promscale" do
- cluster database_cluster
- owner "prometheus"
-end
-
-directory "/opt/promscale" do
- owner "root"
- group "root"
- mode "755"
-end
-
-directory "/opt/promscale/bin" do
- owner "root"
- group "root"
- mode "755"
-end
-
-remote_file "/opt/promscale/bin/promscale" do
- action :create
- source "https://github.com/timescale/promscale/releases/download/#{promscale_version}/promscale_#{promscale_version}_Linux_x86_64"
- owner "root"
- group "root"
- mode "755"
-end
-
-systemd_service "promscale" do
- description "Promscale Connector"
- type "simple"
- user "prometheus"
- exec_start "/opt/promscale/bin/promscale --db.uri postgresql:///promscale?host=/run/postgresql&port=5432 --db.connections-max 400"
- limit_nofile 16384
- sandbox :enable_network => true
- restrict_address_families "AF_UNIX"
-end
-
-if node[:prometheus][:promscale]
- service "promscale" do
- action [:enable, :start]
- subscribes :restart, "remote_file[/opt/promscale/bin/promscale]"
- subscribes :restart, "systemd_service[promscale]"
- end
-else
- service "promscale" do
- action [:disable, :stop]
- end
-end
-
search(:node, "roles:gateway") do |gateway|
allowed_ips = gateway.ipaddresses(:role => :internal).map(&:subnet)
static_configs:
- targets:
- localhost:9093
- - job_name: promscale
- static_configs:
- - targets:
- - localhost:9201
- job_name: ssl
scrape_interval: 15m
metrics_path: /probe
- source_labels: [__address__]
regex: "[^/]+/[^/]+/(.*)"
target_label: __address__
-
-remote_read:
- - url: "http://localhost:9201/read"
+++ /dev/null
-# TimescaleDB Cookbook
-
-This cookbook configures TimescaleDB.
+++ /dev/null
-default[:timescaledb][:database_version] = "15"
-default[:timescaledb][:max_background_workers] = 8
+++ /dev/null
-name "timescaledb"
-maintainer "OpenStreetMap Administrators"
-maintainer_email "admins@openstreetmap.org"
-license "Apache-2.0"
-description "Installs and configures timescaledb"
-
-version "1.0.0"
-supports "ubuntu"
-depends "apache"
-depends "apt"
-depends "postgresql"
+++ /dev/null
-#
-# Cookbook:: timescaledb
-# Recipe:: default
-#
-# Copyright:: 2021, OpenStreetMap Foundation
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-include_recipe "apt::timescaledb"
-
-database_version = node[:timescaledb][:database_version]
-
-package %W[
- timescaledb-tools
- timescaledb-2-postgresql-#{database_version}
-]
-
-node.default_unless[:postgresql][:versions] = []
-node.default[:postgresql][:versions] |= [database_version]
-node.default[:postgresql][:monitor_tables] = false
-node.default_unless[:postgresql][:settings][database_version][:shared_preload_libraries] = []
-node.default[:postgresql][:settings][database_version][:shared_preload_libraries] |= ["timescaledb"]
-node.default_unless[:postgresql][:settings][database_version][:customized_options] = {}
-node.default[:postgresql][:settings][database_version][:customized_options]["timescaledb.max_background_workers"] = node[:timescaledb][:max_background_workers]
-
-include_recipe "postgresql"
+++ /dev/null
-require "serverspec"
-
-# Required by serverspec
-set :backend, :exec
-
-describe service("promscale") do
- it { should be_enabled }
- it { should be_running }
-end
-
-describe port(9201) do
- it { should be_listening.with("tcp6") }
-end