graphite

package
v0.0.0-...-5864974 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 9, 2019 License: MIT Imports: 8 Imported by: 0

README

Graphite

The Graphite data format is translated from Telegraf Metrics using either the template pattern or tag support method. You can select between the two methods using the graphite_tag_support option. When set, the tag support method is used, otherwise the Template Pattern is used.

Configuration
[[outputs.file]]
  ## Files to write to, "stdout" is a specially handled file.
  files = ["stdout", "/tmp/metrics.out"]

  ## Data format to output.
  ## Each data format has its own unique set of configuration options, read
  ## more about them here:
  ## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_OUTPUT.md
  data_format = "graphite"

  ## Prefix added to each graphite bucket
  prefix = "telegraf"
  ## Graphite template pattern
  template = "host.tags.measurement.field"

  ## Support Graphite tags, recommended to enable when using Graphite 1.1 or later.
  # graphite_tag_support = false
graphite_tag_support

When the graphite_tag_support option is enabled, the template pattern is not used. Instead, tags are encoded using Graphite tag support added in Graphite 1.1. The metric_path is a combination of the optional prefix option, measurement name, and field name.

The tag name is reserved by Graphite, any conflicting tags and will be encoded as _name.

Example Conversion:

cpu,cpu=cpu-total,dc=us-east-1,host=tars usage_idle=98.09,usage_user=0.89 1455320660004257758
=>
cpu.usage_user;cpu=cpu-total;dc=us-east-1;host=tars 0.89 1455320690
cpu.usage_idle;cpu=cpu-total;dc=us-east-1;host=tars 98.09 1455320690

Documentation

Index

Constants

View Source
const DEFAULT_TEMPLATE = "host.tags.measurement.field"

Variables

This section is empty.

Functions

func InsertField

func InsertField(bucket, fieldName string) string

InsertField takes the bucket string from SerializeBucketName and replaces the FIELDNAME portion. If fieldName == "value", it will simply delete the FIELDNAME portion.

func SerializeBucketName

func SerializeBucketName(
	measurement string,
	tags map[string]string,
	template string,
	prefix string,
) string

SerializeBucketName will take the given measurement name and tags and produce a graphite bucket. It will use the GraphiteSerializer.Template to generate this, or DEFAULT_TEMPLATE.

NOTE: SerializeBucketName replaces the "field" portion of the template with FIELDNAME. It is up to the user to replace this. This is so that SerializeBucketName can be called just once per measurement, rather than once per field. See GraphiteSerializer.InsertField() function.

func SerializeBucketNameWithTags

func SerializeBucketNameWithTags(
	measurement string,
	tags map[string]string,
	prefix string,
	field string,
) string

SerializeBucketNameWithTags will take the given measurement name and tags and produce a graphite bucket. It will use the Graphite11Serializer. http://graphite.readthedocs.io/en/latest/tags.html

Types

type GraphiteSerializer

type GraphiteSerializer struct {
	Prefix     string
	Template   string
	TagSupport bool
}

func (*GraphiteSerializer) Serialize

func (s *GraphiteSerializer) Serialize(metric telegraf.Metric) ([]byte, error)

func (*GraphiteSerializer) SerializeBatch

func (s *GraphiteSerializer) SerializeBatch(metrics []telegraf.Metric) ([]byte, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL