API Key Authentication
#
Generate an API KeyWhen one of the authentication providers is configured, API clients should provide an
authentication token. You can generate it via the UI, if you have Admin
role:
- Log in using an account with the Admin role.
- Navigate to Settings page in the left sidebar.
- Open API keys tab.
- Click on Add Key button.
- Type in a descriptive unique API key name.
- Select the appropriate role.
- Specify expiration period in seconds. Set 0, if you want the key to never expire.
- Click Add API Key button.
- Copy the key. The key is not stored and can't be viewed after the creation.
tip
If you don't have an admin user, follow the instructions to create one
#
Authenticate Agents with an API KeyPyroscope Server can be configured to require authentication from the agents ingesting data in the push mode. By default, anyone can send data to Pyroscope Server without any authentication.
#
1. Enable Agent AuthenticationIn order to secure the data ingestion, specify the auth.ingestion.enabled
parameter in the Pyroscope configuration file:
auth: ingestion: enabled: true
The options can be also specified via CLI flags or environment variables. See the server configuration page for more details on the Pyroscope configuration.
You will need to restart Pyroscope Server for the configuration to take effect.
#
2. Get API KeyFirst, we need to get an API key with the Agent
role that would allow agents to authenticate and ingest data.
Generate an API Key paragraph describes how a new key can be generated.
#
3. Specify Authentication TokenNow the API Key should be provided to the agent as the authentication token. The way an authentication token is specified on the agent side depends on the integration used and is described in the corresponding page.
For example, in Go you should specify AuthToken
configuration parameter:
package main
import "github.com/pyroscope-io/client/pyroscope"
func main() { pyroscope.Start(pyroscope.Config{ ApplicationName: "simple.golang.app", ServerAddress: "http://pyroscope-server:4040", AuthToken: os.Getenv("PYROSCOPE_AUTH_TOKEN"), })
// your code goes here}
If the application is profiled using exec
or connect
mode, we recommend you specifying the API Key via the
PYROSCOPE_AUTH_TOKEN
environment variable.