Skip to content

Commit

Permalink
add connector for KairosDB provider
Browse files Browse the repository at this point in the history
  • Loading branch information
iaean committed Feb 27, 2015
1 parent 36ef6a0 commit 74eff31
Show file tree
Hide file tree
Showing 5 changed files with 618 additions and 0 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ To reach the core developer team, please write to the <dev@facette.io> address.
CONTRIBUTORS
============

* Andreas Schulze <https://github.com/iaean>
* Maxime Guillet <https://github.com/maximeguillet>
* Michael Crosby <https://github.com/crosbymichael>
* Nicolas Leclercq <https://github.com/exzz>
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ VERSION = 0.3.0dev

TAGS ?= facette \
graphite \
kairosdb \
influxdb \
rrd

Expand Down
18 changes: 18 additions & 0 deletions docs/examples/providers/kairosdb.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"connector": {
"type": "kairosdb",
"url": "http://localhost:8080/",
"source_tags": [ "host", "name" ],
"start_relative": { "value": 6, "unit": "months" },
"aggregators": [
{ "metric": "^entropy\\.", "aggregator": { "name": "min", "sampling": { "value": 5, "unit": "minutes" } } },
{ "metric": "\\.[tr]x$", "aggregator": { "name": "max", "sampling": { "value": 5, "unit": "minutes" } } }
]
},

"filters": [
{ "action": "rewrite", "target": "metric", "pattern": "/", "into": "." },
{ "action": "rewrite", "target": "metric", "pattern": "\\.value$", "into": "" },
{ "action": "rewrite", "target": "source", "pattern": "_/x28.*/x29$", "into": "" }
]
}
30 changes: 30 additions & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,33 @@ func GetBool(config map[string]interface{}, setting string, mandatory bool) (boo
value, err := getSetting(config, setting, reflect.Bool, mandatory, false)
return value.(bool), err
}

// GetStringSlice returns the string slice of a configuration setting.
func GetStringSlice(config map[string]interface{}, setting string, mandatory bool) ([]string, error) {
value, err := getSetting(config, setting, reflect.Slice, mandatory, nil)
if err != nil || value == nil {
return nil, err
}
array := make([]string, 0)
for _, v := range value.([]interface{}) {
if reflect.ValueOf(v).Kind() != reflect.String {
return nil, fmt.Errorf("setting `%s' should be slice of strings and not %s", setting,
reflect.ValueOf(v).Kind().String())
} else {
array = append(array, v.(string))
}
}
return array, nil
}

// GetJsonObj returns the JSON Object interface{} of a configuration setting.
func GetJsonObj(config map[string]interface{}, setting string, mandatory bool) (interface{}, error) {
value, err := getSetting(config, setting, reflect.Map, mandatory, nil)
return value, err
}

// GetJsonArray returns the JSON Array interface{} of a configuration setting.
func GetJsonArray(config map[string]interface{}, setting string, mandatory bool) (interface{}, error) {
value, err := getSetting(config, setting, reflect.Slice, mandatory, nil)
return value, err
}
Loading

0 comments on commit 74eff31

Please sign in to comment.