배경
influx CLI를 통해 influxdb 내에 저장된 데이터를 조회 시 아래와 같이 timestamp 형식으로 출력되어 가독성이 떨어진다.
Connected to http://localhost:8086 version 1.6.3
InfluxDB shell version: 1.6.3
> use telegraf
Using database telegraf
> select * from cpu limit 10;
name: cpu
time cpu host usage_guest usage_guest_nice usage_idle usage_iowait usage_irq usage_nice usage_softirq usage_steal usage_system usage_user
---- --- ---- ----------- ---------------- ---------- ------------ --------- ---------- ------------- ----------- ------------ ----------
1539295550000000000 cpu-total ip-172-31-24-216.ap-northeast-2.compute.internal 0 0 99.59798994938187 0 0 0 0 0 0 0.402010050243365
1539298550000000000 cpu0 ip-172-31-24-216.ap-northeast-2.compute.internal 0 0 99.59839357392165 0 0 0 0 0 0.20080321285197406 0.20080321285197406
1539299990000000000 cpu-total ip-172-31-24-216.ap-northeast-2.compute.internal 0 0 99.49849548831452 0 0 0 0 0 0.30090270813196973 0.20060180542131315
1539300240000000000 cpu-total ip-172-31-24-216.ap-northeast-2.compute.internal 0 0 99.39819458320315 0 0 0 0 0.10030090270597189 0.20060180541194378 0.30090270812019626
1539302860000000000 cpu0 ip-172-31-24-216.ap-northeast-2.compute.internal 0 0 99.6984924643623 0 0 0 0 0 0.20100502513108956 0.10050251256325962
1539303090000000000 cpu-total ip-172-31-24-216.ap-northeast-2.compute.internal 0 0 99.6984924643623 0 0 0 0 0 0.10050251256554478 0.20100502513108956
1539303100000000000 cpu0 ip-172-31-24-216.ap-northeast-2.compute.internal 0 0 99.49849548831452 0 0 0 0 0 0.10030090271065657 0.4012036108426263
1539304410000000000 cpu0 ip-172-31-24-216.ap-northeast-2.compute.internal 0 0 99.6984924596964 0 0 0 0 0 0.10050251256084125 0.2010050251216825
1539304530000000000 cpu-total ip-172-31-24-216.ap-northeast-2.compute.internal 0 0 99.69879518277891 0 0 0 0 0 0.10040160642598703 0.20080321285197406
1539304550000000000 cpu-total ip-172-31-24-216.ap-northeast-2.compute.internal 0 0 99.69788519375363 0 0 0 0 0 0.10070493454000086 0.20140986908000172
>
해결법
influx 실행 시 -precision rfc3339 를 추가로 붙이거나
$ influx -precision rfc3339
influx CLI 실행 후 presision rfc3339 을 실행하면 된다.
precision rfc3339
[root@nbsoft ~]# influx -precision rfc3339
Connected to http://localhost:8086 version 1.6.3
InfluxDB shell version: 1.6.3
> use telegraf
Using database telegraf
> select * from cpu limit 10;
name: cpu
time cpu host usage_guest usage_guest_nice usage_idle usage_iowait usage_irq usage_nice usage_softirq usage_steal usage_system usage_user
---- --- ---- ----------- ---------------- ---------- ------------ --------- ---------- ------------- ----------- ------------ ----------
2018-10-11T22:05:50Z cpu-total ip-172-31-24-216.ap-northeast-2.compute.internal 0 0 99.59798994938187 0 0 0 0 0 0 0.402010050243365
2018-10-11T22:55:50Z cpu0 ip-172-31-24-216.ap-northeast-2.compute.internal 0 0 99.59839357392165 0 0 0 0 0 0.20080321285197406 0.20080321285197406
2018-10-11T23:19:50Z cpu-total ip-172-31-24-216.ap-northeast-2.compute.internal 0 0 99.49849548831452 0 0 0 0 0 0.30090270813196973 0.20060180542131315
2018-10-11T23:24:00Z cpu-total ip-172-31-24-216.ap-northeast-2.compute.internal 0 0 99.39819458320315 0 0 0 0 0.10030090270597189 0.20060180541194378 0.30090270812019626
2018-10-12T00:07:40Z cpu0 ip-172-31-24-216.ap-northeast-2.compute.internal 0 0 99.6984924643623 0 0 0 0 0 0.20100502513108956 0.10050251256325962
2018-10-12T00:11:30Z cpu-total ip-172-31-24-216.ap-northeast-2.compute.internal 0 0 99.6984924643623 0 0 0 0 0 0.10050251256554478 0.20100502513108956
2018-10-12T00:11:40Z cpu0 ip-172-31-24-216.ap-northeast-2.compute.internal 0 0 99.49849548831452 0 0 0 0 0 0.10030090271065657 0.4012036108426263
2018-10-12T00:33:30Z cpu0 ip-172-31-24-216.ap-northeast-2.compute.internal 0 0 99.6984924596964 0 0 0 0 0 0.10050251256084125 0.2010050251216825
2018-10-12T00:35:30Z cpu-total ip-172-31-24-216.ap-northeast-2.compute.internal 0 0 99.69879518277891 0 0 0 0 0 0.10040160642598703 0.20080321285197406
2018-10-12T00:35:50Z cpu-total ip-172-31-24-216.ap-northeast-2.compute.internal 0 0 99.69788519375363 0 0 0 0 0 0.10070493454000086 0.20140986908000172
>