mirror of
https://github.com/ClusterCockpit/cc-metric-collector.git
synced 2025-04-08 22:45:55 +02:00
Change ccMetric->Influx functions
This commit is contained in:
parent
c0e600269a
commit
08968b1894
@ -24,8 +24,8 @@ type ccMetric struct {
|
|||||||
|
|
||||||
// ccMetric access functions
|
// ccMetric access functions
|
||||||
type CCMetric interface {
|
type CCMetric interface {
|
||||||
ToPoint(metaAsTags bool) *write.Point // Generate influxDB point for data type ccMetric
|
ToPoint(metaAsTags map[string]bool) *write.Point // Generate influxDB point for data type ccMetric
|
||||||
ToLineProtocol(metaAsTags bool) string // Generate influxDB line protocol for data type ccMetric
|
ToLineProtocol(metaAsTags map[string]bool) string // Generate influxDB line protocol for data type ccMetric
|
||||||
|
|
||||||
Name() string // Get metric name
|
Name() string // Get metric name
|
||||||
SetName(name string) // Set metric name
|
SetName(name string) // Set metric name
|
||||||
@ -61,25 +61,18 @@ func (m *ccMetric) String() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ToLineProtocol generates influxDB line protocol for data type ccMetric
|
// ToLineProtocol generates influxDB line protocol for data type ccMetric
|
||||||
func (m *ccMetric) ToPoint(metaAsTags bool) (p *write.Point) {
|
func (m *ccMetric) ToPoint(metaAsTags map[string]bool) (p *write.Point) {
|
||||||
|
p = influxdb2.NewPoint(m.name, m.tags, m.fields, m.tm)
|
||||||
if !metaAsTags {
|
for key, ok1 := range metaAsTags {
|
||||||
p = influxdb2.NewPoint(m.name, m.tags, m.fields, m.tm)
|
if val, ok2 := m.GetMeta(key); ok1 && ok2 {
|
||||||
} else {
|
p.AddTag(key, val)
|
||||||
tags := make(map[string]string, len(m.tags)+len(m.meta))
|
|
||||||
for key, value := range m.tags {
|
|
||||||
tags[key] = value
|
|
||||||
}
|
}
|
||||||
for key, value := range m.meta {
|
|
||||||
tags[key] = value
|
|
||||||
}
|
|
||||||
p = influxdb2.NewPoint(m.name, tags, m.fields, m.tm)
|
|
||||||
}
|
}
|
||||||
return
|
return p
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToLineProtocol generates influxDB line protocol for data type ccMetric
|
// ToLineProtocol generates influxDB line protocol for data type ccMetric
|
||||||
func (m *ccMetric) ToLineProtocol(metaAsTags bool) string {
|
func (m *ccMetric) ToLineProtocol(metaAsTags map[string]bool) string {
|
||||||
|
|
||||||
return write.PointToLineProtocol(
|
return write.PointToLineProtocol(
|
||||||
m.ToPoint(metaAsTags),
|
m.ToPoint(metaAsTags),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user