Configuration

Configure the LogFlux Collector CLI

This guide covers configuring the LogFlux Collector CLI to connect to your LogFlux server.

Quick Setup

After installing the CLI, initialize the configuration:

1
2
3
4
5
# Create default configuration file
./logflux-collector -init

# Edit the configuration with your LogFlux credentials
nano ~/.logflux-collector.json

Configuration File Structure

The configuration file uses JSON format with the following structure:

1
2
3
4
5
6
7
{
  "server_url": "https://c12345.ingest.us.logflux.io/v1",
  "api_key": "lf_abcd1234efgh5678ijkl9012mnop3456",
  "node_id": "server-01",
  "secret": "32-character-encryption-secret-key",
  "prefix": "myapp"
}

Configuration Fields

Field Required Description Example
server_url Yes Your LogFlux ingest endpoint https://c12345.ingest.us.logflux.io/v1
api_key Yes Your LogFlux API key lf_abcd1234efgh5678ijkl9012mnop3456
node_id Yes Unique identifier for this client server-01
secret Yes Encryption secret for log data 32-character-encryption-secret-key
prefix No Default prefix for log messages myapp

Server URL Format

LogFlux uses customer-specific endpoints in the format:

https://[customer-id].ingest.[region].logflux.io/v1

Examples:

  • https://c12345.ingest.us.logflux.io/v1 (US region)
  • https://c12345.ingest.eu.logflux.io/v1 (EU region)
  • https://c12345.ingest.ap.logflux.io/v1 (Asia Pacific region)

API Key Format

LogFlux API keys follow a specific format:

  • Prefix: All keys start with lf_
  • Format: lf_ followed by 32 alphanumeric characters
  • Example: lf_abcd1234efgh5678ijkl9012mnop3456

Configuration Locations

The CLI looks for configuration files in the following order:

  1. Custom path (via -config flag): ./logflux-collector -config /path/to/config.json
  2. User home directory: ~/.logflux-collector.json
  3. Current directory: ./logflux-collector.json

Environment Variables

You can override configuration values using environment variables:

1
2
3
4
5
export LOGFLUX_SERVER_URL="https://c12345.ingest.us.logflux.io/v1"
export LOGFLUX_API_KEY="lf_abcd1234efgh5678ijkl9012mnop3456"
export LOGFLUX_NODE_ID="server-01"
export LOGFLUX_SECRET="32-character-encryption-secret-key"
export LOGFLUX_PREFIX="myapp"

Environment variables take precedence over configuration file values.

Security Considerations

API Key Security

  • Never commit API keys to version control
  • Use environment variables in production
  • Rotate API keys periodically
  • Store keys securely using your preferred secrets management solution

Encryption Secret

  • Must be exactly 32 characters long
  • Use a cryptographically secure random string
  • Keep the secret secure and never share it
  • Different secrets can be used for different environments

File Permissions

Secure your configuration file:

1
2
3
4
5
6
# Set restrictive permissions
chmod 600 ~/.logflux-collector.json

# Verify permissions
ls -la ~/.logflux-collector.json
# Should show: -rw------- (600)

Validation

Test your configuration:

1
2
3
4
5
6
7
8
# Check version and basic functionality
./logflux-collector -version

# Test connectivity to LogFlux server
./logflux-collector -health

# Send a test message
./logflux-collector -message "Configuration test successful"

Common Issues

Invalid API Key

Error: authentication failed: invalid API key
  • Verify your API key starts with lf_
  • Check that the key is exactly 32 characters after the prefix
  • Ensure no extra spaces or characters

Connection Errors

Error: connection failed: dial tcp: lookup failed
  • Verify your server URL is correct
  • Check network connectivity
  • Ensure the endpoint is accessible from your location

Encryption Errors

Error: encryption failed: invalid secret length
  • Verify your secret is exactly 32 characters
  • Use only alphanumeric characters and standard symbols
  • Regenerate the secret if needed

Production Setup

For production deployments:

1. Use Environment Variables

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
# /etc/systemd/system/logflux-collector.service
[Unit]
Description=LogFlux Collector
After=network.target

[Service]
Type=simple
User=logflux
Environment=LOGFLUX_SERVER_URL=https://c12345.ingest.us.logflux.io/v1
Environment=LOGFLUX_API_KEY=lf_abcd1234efgh5678ijkl9012mnop3456
Environment=LOGFLUX_NODE_ID=prod-server-01
Environment=LOGFLUX_SECRET=32-character-encryption-secret-key
ExecStart=/usr/local/bin/logflux-collector -tail
Restart=always

[Install]
WantedBy=multi-user.target

2. Secure Configuration Storage

1
2
3
# Use your preferred secrets management solution
# Examples: HashiCorp Vault, Kubernetes secrets, etc.
export LOGFLUX_API_KEY=$(your-secrets-command)

3. Monitor Configuration

1
2
3
4
5
# Regular health checks
./logflux-collector -health

# Validate configuration
./logflux-collector -config /path/to/config.json -health

Next Steps