-
Notifications
You must be signed in to change notification settings - Fork 1
08. Golang with influxDB
Tanveer Alam edited this page Aug 23, 2019
·
1 revision
- Check influxd server status (Should be running)
root@freebsd:~/performance/influxdb # service influxd status
influxd is running as pid 92624.
- Copy golang code base shared by name go_influxdb
root@freebsd:~/performance/influxdb # ll
total 4
drwxr-xr-x 3 root wheel 512 Nov 30 05:51 go_influxdb/
root@freebsd:~/performance/influxdb # cd go_influxdb/
- Go get the influxDB go driver
root@freebsd:~/performance/influxdb/go_influxdb # go get github.com/influxdata/influxdb/client/v2
- Compile, build and run
Note :- Uuid and timestamp gets generated in code, only input required is a file path.
root@freebsd:~/performance/influxdb/go_influxdb # go build .
root@freebsd:~/performance/influxdb/go_influxdb # ./go_influxdb
Enter absolute path of file(utf-8 format):
/root/performance/influxdb/go_influxdb/sample_input.csv
- Verify data by checking in influxDB shell
root@freebsd:~/performance/influxdb/go_influxdb # influx -format 'json' -pretty
Connected to http://localhost:8086 version 1.6.2
InfluxDB shell version: 1.6.2
> use testdb
Using database testdb
>
> SELECT * FROM test_collection
{
"results": [
{
"series": [
{
"name": "test_collection",
"columns": [
"time",
"Blob_data",
"Timestamp",
"Uuid"
],
"values": [
[
1543558020000000000,
"col1, col2, col3\nval1, val2, val3",
"2018-11-30 06:07:00.838498263 +0000 UTC m=+17.700475205",
"26ba4184-f466-11e8-b148-b755ac6ddae1\n"
]
]
}
]
}
]
}
>