Skip to content

Commit

Permalink
fix(exporter): correct metrics file format and ext
Browse files Browse the repository at this point in the history
  • Loading branch information
sar-make committed Aug 24, 2017
1 parent 5972d70 commit 41ff9f5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion attributes/exporter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

# Where to put the exported metrics
default[cookbook_name]['metrics_dir'] = '/opt/prometheus_metrics'
metrics_file = "#{node[cookbook_name]['metrics_dir']}/chronyd"
metrics_file = "#{node[cookbook_name]['metrics_dir']}/chronyd.prom"

# Systemd service unit
default[cookbook_name]['systemd_unit'] = {
Expand Down
12 changes: 6 additions & 6 deletions files/default/chrony_exporter.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ sources_burst_offline=\
$(echo "${activity}" | grep "return to offline" | cut -d ' ' -f1)

cat <<EOF
TYPE node_chronyd_offset_seconds gauge
# TYPE node_chronyd_offset_seconds gauge
node_chronyd_offset_seconds ${last_offset}
TYPE node_chronyd_sources_total gauge
node_chronyd_sources_total{status=online} ${sources_online}
node_chronyd_sources_total{status=offline} ${sources_offline}
node_chronyd_sources_total{status=burst_online} ${sources_burst_online}
node_chronyd_sources_total{status=burst_offline} ${sources_burst_offline}
# TYPE node_chronyd_sources_total gauge
node_chronyd_sources_total{status="online"} ${sources_online}
node_chronyd_sources_total{status="offline"} ${sources_offline}
node_chronyd_sources_total{status="burst_online"} ${sources_burst_online}
node_chronyd_sources_total{status="burst_offline"} ${sources_burst_offline}
EOF
8 changes: 4 additions & 4 deletions test/integration/chrony-ntp/serverspec/default_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@
end

(1..15).each do |try|
msg = 'node_chronyd_sources_total{status=online} 2'
cmd = "grep '#{msg}' /opt/prometheus_metrics/chronyd"
msg = 'node_chronyd_sources_total{status="online"} 2'
cmd = "grep '#{msg}' /opt/prometheus_metrics/chronyd.prom"
result = `#{cmd} 2>&1`
break if result.include?(msg)
puts "Waiting for metrics chronyd …\
Try ##{try}/15, waiting 5s"
sleep(5)
end

describe file('/opt/prometheus_metrics/chronyd') do
it { should contain('node_chronyd_sources_total{status=online} 2') }
describe file('/opt/prometheus_metrics/chronyd.prom') do
it { should contain('node_chronyd_sources_total{status="online"} 2') }
end

0 comments on commit 41ff9f5

Please sign in to comment.