|
| 1 | +# Custom Kibana Configuration |
| 2 | + |
| 3 | +This document explains how to add custom configuration to Kibana when using elastic-package. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +You can provide additional Kibana configuration that will be appended to the base configuration generated by elastic-package. This allows you to: |
| 8 | + |
| 9 | +- Override default settings |
| 10 | +- Add custom plugins configuration |
| 11 | +- Set up custom security settings |
| 12 | +- Configure additional features |
| 13 | + |
| 14 | +## Setup |
| 15 | + |
| 16 | +1. Enable custom configuration in your profile: |
| 17 | + ```bash |
| 18 | + # Edit ~/.elastic-package/profiles/default/config.yml |
| 19 | + stack.kibana_custom_config_enabled: true |
| 20 | + ``` |
| 21 | + |
| 22 | +2. Create your custom configuration file: |
| 23 | + ```bash |
| 24 | + # Create ~/.elastic-package/profiles/default/kibana-custom.yml |
| 25 | + touch ~/.elastic-package/profiles/default/kibana-custom.yml |
| 26 | + ``` |
| 27 | + |
| 28 | +3. Add your custom configuration: |
| 29 | + ```yaml |
| 30 | + # Example custom configuration |
| 31 | + logging.loggers: |
| 32 | + - name: plugins.security |
| 33 | + level: debug |
| 34 | + |
| 35 | + server.customResponseHeaders: |
| 36 | + X-Custom-Header: "MyValue" |
| 37 | + |
| 38 | + # Template variables are supported |
| 39 | + xpack.security.enabled: {{ if eq .security_enabled "true" }}true{{ else }}false{{ end }} |
| 40 | + ``` |
| 41 | +
|
| 42 | +## Template Support |
| 43 | +
|
| 44 | +Your custom configuration supports the same templating as the base configuration: |
| 45 | +
|
| 46 | +- `{{ fact "kibana_version" }}` - Kibana version |
| 47 | +- `{{ fact "username" }}` - Elasticsearch username |
| 48 | +- `{{ fact "password" }}` - Elasticsearch password |
| 49 | +- `{{ fact "apm_enabled" }}` - APM enabled flag |
| 50 | +- `{{ fact "self_monitor_enabled" }}` - Self monitoring enabled flag |
| 51 | +- All other facts available in the base template |
| 52 | + |
| 53 | +### Available Template Variables |
| 54 | + |
| 55 | +The following template variables are available in your custom configuration: |
| 56 | + |
| 57 | +| Variable | Description | Example | |
| 58 | +|----------|-------------|---------| |
| 59 | +| `kibana_version` | Version of Kibana | `8.11.0` | |
| 60 | +| `elasticsearch_version` | Version of Elasticsearch | `8.11.0` | |
| 61 | +| `agent_version` | Version of Elastic Agent | `8.11.0` | |
| 62 | +| `username` | Elasticsearch username | `elastic` | |
| 63 | +| `password` | Elasticsearch password | `changeme` | |
| 64 | +| `kibana_host` | Kibana host URL | `https://kibana:5601` | |
| 65 | +| `elasticsearch_host` | Elasticsearch host URL | `https://elasticsearch:9200` | |
| 66 | +| `fleet_url` | Fleet server URL | `https://fleet-server:8220` | |
| 67 | +| `apm_enabled` | APM enabled flag | `true`/`false` | |
| 68 | +| `logstash_enabled` | Logstash enabled flag | `true`/`false` | |
| 69 | +| `self_monitor_enabled` | Self monitoring flag | `true`/`false` | |
| 70 | + |
| 71 | +## Configuration Precedence |
| 72 | + |
| 73 | +1. Base elastic-package configuration (from template) |
| 74 | +2. Your custom configuration (appended) |
| 75 | + |
| 76 | +Since YAML allows duplicate keys and Kibana processes them in order, your custom settings will override base settings with the same key. |
| 77 | + |
| 78 | +## Examples |
| 79 | + |
| 80 | +### Enable Debug Logging |
| 81 | +```yaml |
| 82 | +logging.loggers: |
| 83 | + - name: root |
| 84 | + level: debug |
| 85 | + - name: plugins.fleet |
| 86 | + level: trace |
| 87 | +``` |
| 88 | + |
| 89 | +### Custom Security Settings |
| 90 | +```yaml |
| 91 | +xpack.security.session.idleTimeout: "8h" |
| 92 | +xpack.security.session.lifespan: "24h" |
| 93 | +xpack.security.authc.providers: |
| 94 | + basic.basic1: |
| 95 | + order: 0 |
| 96 | +``` |
| 97 | + |
| 98 | +### Development Features |
| 99 | +```yaml |
| 100 | +server.rewriteBasePath: false |
| 101 | +server.dev.basePathProxyTarget: 3000 |
| 102 | +
|
| 103 | +# Enable experimental features |
| 104 | +xpack.fleet.enableExperimental: |
| 105 | + - customIntegrations |
| 106 | + - agentTamperProtectionEnabled |
| 107 | +``` |
| 108 | + |
| 109 | +### Custom UI Settings |
| 110 | +```yaml |
| 111 | +uiSettings: |
| 112 | + overrides: |
| 113 | + "theme:darkMode": true |
| 114 | + "dateFormat": "YYYY-MM-DD HH:mm:ss.SSS" |
| 115 | + "discover:sampleSize": 1000 |
| 116 | +``` |
| 117 | + |
| 118 | +### Template Usage Example |
| 119 | +```yaml |
| 120 | +# Use template variables in your custom config |
| 121 | +server.name: kibana-{{ fact "kibana_version" }} |
| 122 | +server.customResponseHeaders: |
| 123 | + X-Kibana-Version: "{{ fact "kibana_version" }}" |
| 124 | +
|
| 125 | +# Conditional configuration based on features |
| 126 | +{{ if eq (fact "apm_enabled") "true" }} |
| 127 | +elastic.apm.active: true |
| 128 | +elastic.apm.serverUrl: "http://fleet-server:8200" |
| 129 | +elastic.apm.environment: "development" |
| 130 | +{{ end }} |
| 131 | +
|
| 132 | +# Version-specific configuration |
| 133 | +{{ if semverLessThan (fact "kibana_version") "8.0.0" }} |
| 134 | +# Legacy configuration for older versions |
| 135 | +xpack.monitoring.ui.container.elasticsearch.enabled: true |
| 136 | +{{ else }} |
| 137 | +# Modern configuration for newer versions |
| 138 | +monitoring.ui.container.elasticsearch.enabled: true |
| 139 | +{{ end }} |
| 140 | +``` |
| 141 | + |
| 142 | +## Troubleshooting |
| 143 | + |
| 144 | +### Configuration Not Applied |
| 145 | +- Ensure `stack.kibana_custom_config_enabled: true` is set in your profile's `config.yml` |
| 146 | +- Verify the `kibana-custom.yml` file exists in your profile directory |
| 147 | +- Check that the YAML syntax is valid |
| 148 | + |
| 149 | +### Template Errors |
| 150 | +- Use `{{ fact "variable_name" }}` syntax for template variables |
| 151 | +- Ensure template functions like `semverLessThan` are used correctly |
| 152 | +- Check the elastic-package logs for template parsing errors |
| 153 | + |
| 154 | +### Kibana Startup Issues |
| 155 | +- Validate your custom configuration against Kibana documentation |
| 156 | +- Start with minimal changes and add complexity gradually |
| 157 | +- Check Kibana logs for configuration validation errors |
| 158 | + |
| 159 | +## Profile-Specific Configurations |
| 160 | + |
| 161 | +You can have different custom configurations for different profiles: |
| 162 | + |
| 163 | +```bash |
| 164 | +# Development profile with debug settings |
| 165 | +~/.elastic-package/profiles/development/kibana-custom.yml |
| 166 | +
|
| 167 | +# Production profile with optimized settings |
| 168 | +~/.elastic-package/profiles/production/kibana-custom.yml |
| 169 | +``` |
| 170 | + |
| 171 | +Each profile can enable or disable custom configuration independently. |
| 172 | + |
| 173 | +## Best Practices |
| 174 | + |
| 175 | +1. **Start Simple**: Begin with basic configuration changes and add complexity gradually |
| 176 | +2. **Use Comments**: Document your custom configurations for future reference |
| 177 | +3. **Test Changes**: Verify that Kibana starts successfully after configuration changes |
| 178 | +4. **Version Compatibility**: Use template conditions for version-specific settings |
| 179 | +5. **Backup Configurations**: Keep copies of working configurations before making changes |
| 180 | + |
| 181 | +## Limitations |
| 182 | + |
| 183 | +- Custom configuration is appended to the base configuration (not merged at the YAML structure level) |
| 184 | +- Template processing errors will prevent stack startup |
| 185 | +- Some Kibana settings may require specific ordering or dependencies |
| 186 | + |
| 187 | +## Related Documentation |
| 188 | + |
| 189 | +- [Kibana Configuration Settings](https://www.elastic.co/guide/en/kibana/current/settings.html) |
| 190 | +- [elastic-package Profiles](../README.md#profiles) |
| 191 | +- [Stack Configuration](../README.md#stack-configuration) |
0 commit comments