Merge branch 'install-filestat_exporter' of kazu634/itamae into master
This commit is contained in:
commit
87f9f3197c
|
@ -17,7 +17,7 @@ remote_file '/etc/prometheus.d/alertmanager.yml' do
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deploy alert setting file:
|
# Deploy alert setting file:
|
||||||
%w(node_exporter prometheus).each do |conf|
|
%w(node_exporter prometheus filestat).each do |conf|
|
||||||
remote_file "/etc/prometheus.d/alerts/#{conf}.yml" do
|
remote_file "/etc/prometheus.d/alerts/#{conf}.yml" do
|
||||||
owner 'root'
|
owner 'root'
|
||||||
group 'root'
|
group 'root'
|
||||||
|
|
|
@ -38,4 +38,11 @@ node.reverse_merge!({
|
||||||
'storage' => '/opt/prometheus/',
|
'storage' => '/opt/prometheus/',
|
||||||
'location' => '/usr/local/bin/'
|
'location' => '/usr/local/bin/'
|
||||||
},
|
},
|
||||||
|
'filestat_exporter' => {
|
||||||
|
'url' => 'https://github.com/michael-doubez/filestat_exporter/releases/download/',
|
||||||
|
'prefix' => 'filestat_exporter-',
|
||||||
|
'postfix' => '.linux-amd64.tar.gz',
|
||||||
|
'storage' => '/opt/filestat_exporter/',
|
||||||
|
'location' => '/usr/local/bin/'
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|
|
@ -38,8 +38,21 @@ if node['prometheus']['manager']
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Create `/etc/prometheus.d/`:
|
||||||
|
%w(/etc/prometheus_exporters.d).each do |d|
|
||||||
|
directory d do
|
||||||
|
owner 'root'
|
||||||
|
group 'root'
|
||||||
|
mode '0755'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Install the node_exporter here:
|
# Install the node_exporter here:
|
||||||
include_recipe './node_exporter_install.rb'
|
include_recipe './node_exporter_install.rb'
|
||||||
include_recipe './node_exporter_setup.rb'
|
include_recipe './node_exporter_setup.rb'
|
||||||
|
|
||||||
|
# Install the filestat_exporter here:
|
||||||
|
include_recipe './filestat_exporter_install.rb'
|
||||||
|
include_recipe './filestat_exporter_setup.rb'
|
||||||
|
|
||||||
include_recipe './exporter_proxy.rb'
|
include_recipe './exporter_proxy.rb'
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
URL = 'https://github.com/rrreeeyyy/exporter_proxy/releases/download/v0.1.0/exporter_proxy_linux_amd64'
|
URL = 'https://github.com/rrreeeyyy/exporter_proxy/releases/download/v0.1.0/exporter_proxy_linux_amd64'
|
||||||
BIN = '/usr/local/bin/exporter_proxy'
|
BIN = '/usr/local/bin/exporter_proxy'
|
||||||
CONFDIR = '/etc/exporter_proxy/'
|
CONFDIR = '/etc/prometheus_exporters.d/exporter_proxy/'
|
||||||
CONF = 'config.yml'
|
CONF = 'config.yml'
|
||||||
|
|
||||||
execute "wget #{URL} -O #{BIN}" do
|
execute "wget #{URL} -O #{BIN}" do
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"service": {
|
||||||
|
"name": "filestat_exporter",
|
||||||
|
"port": 60000
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
groups:
|
||||||
|
- name: filestat
|
||||||
|
rules:
|
||||||
|
- alert: RebootRequired
|
||||||
|
expr: file_glob_match_number{pattern="/var/run/reboot-required"} > 0
|
||||||
|
for: 24h
|
||||||
|
labels:
|
||||||
|
severity: warning
|
||||||
|
annotations:
|
||||||
|
summary: "Instance {{ $labels.instance }} requires rebooting."
|
||||||
|
description: "{{ $labels.instance }} requires rebooting."
|
||||||
|
|
|
@ -14,6 +14,7 @@ rule_files:
|
||||||
# - "first.rules"
|
# - "first.rules"
|
||||||
# - "second.rules"
|
# - "second.rules"
|
||||||
- '/etc/prometheus.d/alerts/node_exporter.yml'
|
- '/etc/prometheus.d/alerts/node_exporter.yml'
|
||||||
|
- '/etc/prometheus.d/alerts/filestat.yml'
|
||||||
- '/etc/prometheus.d/alerts/prometheus.yml'
|
- '/etc/prometheus.d/alerts/prometheus.yml'
|
||||||
|
|
||||||
# A scrape configuration containing exactly one endpoint to scrape:
|
# A scrape configuration containing exactly one endpoint to scrape:
|
||||||
|
@ -51,6 +52,14 @@ scrape_configs:
|
||||||
services:
|
services:
|
||||||
- 'node_exporter'
|
- 'node_exporter'
|
||||||
|
|
||||||
|
- job_name: 'filestat'
|
||||||
|
metrics_path: /filestat_exporter/metrics
|
||||||
|
|
||||||
|
consul_sd_configs:
|
||||||
|
- server: 'localhost:8500'
|
||||||
|
services:
|
||||||
|
- 'filestat_exporter'
|
||||||
|
|
||||||
- job_name: 'grafana'
|
- job_name: 'grafana'
|
||||||
consul_sd_configs:
|
consul_sd_configs:
|
||||||
- server: 'localhost:8500'
|
- server: 'localhost:8500'
|
||||||
|
|
|
@ -16,6 +16,6 @@ exporters:
|
||||||
node_exporter:
|
node_exporter:
|
||||||
path: "/node_exporter/metrics"
|
path: "/node_exporter/metrics"
|
||||||
url: "http://127.0.0.1:9100/metrics"
|
url: "http://127.0.0.1:9100/metrics"
|
||||||
statup_exporter:
|
filestat_exporter:
|
||||||
path: "/statup_exporter/metrics"
|
path: "/filestat_exporter/metrics"
|
||||||
url: "http://127.0.0.1:8080/metrics"
|
url: "http://127.0.0.1:9943/metrics"
|
|
@ -0,0 +1,16 @@
|
||||||
|
exporter:
|
||||||
|
# Optional network parameters
|
||||||
|
listen_address: ':9943'
|
||||||
|
metrics_path: /metrics
|
||||||
|
|
||||||
|
# Optional working directory - overridden by parameter '-path.cwd'
|
||||||
|
# working_directory: "/path/to/my/project"
|
||||||
|
|
||||||
|
# Default enable/disable of metrics - overridden if not set by parameter '-metric.*'
|
||||||
|
enable_crc32_metric: true
|
||||||
|
enable_nb_line_metric: false
|
||||||
|
# list of patterns to apply - metrics can be enable/disabled for each group
|
||||||
|
files:
|
||||||
|
- patterns: ["/var/run/reboot-required"]
|
||||||
|
enable_crc32_metric: false
|
||||||
|
enable_nb_line_metric: false
|
|
@ -1,5 +1,5 @@
|
||||||
[program:exporter_proxy]
|
[program:exporter_proxy]
|
||||||
command=/usr/local/bin/exporter_proxy -config /etc/exporter_proxy/config.yml
|
command=/usr/local/bin/exporter_proxy -config /etc/prometheus_exporters.d/exporter_proxy/config.yml
|
||||||
stdout_logfile=/var/log/supervisor/exporter_proxy.log
|
stdout_logfile=/var/log/supervisor/exporter_proxy.log
|
||||||
redirect_stderr=true
|
redirect_stderr=true
|
||||||
stdout_logfile_maxbytes=1MB
|
stdout_logfile_maxbytes=1MB
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
[program:filestat_exporter]
|
||||||
|
command=/usr/local/bin/filestat_exporter --config.file=/etc/prometheus_exporters.d/filestat.yml
|
||||||
|
stdout_logfile=/var/log/supervisor/filestat_exporter.log
|
||||||
|
redirect_stderr=true
|
||||||
|
stdout_logfile_maxbytes=1MB
|
||||||
|
stdout_logfile_backups=5
|
||||||
|
autorestart=true
|
||||||
|
stopsignal=HUP
|
|
@ -0,0 +1,53 @@
|
||||||
|
filestat_exporter_url = ''
|
||||||
|
filestat_exporter_bin = ''
|
||||||
|
|
||||||
|
vtag = ''
|
||||||
|
|
||||||
|
# Calculate the Download URL:
|
||||||
|
begin
|
||||||
|
require 'net/http'
|
||||||
|
|
||||||
|
uri = URI.parse('https://github.com/michael-doubez/filestat_exporter/releases/latest')
|
||||||
|
|
||||||
|
Timeout.timeout(3) do
|
||||||
|
response = Net::HTTP.get_response(uri)
|
||||||
|
|
||||||
|
vtag = $1 if response.body =~ %r{tag\/(v\d+\.\d+\.\d+)}
|
||||||
|
|
||||||
|
filestat_exporter_bin = "#{node['filestat_exporter']['prefix']}#{vtag}#{node['filestat_exporter']['postfix']}"
|
||||||
|
filestat_exporter_url = "#{node['filestat_exporter']['url']}/#{vtag}/#{filestat_exporter_bin}"
|
||||||
|
end
|
||||||
|
rescue
|
||||||
|
# Abort the chef client process:
|
||||||
|
raise 'Cannot connect to http://github.com.'
|
||||||
|
end
|
||||||
|
|
||||||
|
# バージョン確認して、アップデート必要かどうか確認
|
||||||
|
result = run_command("filestat_exporter --version 2>&1 | grep #{vtag}", error: false)
|
||||||
|
if result.exit_status != 0
|
||||||
|
# Download:
|
||||||
|
TMP = "/tmp/#{filestat_exporter_bin}"
|
||||||
|
|
||||||
|
execute "wget #{filestat_exporter_url} -O #{TMP}"
|
||||||
|
|
||||||
|
# Install:
|
||||||
|
directory node['filestat_exporter']['storage'] do
|
||||||
|
owner 'root'
|
||||||
|
group 'root'
|
||||||
|
mode '755'
|
||||||
|
end
|
||||||
|
|
||||||
|
execute "tar zxf #{TMP} -C #{node['filestat_exporter']['storage']} --strip-components 1"
|
||||||
|
|
||||||
|
# Change Owner and Permissions:
|
||||||
|
file "#{node['filestat_exporter']['storage']}filestat_exporter" do
|
||||||
|
owner 'root'
|
||||||
|
group 'root'
|
||||||
|
mode '755'
|
||||||
|
end
|
||||||
|
|
||||||
|
# Create Link
|
||||||
|
link "#{node['filestat_exporter']['location']}filestat_exporter" do
|
||||||
|
to "#{node['filestat_exporter']['storage']}filestat_exporter"
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,31 @@
|
||||||
|
# Deploy the `supervisord` configuration:
|
||||||
|
remote_file '/etc/prometheus_exporters.d/filestat.yml' do
|
||||||
|
owner 'root'
|
||||||
|
group 'root'
|
||||||
|
mode '644'
|
||||||
|
|
||||||
|
notifies :restart, 'service[supervisor]'
|
||||||
|
end
|
||||||
|
|
||||||
|
# Deploy the `supervisord` configuration:
|
||||||
|
remote_file '/etc/supervisor/conf.d/filestat_exporter.conf' do
|
||||||
|
owner 'root'
|
||||||
|
group 'root'
|
||||||
|
mode '644'
|
||||||
|
|
||||||
|
notifies :restart, 'service[supervisor]'
|
||||||
|
end
|
||||||
|
|
||||||
|
# Deploy `consul` config for `node_exporter`:
|
||||||
|
remote_file '/etc/consul.d/service-filestat_exporter.json' do
|
||||||
|
owner 'root'
|
||||||
|
group 'root'
|
||||||
|
mode '644'
|
||||||
|
|
||||||
|
notifies :restart, 'service[supervisor]'
|
||||||
|
end
|
||||||
|
|
||||||
|
service 'supervisor' do
|
||||||
|
action :nothing
|
||||||
|
end
|
||||||
|
|
Loading…
Reference in New Issue