func (t TSDB) System(hostname string) error {
	var dps []TSDBDataPoint
	sys := new(Sys)
	client := NewHTTP()
	err := client.Get(t.VHost+"/sys", sys)
	if err != nil {
		return err
	}
	metrics := []string{
		"mem.heap.alloc",
		"mem.alloc",
		"mcache.inuse",
		"mem.total.alloc",
		"mem.heap.sys",
		"num.goroutine",
	}
	values := []int64{
		sys.MemHeapAlloc,
		sys.MemAlloc,
		sys.MCacheInuse,
		sys.MemTotalAlloc,
		sys.MemHeapSys,
		sys.NumGoroutine,
	}
	for i, m := range metrics {
		dps = append(dps, TSDBDataPoint{
			Metric:    m,
			Timestamp: time.Now().Unix(),
			Value:     values[i],
			Tags: struct {
				Host string `json:"host"`
				Type string `json:"type"`
			}{
				Host: hostname,
			},
		})
	}
	err = t.put(dps)
	return err
}
System ingests system's stats to TSDB
package store
import (
	"encoding/json"
	"errors"
	"fmt"
	"time"
)
type TSDB struct {
	API   string
	VHost string
}
type TSDBDataPoint struct {
	Metric    string `json:"metric"`
	Timestamp int64  `json:"timestamp"`
	Value     int64  `json:"value"`
	Tags      struct {
		Host string `json:"host"`
		Type string `json:"type"`
	}
}
type TSDBResp struct {
	Failed  int `json:"failed"`
	Success int `json:"success"`
}
func (t TSDB) Netflow(hostname string) error {
	var (
		dps    []TSDBDataPoint
		values []int64
	)
	flow, lastFlow, err := getFlow(t.VHost, hostname)
	if err != nil {
		return err
	}
	delta := flow.Timestamp - lastFlow.Timestamp
	metrics := [][]string{
		{"ipfix", "udp.rate"},
		{"sflow", "udp.rate"},
		{"ipfix", "decode.rate"},
		{"sflow", "decode.rate"},
		{"ipfix", "mq.error.rate"},
		{"sflow", "mq.error.rate"},
		{"ipfix", "workers"},
		{"sflow", "workers"},
	}
	values = append(values, abs((flow.IPFIX.UDPCount-lastFlow.IPFIX.UDPCount)/delta))
	values = append(values, abs((flow.SFlow.UDPCount-lastFlow.SFlow.UDPCount)/delta))
	values = append(values, abs((flow.IPFIX.DecodedCount-lastFlow.IPFIX.DecodedCount)/delta))
	values = append(values, abs((flow.SFlow.DecodedCount-lastFlow.SFlow.DecodedCount)/delta))
	values = append(values, abs((flow.IPFIX.MQErrorCount-lastFlow.IPFIX.MQErrorCount)/delta))
	values = append(values, abs((flow.SFlow.MQErrorCount-lastFlow.SFlow.MQErrorCount)/delta))
	values = append(values, flow.IPFIX.Workers)
	values = append(values, flow.SFlow.Workers)
	for i, m := range metrics {
		dps = append(dps, TSDBDataPoint{
			Metric:    m[1],
			Timestamp: time.Now().Unix(),
			Value:     values[i],
			Tags: struct {
				Host string `json:"host"`
				Type string `json:"type"`
			}{
				Host: hostname,
				Type: m[0],
			},
		})
	}
	err = t.put(dps)
	return err
}