Skip to content

mysql_exporter and mysql_importer have confusing error messages #1

@bertrand-lorentz

Description

@bertrand-lorentz

When using mysql_exporter and mysql_importer, if the DB_NAME variable is not defined (neither in a .env file not as an environment variable), the error messages are incorrect and confusing:

docker run --rm -it \
          --volume $PWD/output:/home/mysql/output \
          --workdir /home/mysql/output \
          docker.io/joseluisq/mysql-client:8 \
          mysql_exporter
. . .

/usr/local/bin/___mysqlexport.sh: line 14: DB_NAME: command not found
/usr/local/bin/___mysqlexport.sh: line 14: ERROR:  env variable is required.: command not found

I think this is because the lines that check that the required variables are defined are incorrect.
For example:

if [[ -z "$DB_NAME" ]]; then "ERROR: `DB_NAME` env variable is required."; exit 1; fi

should have "echo" and probably not use backticks around the variable name:

if [[ -z "$DB_NAME" ]]; then echo "ERROR: DB_NAME env variable is required."; exit 1; fi

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions