Overview
Elasticsearch is the primary datastore for SafeNetworking, storing threat logs, domain intelligence, tag information, and enriched event data. This guide covers Elasticsearch configuration, index management, and backup settings.Connection Settings
Elasticsearch connection settings are configured in the.panrc file in your home directory.
Host and Port Configuration
- Host:
localhost(all components on same system) - Port:
9200(standard Elasticsearch HTTP port) - Protocol: HTTP
For production deployments, you can point to a remote Elasticsearch cluster by changing
ELASTICSEARCH_HOST to the cluster IP or hostname.Authentication
If your Elasticsearch cluster requires authentication:Application Configuration
These settings are defined inproject/__init__.py and loaded from .panrc:
Elasticsearch System Configuration
The main Elasticsearch configuration file is located at:Cluster and Node Settings
Data and Log Paths
The
path.repo setting is automatically configured during installation using the setup.sh script, which substitutes your home directory path.Network Settings
Performance Tuning
Memory Configuration
JVM heap size is configured in/etc/elasticsearch/jvm.options.
Heap Size Settings
Memory Lock Settings
Heap memory locking can be enabled to prevent swapping:/etc/security/limits.conf:
Verifying Memory Settings
After starting Elasticsearch, verify settings:Index Patterns and Mappings
SafeNetworking uses several Elasticsearch indices with custom mappings.Index Structure
| Index Pattern | Purpose | Time-based |
|---|---|---|
threat-* | Threat logs from PAN-OS firewalls | Yes (monthly) |
traffic-* | Traffic logs (disabled by default) | Yes (monthly) |
system-* | System logs from PAN-OS | Yes (monthly) |
config-* | Configuration change logs | Yes (monthly) |
iot-* | IoT threat detection logs | Yes (monthly) |
af-details | AutoFocus sample details | No |
sfn-domain-details | Cached domain intelligence | No |
sfn-tag-details | AutoFocus tag information | No |
sfn-iot-details | IoT malware lookup data | No |
Installing Index Mappings
Index mappings are automatically installed by thesetup.sh script:
Key Field Mappings
The threat log mapping includes important fields:Replica Configuration
For single-node deployments, replicas are disabled:For production clusters with multiple nodes, increase the replica count for high availability.
Backup Configuration
SafeNetworking creates a backup directory for Elasticsearch snapshots.Backup Directory Setup
The setup script creates and configures the backup directory:~/es_backup
Permissions: 0777 (world-writable, required for Elasticsearch access)
Repository Registration
Register the backup repository in Elasticsearch:Creating Snapshots
Create a snapshot of all indices:Restoring from Backup
System Tuning
The setup script configures system settings for optimal Elasticsearch performance.System Limits
Configured in/etc/security/limits.conf:
Virtual Memory
Configured in/etc/sysctl.conf:
Service Management
Elasticsearch runs as a systemd service.Enable and Start Service
Check Service Status
View Logs
Elasticsearch Version
SafeNetworking is tested with Elasticsearch 6.4:Index mappings are version-specific. The
install/elasticsearch/mappings/ES-6.x/ directory contains mappings for Elasticsearch 6.x.Troubleshooting
Connection Refused
Symptom: Cannot connect to Elasticsearch Solutions:- Check if service is running:
sudo systemctl status elasticsearch - Verify port is listening:
sudo netstat -tlnp | grep 9200 - Check logs:
tail -f /var/log/elasticsearch/*.log - Wait 10-15 seconds after starting (Elasticsearch takes time to initialize)
Out of Memory
Symptom: Elasticsearch crashes or becomes unresponsive Solutions:- Increase heap size in
/etc/elasticsearch/jvm.options - Reduce index size by deleting old indices
- Add more system RAM
- Disable replicas on single-node setups
Courier Fetch Errors in Kibana
Symptom: Kibana visualizations show courier fetch errors Solution: Increase search queue size inelasticsearch.yml:
Disk Space Issues
Symptom: Elasticsearch enters read-only mode Solutions:- Delete old indices:
curl -XDELETE http://localhost:9200/threat-2020.01 - Increase disk space
- Configure index lifecycle management (ILM) policies
Related Configuration
- AutoFocus API Configuration - Configure threat intelligence source
- Logstash Pipelines - Configure data ingestion
Source References
Configuration files:project/__init__.py:164-169- Application connection settingsinstall/elasticsearch/config/elasticsearch_template.yml- Main configuration templateinstall/elasticsearch/config/jvm.options- JVM memory settingsinstall/elasticsearch/mappings/- Index mapping definitionsinstall/setup.sh:48-151- Automated setup script
