feat: Add logfmts script to humanize timestamps

```console
$ kubectl logs deploy/iox-router-1000 -c iox -f | TZ=UTC ./scripts/logfmts
2021-06-04 10:25:46 level=debug msg="Successfully processed request" response="Response { status: 204, version: HTTP/1.1, headers: {\"x-powered-by\": \"Routerify v2.0.0-beta-2\"}, body: Body(Empty) }" target="influxdb_iox::influxdb_ioxd::http" location="src/influxdb_ioxd/http.rs:359"
```
pull/24376/head
Marko Mikulicic 2021-06-04 12:25:22 +02:00
parent c595757616
commit 12b561f140
No known key found for this signature in database
GPG Key ID: D02A41F91A687DB3
1 changed files with 26 additions and 0 deletions

26
scripts/logfmts Executable file
View File

@ -0,0 +1,26 @@
#!/bin/bash
#
# Human readable logfmt timestamps (ts)
#
# Usage:
#
# kubectl logs deploy/iox-router-1000 -c iox -f | ./scripts/logfmts
#
#
# If you want to render into UTC timestamps:
#
# kubectl logs deploy/iox-router-1000 -c iox -f | TZ=UTC ./scripts/logfmts
#
#
set -eu -o pipefail
if ! command -v gawk &> /dev/null; then
echo "GNU awk required"
echo " brew install gawk"
echo " apt-get install gawk"
echo " ...."
fi
exec gawk -F"time=" '{print strftime("%Y-%m-%d %H:%M:%S", $2/1000000000), $1 }'