31 lines
773 B
Markdown
31 lines
773 B
Markdown
---
|
|
title: Use secrets
|
|
description: Use secrets in a query with Flux.
|
|
influxdb/v2/tags: [secrets, security]
|
|
menu:
|
|
influxdb_v2:
|
|
parent: Manage secrets
|
|
weight: 305
|
|
aliases:
|
|
- /influxdb/v2/security/secrets/manage-secrets/use/
|
|
- /influxdb/v2/security/secrets/use/
|
|
---
|
|
|
|
## Use secrets in a query
|
|
Import the `influxdata/influxd/secrets` package and use the `secrets.get()` function
|
|
to populate sensitive data in queries with secrets from your secret store.
|
|
|
|
```js
|
|
import "influxdata/influxdb/secrets"
|
|
import "sql"
|
|
|
|
username = secrets.get(key: "POSTGRES_USERNAME")
|
|
password = secrets.get(key: "POSTGRES_PASSWORD")
|
|
|
|
sql.from(
|
|
driverName: "postgres",
|
|
dataSourceName: "postgresql://${username}:${password}@localhost",
|
|
query:"SELECT * FROM example-table",
|
|
)
|
|
```
|