Skip to content

Commit

Permalink
apply required changes
Browse files Browse the repository at this point in the history
- Change CamelCase tags, measurements and values names to sneak_case
- Move information about used version during tests to test file
  • Loading branch information
Daniel Salbert committed Jul 12, 2017
1 parent 56c2560 commit ffd0b35
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 25 deletions.
24 changes: 12 additions & 12 deletions plugins/inputs/fluentd/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,26 +28,26 @@ This plugin understands data provided by /api/plugin.json resource (/api/config.
Fields may vary depends on type of the plugin

- fluentd
- RetryCount (float, unit)
- BufferQueueLength (float, unit)
- BufferTotalQueuedSize (float, unit)
- retry_count (float, unit)
- buffer_queue_length (float, unit)
- buffer_total_queued_size (float, unit)

### Tags:

- All measurements have the following tags:
- PluginID (unique plugin id)
- PluginType (type of the plugin e.g. s3)
- PluginCategory (plugin category e.g. output)
- plugin_id (unique plugin id)
- plugin_type (type of the plugin e.g. s3)
- plugin_category (plugin category e.g. output)

### Example Output:

```
$ telegraf --config fluentd.conf --input-filter fluentd --test
* Plugin: inputs.fluentd, Collection 1
> fluentd,host=T440s,PluginID=object:9f748c,PluginCategory=input,PluginType=dummy BufferTotalQueuedSize=0,BufferQueueLength=0,RetryCount=0 1492006105000000000
> fluentd,PluginCategory=input,PluginType=dummy,host=T440s,PluginID=object:8da98c BufferQueueLength=0,RetryCount=0,BufferTotalQueuedSize=0 1492006105000000000
> fluentd,PluginID=object:820190,PluginCategory=input,PluginType=monitor_agent,host=T440s RetryCount=0,BufferTotalQueuedSize=0,BufferQueueLength=0 1492006105000000000
> fluentd,PluginID=object:c5e054,PluginCategory=output,PluginType=stdout,host=T440s BufferQueueLength=0,RetryCount=0,BufferTotalQueuedSize=0 1492006105000000000
> fluentd,PluginType=s3,host=T440s,PluginID=object:bd7a90,PluginCategory=output BufferQueueLength=0,RetryCount=0,BufferTotalQueuedSize=0 1492006105000000000
> fluentd,host=T440s,plugin_id=object:9f748c,plugin_category=input,plugin_type=dummy buffer_total_queued_size=0,buffer_queue_length=0,retry_count=0 1492006105000000000
> fluentd,plugin_category=input,plugin_type=dummy,host=T440s,plugin_id=object:8da98c buffer_queue_length=0,retry_count=0,buffer_total_queued_size=0 1492006105000000000
> fluentd,plugin_id=object:820190,plugin_category=input,plugin_type=monitor_agent,host=T440s retry_count=0,buffer_total_queued_size=0,buffer_queue_length=0 1492006105000000000
> fluentd,plugin_id=object:c5e054,plugin_category=output,plugin_type=stdout,host=T440s buffer_queue_length=0,retry_count=0,buffer_total_queued_size=0 1492006105000000000
> fluentd,plugin_type=s3,host=T440s,plugin_id=object:bd7a90,plugin_category=output buffer_queue_length=0,retry_count=0,buffer_total_queued_size=0 1492006105000000000
```
```
13 changes: 6 additions & 7 deletions plugins/inputs/fluentd/fluentd.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ const (
description = "Read metrics exposed by fluentd in_monitor plugin"
sampleConfig = `
## This plugin only reads information exposed by fluentd using /api/plugins.json.
## Tested using 'fluentd' version '0.14.9'
##
## Endpoint:
## - only one URI is allowed
Expand Down Expand Up @@ -174,14 +173,14 @@ func (h *Fluentd) Gather(acc telegraf.Accumulator) error {
tmpFields := make(map[string]interface{})

tmpTags := map[string]string{
"PluginID": p.PluginID,
"PluginCategory": p.PluginCategory,
"PluginType": p.PluginType,
"plugin_id": p.PluginID,
"plugin_category": p.PluginCategory,
"plugin_type": p.PluginType,
}

tmpFields["BufferQueueLength"] = p.BufferQueueLength
tmpFields["RetryCount"] = p.RetryCount
tmpFields["BufferTotalQueuedSize"] = p.BufferTotalQueuedSize
tmpFields["buffer_queue_length"] = p.BufferQueueLength
tmpFields["retry_count"] = p.RetryCount
tmpFields["buffer_total_queued_size"] = p.BufferTotalQueuedSize

acc.AddFields(measurement, tmpFields, tmpTags)
}
Expand Down
13 changes: 7 additions & 6 deletions plugins/inputs/fluentd/fluentd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/stretchr/testify/assert"
)

// sampleJSON from fluentd version '0.14.9'
const sampleJSON = `
{
"plugins": [
Expand Down Expand Up @@ -166,12 +167,12 @@ func Test_Gather(t *testing.T) {
}

for i := 0; i < len(acc.Metrics); i++ {
assert.Equal(t, expectedOutput[i].PluginID, acc.Metrics[i].Tags["PluginID"])
assert.Equal(t, expectedOutput[i].PluginType, acc.Metrics[i].Tags["PluginType"])
assert.Equal(t, expectedOutput[i].PluginCategory, acc.Metrics[i].Tags["PluginCategory"])
assert.Equal(t, expectedOutput[i].RetryCount, acc.Metrics[i].Fields["RetryCount"])
assert.Equal(t, expectedOutput[i].BufferQueueLength, acc.Metrics[i].Fields["BufferQueueLength"])
assert.Equal(t, expectedOutput[i].BufferTotalQueuedSize, acc.Metrics[i].Fields["BufferTotalQueuedSize"])
assert.Equal(t, expectedOutput[i].PluginID, acc.Metrics[i].Tags["plugin_id"])
assert.Equal(t, expectedOutput[i].PluginType, acc.Metrics[i].Tags["plugin_type"])
assert.Equal(t, expectedOutput[i].PluginCategory, acc.Metrics[i].Tags["plugin_category"])
assert.Equal(t, expectedOutput[i].RetryCount, acc.Metrics[i].Fields["retry_count"])
assert.Equal(t, expectedOutput[i].BufferQueueLength, acc.Metrics[i].Fields["buffer_queue_length"])
assert.Equal(t, expectedOutput[i].BufferTotalQueuedSize, acc.Metrics[i].Fields["buffer_total_queued_size"])
}

}

0 comments on commit ffd0b35

Please sign in to comment.