Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cloudfoundry -use-cf-binding does not work #247

Closed
tuxjockey opened this issue Mar 26, 2019 · 7 comments
Closed

Cloudfoundry -use-cf-binding does not work #247

tuxjockey opened this issue Mar 26, 2019 · 7 comments
Labels

Comments

@tuxjockey
Copy link

tuxjockey commented Mar 26, 2019

Hello,

I have built the exporter from the latest release and created an app out of it in cloudfoundry. The binary is not allowing me to use the -use-cf-bindings flag and throws an error. For eg:

vcap@2e453d54-dd7f-43c3-4133-3a93:~/app/bin$ ./redis_exporter -use-cf-bindings
INFO[0000] Redis Metrics Exporter <<< filled in by build >>>    build date: <<< filled in by build >>>    sha1: <<< filled in by build >>>    Go: go1.8.7 
panic: interface conversion: interface {} is float64, not string

goroutine 1 [running]:
github.com/oliver006/redis_exporter/exporter.getAlternative(0xc4200fc720, 0xc42010ba48, 0x1, 0x1, 0xc4200fa600, 0xc)
        /tmp/gobuildpack.gopath505888155/.go/src/github.com/oliver006/redis_exporter/exporter/discovery.go:107 +0xd7
github.com/oliver006/redis_exporter/exporter.GetCloudFoundryRedisBindings(0x562000000004, 0x41, 0xc420057ef0, 0x4, 0x4, 0xc420015c1c, 0xc4200fa250, 0x90, 0xa0)
        /tmp/gobuildpack.gopath505888155/.go/src/github.com/oliver006/redis_exporter/exporter/discovery.go:90 +0x38e
main.main()
        /tmp/gobuildpack.gopath505888155/.go/src/github.com/oliver006/redis_exporter/main.go:109 +0xb9d
vcap@2e453d54-dd7f-43c3-4133-3a93:~/app/bin$ 

I have not passed the other flags here, but this gives the same error if I do. The same binary works perfectly fine if I pass the details (IP:PORT and Passord)as env variables. Would be great if I can use the flag -use-cf-bindings so that I don't need to pass the credentials, instead just bind the app to a redis service instance

Thanks.
Tuxjockey

@oliver006
Copy link
Owner

oliver006 commented Mar 26, 2019

Sorry, not familiar with how CloudFoundry works. The CF integration was done by @ihrigb in #103 - maybe he can add some more info as to what's wrong or how to fix it.

I took a quick look at the code that's failing and my best guess would be that getAlternative(), when used for port fails cause it's trying to cast a float to a string.
One way to fix it could be to change line 107 and do a switch on the type of value when casting and, if a float, turn it into a string.

@ihrigb
Copy link
Contributor

ihrigb commented Mar 26, 2019

Hi @tuxjockey, the flag needs a double dash: ./redis_exporter --use-cf-bindings. Can you please try that?

@tuxjockey
Copy link
Author

@ihrigb I tried that too and gives me the same result.

@ihrigb
Copy link
Contributor

ihrigb commented Mar 27, 2019

Can you send a copy of your binding credentials? (Mask out the username and password).

@tuxjockey
Copy link
Author

Hello @ihrigb Below are the details

VCAP_SERVICES={"p-redis":[{
  "name": "redis-exporter",
  "instance_name": "redis-exporter",
  "binding_name": null,
  "credentials": {
    "host": "xxxxxx",
    "password": "xxxxxxxxxx",
    "port": 123456
  },
  "syslog_drain_url": null,
  "volume_mounts": [

  ],
  "label": "p-redis",
  "provider": null,
  "plan": "shared-vm",
  "tags": [
    "pivotal",
    "redis"
  ]
}]}

@tuxjockey
Copy link
Author

tuxjockey commented Apr 17, 2019

For now, I am using this exporter by passing the service keys as env variables

@oliver006
Copy link
Owner

Closing this, CloudFoundry is no longer directly supported by the exporter itself. Please move your service discovery to where you run the Prometheus server and use e.g. file_sd_config.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants