Created
March 17, 2013 06:08
-
-
Save mikeda/5180344 to your computer and use it in GitHub Desktop.
growthforecastのgemライブラリを使って、グラフに色を付けたり複合グラフ作ったり
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/env ruby | |
| # -*- encoding: utf-8 -*- | |
| require 'growthforecast' | |
| SERVICE = 'service01' | |
| SECTION = 'access' | |
| COMPLEX_GRAPHS = [ | |
| { | |
| name: 'access_status', | |
| description: 'アクセス数(ステータスごと)', | |
| sort: 19, | |
| sumup: true, | |
| gmode: 'gauge', | |
| type: 'AREA', | |
| stack: true, | |
| graph_names: [ | |
| '2xx_count', | |
| '3xx_count', | |
| '4xx_count', | |
| '5xx_count', | |
| ] | |
| }, | |
| { | |
| name: 'access_type', | |
| description: 'アクセス数(種別ごと)', | |
| sort: 18, | |
| sumup: true, | |
| gmode: 'gauge', | |
| type: 'AREA', | |
| stack: true, | |
| graph_names: [ | |
| 'XXX_count', | |
| 'YYY_count', | |
| 'ZZZ_count', | |
| 'unmatched_count', | |
| ] | |
| }, | |
| { | |
| name: 'response_time', | |
| description: 'レスポンスタイム', | |
| sort: 17, | |
| sumup: false, | |
| gmode: 'gauge', | |
| type: 'LINE', | |
| stack: false, | |
| graph_names: [ | |
| 'avg', | |
| 'percentile_95', | |
| ] | |
| }, | |
| ] | |
| gf = GrowthForecast.new('localhost', 5125) | |
| tree = gf.tree() | |
| COMPLEX_GRAPHS.each do |complex| | |
| spec = GrowthForecast::Complex.new({ | |
| complex: true, | |
| service_name: SERVICE, | |
| section_name: SECTION, | |
| graph_name: complex[:name], | |
| description: complex[:description], | |
| sumup: complex[:sumup], | |
| data: complex[:graph_names].map{|name| | |
| id = tree[SERVICE][SECTION][name].id | |
| GrowthForecast::Complex::Item.new({ | |
| graph_id: id, | |
| type: complex[:type], | |
| gmode: complex[:gmode], | |
| stack: complex[:stack], | |
| }) | |
| } | |
| }) | |
| gf.add(spec) | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/env ruby | |
| require 'growthforecast' | |
| SERVICE = 'service01' | |
| SECTION = 'access' | |
| GRAPHS = { | |
| '2xx_count' => '#1111cc', | |
| '3xx_count' => '#11cc11', | |
| '4xx_count' => '#cccc11', | |
| '5xx_count' => '#cc1111', | |
| 'XXX_count' => '#11cc11', | |
| 'YYY_count' => '#1111cc', | |
| 'ZZZ_count' => '#cccc11', | |
| 'unmatched_count' => '#cccccc', | |
| 'avg' => '#11cc11', | |
| 'percentile_95' => '#1111cc', | |
| } | |
| gf = GrowthForecast.new('localhost', 5125) | |
| GRAPHS.each do |name, color| | |
| graph = gf.by_name(SERVICE, SECTION, name) | |
| graph.color = color | |
| result = gf.edit(graph) | |
| raise "Something goes wrong..." unless result | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment