dpattmann / prometheus-timestream-adapter

Use AWS Timestream as a remote storage database for Prometheus
Apache License 2.0
36 stars 12 forks source link

Fail on Test #78

Closed ratovarius closed 2 years ago

ratovarius commented 2 years ago

Using Ubuntu 20.04.3 LTS go version go1.17.6 linux/amd64

I just cloned the repo, run go build and afther that, go test. I get the folllowing error,

--- FAIL: TestTimeSteamAdapter_Read (0.00s)
    --- FAIL: TestTimeSteamAdapter_Read/Read_Timestream_Request (0.00s)
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
    panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x38 pc=0xa5630f]

goroutine 37 [running]:
testing.tRunner.func1.2({0xaeee60, 0x12afc60})
    /usr/local/go/src/testing/testing.go:1209 +0x24e
testing.tRunner.func1()
    /usr/local/go/src/testing/testing.go:1212 +0x218
panic({0xaeee60, 0x12afc60})
    /usr/local/go/src/runtime/panic.go:1038 +0x215
github.com/dpattmann/prometheus-timestream-adapter.TimeStreamAdapter.readDimension({{0xbb1606, 0xc}, 0xc00011c678, {0xbaf266, 0x9}, {0xddbf10, 0x12c4f90}, {0xddc090, 0x12c4fa0}}, {0xbaa641, ...})
    /home/ubuntu/prometheus-timestream-adapter/timestream.go:310 +0x1cf
github.com/dpattmann/prometheus-timestream-adapter.TimeStreamAdapter.buildTimeStreamQueryString({{0xbb1606, 0xc}, 0xc00011c678, {0xbaf266, 0x9}, {0xddbf10, 0x12c4f90}, {0xddc090, 0x12c4fa0}}, 0xc000413c50)
    /home/ubuntu/prometheus-timestream-adapter/timestream.go:288 +0x98d
github.com/dpattmann/prometheus-timestream-adapter.TimeStreamAdapter.runReadRequestQuery({{0xbb1606, 0xc}, 0xc00011c678, {0xbaf266, 0x9}, {0xddbf10, 0x12c4f90}, {0xddc090, 0x12c4fa0}}, 0xc000413c50)
    /home/ubuntu/prometheus-timestream-adapter/timestream.go:224 +0xd0
github.com/dpattmann/prometheus-timestream-adapter.TimeStreamAdapter.Read({{0xbb1606, 0xc}, 0xc00011c678, {0xbaf266, 0x9}, {0xddbf10, 0x12c4f90}, {0xddc090, 0x12c4fa0}}, 0xc000442210)
    /home/ubuntu/prometheus-timestream-adapter/timestream.go:207 +0x158
github.com/dpattmann/prometheus-timestream-adapter.TestTimeSteamAdapter_Read.func1(0xc000441040)
    /home/ubuntu/prometheus-timestream-adapter/timestream_test.go:582 +0xde
testing.tRunner(0xc000441040, 0xc0003e4f70)
    /usr/local/go/src/testing/testing.go:1259 +0x102
created by testing.(*T).Run
    /usr/local/go/src/testing/testing.go:1306 +0x35a
exit status 2
FAIL    github.com/dpattmann/prometheus-timestream-adapter  0.013s
ratovarius commented 2 years ago

This is happening when I change the default database name in init(). How can I set a custom database name ?

dpattmann commented 2 years ago

Hi @ratovarius, there is a command line option --databaseName to set a custom db name.

ratovarius commented 2 years ago

Thanks. So, I edit the Dokerfile,

...
ENTRYPOINT ["/usr/local/bin/prometheus-timestream-adapter --databaseName my_database --tableName my_table --logLevel debug"]

after that I create and push the image. The kubernetes pod is loading the image, but getting,

  timestream-adapter:
    ...
    Port:           <none>
    Host Port:      <none>
    State:          Waiting
      Reason:       CrashLoopBackOff
    Last State:     Terminated
      Reason:       ContainerCannotRun
      Message:      OCI runtime create failed: container_linux.go:380: starting container process caused: exec: "/usr/local/bin/prometheus-timestream-adapter --databaseName my_database --tableName my_table-table --logLevel debug": stat /usr/local/bin/prometheus-timestream-adapter --databaseName my_database --tableName my_table-table --logLevel debug: no such file or directory: unknown

there is something wrong on my setup?

ratovarius commented 2 years ago

my bad, the correct command is,

...
ENTRYPOINT ["/usr/local/bin/prometheus-timestream-adapter",  "--databaseName", "my_database", "--tableName", "my_table", "--logLevel", "debug"]
dpattmann commented 2 years ago

You don't have to change the Dockerfile. Just pass command line parameters directly to the container.

docker run dpattmann/prometheus-timestream-adapter --help                                 
      --awsRegion string        (default "eu-central-1")
      --databaseName string     (default "prometheus-database")
      --help                   
      --listenAddr string       (default ":9201")
      --logLevel string         (default "error")
      --tableName string        (default "prometheus-table")
      --telemetryPath string    (default "/metric")
      --tls                    
      --tlsCert string          (default "tls.cert")
      --tlsKey string           (default "tls.key")