csvimport

package
v1.98.0-cluster Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2024 License: Apache-2.0 Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ColumnDescriptor

type ColumnDescriptor struct {
	// ParseTimestamp is set to a function, which is used for timestamp
	// parsing from the given column.
	ParseTimestamp func(s string) (int64, error)

	// TagName is set to tag name for tag value, which should be obtained
	// from the given column.
	TagName string

	// MetricName is set to metric name for value obtained from the given column.
	MetricName string
}

ColumnDescriptor represents parsing rules for a single csv column.

The column is transformed to either timestamp, tag or metric value depending on the corresponding non-empty field.

If all the fields are empty, then the given column is ignored.

func ParseColumnDescriptors

func ParseColumnDescriptors(s string) ([]ColumnDescriptor, error)

ParseColumnDescriptors parses column descriptors from s.

s must have comma-separated list of the following entries:

<column_pos>:<column_type>:<extension>

Where:

  • <column_pos> is numeric csv column position. The first column has position 1.
  • <column_type> is one of the following types:
  • time - the corresponding column contains timestamp. Timestamp format is determined by <extension>. The following formats are supported:
  • - unix_s - unix timestamp in seconds
  • - unix_ms - unix timestamp in milliseconds
  • - unix_ns - unix_timestamp in nanoseconds
  • - rfc3339 - RFC3339 format in the form `2006-01-02T15:04:05Z07:00`
  • label - the corresponding column contains metric label with the name set in <extension>.
  • metric - the corresponding column contains metric value with the name set in <extension>.

s must contain at least a single 'metric' column and no more than a single `time` column.

type Row

type Row struct {
	Metric    string
	Tags      []Tag
	Value     float64
	Timestamp int64
}

Row represents a single metric row

type Rows

type Rows struct {
	// Rows contains parsed csv rows after the call to Unmarshal.
	Rows []Row
	// contains filtered or unexported fields
}

Rows represents csv rows.

func (*Rows) Reset

func (rs *Rows) Reset()

Reset resets rs.

func (*Rows) Unmarshal

func (rs *Rows) Unmarshal(s string, cds []ColumnDescriptor)

Unmarshal unmarshals csv lines from s according to the given cds.

type Tag

type Tag struct {
	Key   string
	Value string
}

Tag represents metric tag

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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