Skip to content

Commit e4c2a52

Browse files
authored
Merge pull request #120 from justwatchcom/philippdefner/small-text-fixes
Small wording and formatting changes, moved Getenv inline
2 parents c7792a0 + 40a4e08 commit e4c2a52

2 files changed

Lines changed: 11 additions & 15 deletions

File tree

README.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -215,13 +215,12 @@ LOGLEVEL=info ./sql_exporter
215215
Database specific configurations
216216
--------------------------------
217217
218-
For some database backends some special functionality is available :
218+
For some database backends some special functionality is available:
219219
220-
* cloudsql-postgres: a special `*` caracter can be used to query all databases
221-
accessible by the account
222-
* cloudsql-mysql : same as above
223-
* rds-postgres : this type of URL expects a working AWS configuration
224-
which will use action the equivalent of `rds generate-db-auth-token`
220+
* cloudsql-postgres: A special `*` character can be used to query all databases accessible by the account
221+
* cloudsql-mysql: Same as above
222+
* rds-postgres: This type of URL expects a working AWS configuration
223+
which will use the equivalent of `rds generate-db-auth-token`
225224
for the password. For this driver, the `AWS_REGION` environment variable
226225
must be set.
227226

job.go

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -225,22 +225,19 @@ func (j *Job) updateConnections() {
225225
continue
226226
}
227227
if strings.HasPrefix(conn, "rds-postgres://") {
228-
// reuse postgres SQLDriver by stripping rds- from connexion URL after building the RDS
229-
// authentication token
228+
// Reuse Postgres driver by stripping "rds-" from connection URL after building the RDS authentication token
230229
conn = strings.TrimPrefix(conn, "rds-")
231-
// FIXME - parsing twice the conn url to extract host & username
232230
u, err := url.Parse(conn)
233231
if err != nil {
234-
level.Error(j.log).Log("msg", "Failed to parse URL", "url", conn, "err", err)
235-
continue
236-
}
237-
region := os.Getenv("AWS_REGION")
232+
level.Error(j.log).Log("msg", "failed to parse connection url", "url", conn, "err", err)
233+
continue
234+
}
238235
sess := session.Must(session.NewSessionWithOptions(session.Options{
239236
SharedConfigState: session.SharedConfigEnable,
240237
}))
241-
token, err := rdsutils.BuildAuthToken(u.Host, region, u.User.Username(), sess.Config.Credentials)
238+
token, err := rdsutils.BuildAuthToken(u.Host, os.Getenv("AWS_REGION"), u.User.Username(), sess.Config.Credentials)
242239
if err != nil {
243-
level.Error(j.log).Log("msg", "Failed to parse URL", "url", conn, "err", err)
240+
level.Error(j.log).Log("msg", "failed to parse connection url", "url", conn, "err", err)
244241
continue
245242
}
246243
conn = strings.Replace(conn, "AUTHTOKEN", url.QueryEscape(token), 1)

0 commit comments

Comments
 (0)