From dc61680528d6fa86ed02dc2c8b9bb981a94afb4b Mon Sep 17 00:00:00 2001 From: Trent Albright Date: Fri, 6 Jun 2014 07:37:49 -0400 Subject: [PATCH] Add to list of valid chars in path_segment Allow path segments like: host.cpu-[0-7].cpu-{user,system}.value Please note that the parser is not strict. For example it would allow: host.cpu-][.cpu-}{.value Fixes livingsocial/rearview#42 See: http://graphite.readthedocs.org/en/0.9.10/functions.html#graphite.render.functions.averageSeriesWithWildcards --- lib/graphite/target_grammer.treetop | 2 +- spec/data/metrics.yml | 1 + spec/dummy/db/schema.rb | 6 +++++- spec/lib/graphite/target_parser_spec.rb | 2 +- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/graphite/target_grammer.treetop b/lib/graphite/target_grammer.treetop index 951fd62..7744497 100644 --- a/lib/graphite/target_grammer.treetop +++ b/lib/graphite/target_grammer.treetop @@ -21,7 +21,7 @@ grammar TargetGrammer end rule path_segment - [a-zA-Z0-9_\*\-]+ + [a-zA-Z0-9_\[\]\{\}\*\-]+ end rule comment diff --git a/spec/data/metrics.yml b/spec/data/metrics.yml index 2f803eb..c4b4e24 100644 --- a/spec/data/metrics.yml +++ b/spec/data/metrics.yml @@ -596,3 +596,4 @@ - alias(transformNull(smartSummarize(stats_counts.merchant_center.jobs.roi.watson.watson_consumer_connect_mail_stats.updated, "10min", "sum")), "changed") - alias(hitcount(stats.monocle.indexer.deals.update.start,"10min"), "deals updates in 10 min period") - alias(stats.monocle.indexer.deals.update.start, "drawAsInfinite(update)") +- averageSeriesWithWildcards(host.cpu-[0-7].cpu-{user,system}.value, 1) diff --git a/spec/dummy/db/schema.rb b/spec/dummy/db/schema.rb index 0c14eb3..af85981 100644 --- a/spec/dummy/db/schema.rb +++ b/spec/dummy/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20131106162900) do +ActiveRecord::Schema.define(version: 20140106161202) do create_table "applications", force: true do |t| t.integer "user_id" @@ -33,6 +33,8 @@ t.text "data", limit: 2147483647, null: false end + add_index "job_data", ["job_id"], name: "index_job_data_on_job_id", using: :btree + create_table "job_errors", force: true do |t| t.integer "job_id" t.datetime "created_at" @@ -43,6 +45,7 @@ end add_index "job_errors", ["job_id"], name: "job_id", using: :btree + add_index "job_errors", ["status"], name: "index_job_errors_on_status", using: :btree create_table "jobs", force: true do |t| t.datetime "created_at" @@ -67,6 +70,7 @@ add_index "jobs", ["app_id"], name: "app_id", using: :btree add_index "jobs", ["id", "name"], name: "id_name_version_key", unique: true, using: :btree + add_index "jobs", ["status"], name: "index_jobs_on_status", using: :btree add_index "jobs", ["user_id"], name: "jobs_ibfk_1", using: :btree create_table "users", force: true do |t| diff --git a/spec/lib/graphite/target_parser_spec.rb b/spec/lib/graphite/target_parser_spec.rb index c336a10..e41cb49 100644 --- a/spec/lib/graphite/target_parser_spec.rb +++ b/spec/lib/graphite/target_parser_spec.rb @@ -63,7 +63,7 @@ context 'expression' do context 'is parseable' do - it 'for all values in metrics.yml' do + it 'using comprehensive list of metrics in metrics.yml' do metrics = YAML.load_file("spec/data/metrics.yml") parser = Graphite::TargetParser.new metrics.each do |m|