Skip to content

Commit

Permalink
improve query performance by moving some tags to fields
Browse files Browse the repository at this point in the history
  • Loading branch information
jrcichra committed Oct 17, 2020
1 parent 7875a90 commit 9ff31ff
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion influx/influx.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,25 @@ func (f *Influx) Write(measurement string, packet packet.Packet, interval time.D
panic(err)
}

//Remove bytes as it's not a tag but a field (the only one)
//Remove bytes
delete(m, "bytes")
//Extract out things that shouldn't be tags, but should be fields
dstPort := m["dst_port"]
delete(m, "dst_port")
srcPort := m["src_port"]
delete(m, "src_port")
proto := m["proto"]
delete(m, "proto")

pt := client.Point{
Measurement: "throughput",
Tags: m,
Fields: map[string]interface{}{
"throughput": packet.Bytes,
"interval": int(interval.Seconds()),
"dst_port": dstPort,
"src_port": srcPort,
"proto": proto,
},
Time: t,
}
Expand Down

0 comments on commit 9ff31ff

Please sign in to comment.