Skip to main content
Grafana supports configuration through environment variables, which is particularly useful for containerized deployments, cloud environments, and keeping sensitive credentials out of configuration files.

Environment Variable Format

All configuration file settings can be overridden using environment variables with this format:

Naming Convention

  • Prefix: GF_
  • Section name: Uppercase with underscores replacing dots
  • Key name: Uppercase with underscores replacing hyphens

Examples

Common Environment Variables

Server Configuration

Database Configuration

Security Configuration

Authentication Providers

GitHub OAuth:
Google OAuth:
Azure AD:
Generic OAuth:
LDAP:

SMTP Configuration

Paths Configuration

Logging Configuration

User Management

Analytics Configuration

Docker Environment Variables

When running Grafana in Docker, pass environment variables using the -e flag:
Or use a .env file with Docker Compose:

Kubernetes Deployment

For Kubernetes, use ConfigMaps and Secrets:

Special Character Handling

When using environment variables with special characters, proper shell quoting may be required:

Verifying Environment Variables

To verify which environment variables are being used:

Precedence and Overrides

Configuration values are applied in this order (later overrides earlier):
  1. Default values from conf/defaults.ini
  2. Custom configuration from conf/custom.ini
  3. Environment variables (highest priority)
  4. Command-line arguments
Environment variables always take precedence over configuration file settings.

Best Practices

  1. Use environment variables for secrets - Never commit passwords to configuration files
  2. Document your variables - Keep a list of required environment variables
  3. Use secret management - Leverage Kubernetes Secrets, AWS Secrets Manager, or HashiCorp Vault
  4. Validate before deployment - Test configuration in non-production environments
  5. Avoid hardcoding - Use variable interpolation where possible
  6. Use .env files locally - Keep development configuration consistent
  7. Set defaults - Provide sensible defaults for non-sensitive variables

Troubleshooting

Environment variables not taking effect:
  • Verify the variable name follows the GF_SECTION_KEY format
  • Check for typos in variable names
  • Ensure variables are exported (use export in shell)
  • Restart Grafana after changing environment variables
Values not being parsed correctly:
  • Check for proper quoting of special characters
  • Verify boolean values are true or false (lowercase)
  • Ensure numeric values don’t have quotes
Debug configuration: