chop-dbhi / prometheus-sql

Service that exposes Prometheus metrics for a SQL result set.
BSD 2-Clause "Simplified" License
202 stars 55 forks source link

allow environment variables in connection properties #44

Closed sethishi closed 6 years ago

sethishi commented 6 years ago

We would like to use environment variables we can inject into the different instances of the prometheus-sql agents to ensure that we can run a docker container per environment we want to monitor. We could not find anything so far, and when we tried to add the environment variable in our queries.yml file, it cannot connect and seems not to resolve the host: [prometheus_query] 2018/04/23 15:09:16 503 Service Unavailable: problem connecting to database: dial tcp: lookup ${MYSQL_HOST}: no such host Basically what we want to do is add the following block. We currently tried it in the queries.yml file, but would at some point like to use these variables in the config file to prevent duplication.

connection:
        host: ${MYSQL_HOST}
        port: 3306
        user: ${MYSQL_USER}
        password: ${MYSQL_PASSWORD}
        database: ${MYSQL_DB}

Do you already support this behaviour? If not is there a workaround for now, or a plan to support that feature?

Thanks

bruth commented 6 years ago

Good suggestion! This is straightforward to add.

bruth commented 6 years ago

Opened a PR in #45