Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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 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) Unmarshal ¶
func (rs *Rows) Unmarshal(s string, cds []ColumnDescriptor)
Unmarshal unmarshals csv lines from s according to the given cds.
Click to show internal directories.
Click to hide internal directories.