Skip to content
This repository has been archived by the owner on Nov 4, 2020. It is now read-only.

Commit

Permalink
adding hexdump output for debug log level, updated to gosnowth with d…
Browse files Browse the repository at this point in the history
…ebugging
  • Loading branch information
Ben Huson committed Jun 22, 2018
1 parent 79b0af0 commit c444a12
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
# unused-packages = true

[[constraint]]
branch = "master"
branch = "logging"
name = "github.com/circonus-labs/gosnowth"

[[constraint]]
Expand Down
13 changes: 12 additions & 1 deletion handlers/prometheus2_0.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package handlers
import (
"bytes"
"encoding/base64"
"encoding/hex"
"fmt"
"io/ioutil"
"net/http"
Expand All @@ -14,6 +15,7 @@ import (
"github.com/golang/protobuf/proto"
"github.com/golang/snappy"
"github.com/labstack/echo"
"github.com/labstack/gommon/log"
"github.com/pkg/errors"
"github.com/prometheus/prometheus/prompb"
uuid "github.com/satori/go.uuid"
Expand Down Expand Up @@ -100,14 +102,23 @@ func PrometheusWrite2_0(ctx echo.Context) error {
return err
}

if ctx.Logger().Level() == log.DEBUG {
// if we are set to debug dump out the hexdump of the metric list
fmt.Println(hex.Dump(metricList))
}

// pull a random snowth node from the client to send request to
node := ChooseActiveNode(snowthClient)
if node == nil {
// we are degraded, there are no active nodes
ctx.Logger().Errorf("there are no active nodes... active: %+v, inactive: %+v\n", snowthClient.ListActiveNodes(), snowthClient.ListInactiveNodes())
return errors.New("no active irondb nodes")
}
ctx.Logger().Debugf("using node: %s of %+v", node.GetURL(), snowthClient.ListActiveNodes())

ctx.Logger().Debugf(
"using node: %s of %+v",
node.GetURL(), snowthClient.ListActiveNodes())

// perform the write to IRONdb
if err = snowthClient.WriteRaw(node, bytes.NewBuffer(metricList), true, uint64(len(req.GetTimeseries()))); err != nil {
ctx.Logger().Errorf("failed to write flatbuffer: %s", err.Error())
Expand Down
20 changes: 20 additions & 0 deletions scripts/log2fb.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash

LOGFILE=$1
MSGOUTDIR=$2

mkdir -p $MSGOUTDIR && cd $MSGOUTDIR;

# log message format:
# Jun 21 21:04:20 api4-gcp-ia irondb-prometheus-adapter: 00004a10 63 68 65 63 6b 5f 75 75 69 64 22 3a 62 22 63 64 |check_uuid":b"cd|
# will output one ciml_*.log file per metric list flatbuffer message as well as one ciml_*.log.bin binary file per metric list for
# replay

grep -E ": [a-f0-9]{8}" $LOGFILE | \
cut -f 1,2,3,4,5 -d ' ' --complement | \
gawk '/[a-f0-9]{8} .. 00 00 00 43 49 4d 4c/
{ ++a; fn=sprintf("./ciml_%02d.log", a);}
{print $0 >> fn;}';


cd -;

0 comments on commit c444a12

Please sign in to comment.