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

first path segment in URL cannot contain colon #3794

Closed
rdxmb opened this issue Feb 14, 2018 · 4 comments · Fixed by #4511
Closed

first path segment in URL cannot contain colon #3794

rdxmb opened this issue Feb 14, 2018 · 4 comments · Fixed by #4511
Assignees
Labels
area/influxdb bug unexpected problem or unintended behavior
Milestone

Comments

@rdxmb
Copy link
Contributor

rdxmb commented Feb 14, 2018

Bug report

Relevant telegraf.conf:

[[outputs.influxdb]]
  urls = ["$INFLUXDB_HOST_FULL_ADDRESS"] # required
  ## The target database for metrics (telegraf will create it if not exists).
  database = "$INFLUXDB_DB"
  username = "$INFLUXDB_WRITE_USER"
  password = "$INFLUXDB_WRITE_USER_PASSWORD"

System info:

telegraf 1.5.2

Steps to reproduce:

  1. define telegraf in docker with
services:
  telegraf-servicechecker:
    image: telegraf
    hostname: telegraf-servicechecker
    env_file: 
      - .monitoring-env
  1. .monitoring-env is
INFLUXDB_HOST_FULL_ADDRESS="http://yoururl.com:8086"
INFLUXDB_DB=monitoring
INFLUXDB_WRITE_USER=writetoinflux
INFLUXDB_WRITE_USER_PASSWORD=veeeeerysecret

Expected behavior:

  • works ;)

If not works, the error output should be something like:
"do not use double quotes ..."

Actual behavior:

E! Failed to connect to output influxdb, retrying in 15s, error was 'Error creating HTTP Client ["http://yoururl.com:8086"]: error parsing config.URL: parse "http://yoururl.com:8086": first path segment in URL cannot contain colon'

Aditional info

edit the line to
INFLUXDB_HOST_FULL_ADDRESS=http://yoururl.com:8086
fixes the problem

@danielnelson
Copy link
Contributor

I feel like this is a quirk of docker-compose, when you set an environment variable in your shell script these outer quotes are not part of the variable:

$ export INFLUX_URL="http://localhost:8086"
$ env | grep INFLUX
INFLUX_URL=http://localhost:8086

I see in the docker-compose docs that they warn about this, I'm sure many others have ran into this:

There is no special handling of quotation marks. This means that they are part of the VAL.

I don't want to strip outer quotes automatically because I think it will cause more bugs and confusion.

@rdxmb
Copy link
Contributor Author

rdxmb commented Feb 19, 2018

I don't want to strip outer quotes automatically because I think it will cause more bugs and confusion.

Of course. Anyway: Is there a way to edit the error message? "do not use double quotes ..." is not that significant.

Anyway, the problem was really yaml-specific, as
key=value interprets all values as strings already.

@danielnelson
Copy link
Contributor

It looks like this part of the error message, parse "http://yoururl.com:8086": first path segment in URL cannot contain colon', comes directly from the Go standard library. Unfortunately you can't easily see if the quotes are extra or not from a message like this, but we probably wouldn't want to get in the business of trying to special case the error.

We are free to switch up the prefix though: Error creating HTTP Client ["http://yoururl.com:8086"]: error parsing config.URL: , perhaps we can use a %q format for the url, so that it would appear like "\"http://yoururl.com:8086\"" if there are extra quotes. Do you think that would help?

@danielnelson danielnelson reopened this Feb 20, 2018
@danielnelson danielnelson self-assigned this Feb 20, 2018
@rdxmb
Copy link
Contributor Author

rdxmb commented Feb 20, 2018

Yes, absolutely! If it is possible, I would even prefer single quotes for the outer quotes. That would give the same output as running
declare
in a telegraf container.

environment-file in yaml:

INFLUXDB_HOST_FULL_ADDRESS_DOUBLE_QUOTES="http://yourdomain.com:8086"
INFLUXDB_HOST_FULL_ADDRESS_SINGLE_QUOTES='http://yourdomain.com:8086'
INFLUXDB_HOST_FULL_ADDRESS=http://yourdomain.com:8086

running declare in the container:

root@telegraf-servicechecker:/# declare | grep HOST_FULL
INFLUXDB_HOST_FULL_ADDRESS=http://yourdomain.com:8086
INFLUXDB_HOST_FULL_ADDRESS_DOUBLE_QUOTES='"http://yourdomain.com:8086"'
INFLUXDB_HOST_FULL_ADDRESS_SINGLE_QUOTES=''\''http://yourdomain.com:8086'\'''

(if there is a better tool like declare, that could be the reference though)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/influxdb bug unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants