Skip to content

Instantly share code, notes, and snippets.

@johnduarte
Last active October 23, 2019 23:57
Show Gist options
  • Save johnduarte/c3c1064e54f7d87aacdbb0a8edb1f32a to your computer and use it in GitHub Desktop.
Save johnduarte/c3c1064e54f7d87aacdbb0a8edb1f32a to your computer and use it in GitHub Desktop.
# quick and dirty expression of automating importation
# of L/XL data into grafana from gplt metrics collector data
require "yaml"
time = "1571690335" # this should be introspected from the data directory
tag = "slv-649" # passed as an argument
source = "data/#{tag}"
# parse yaml
data = YAML.load(File.read("jrd-gplt-01/build/pe_xl/nodes.yaml"))
nodes = data["groups"].first["nodes"]
# for each host, gather results
nodes.each do |node|
node_alias_compact = node["alias"].split("_").map{ |string| string[0] }.join("")
cmd = %W[json2graphite.rb
--pattern #{source}/puppet-metrics-collector/**/#{node["name"]}/*.json
--convert-to influxdb
--netcat localhost
--influx-db puppet_metrics
--server-tag #{tag}_#{time}_#{node_alias_compact}].join(" ")
puts "---------"
puts "Running #{cmd}"
success = sytem(cmd)
raise "Error importing data into graphite" unless success
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment