Expose Elasticsearch index settings through Application Settings API

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

Problem to solve

Organizations using GitLab's Advanced Search feature with multiple Elasticsearch indexes cannot programmatically access or configure their Elasticsearch settings through the API, even though these settings are available in the Admin UI. This limitation impacts:

  • DevOps teams implementing infrastructure-as-code who need to configure Elasticsearch settings through automation
  • System administrators managing multiple GitLab instances who require API access for bulk configuration
  • Monitoring solutions that need to track and audit Elasticsearch configuration changes programmatically
  • CI/CD pipelines that validate or update search settings as part of deployment workflows

Currently, administrators must manually navigate to the Admin UI at /admin/application_settings/search to view or modify Elasticsearch index settings, which doesn't scale for organizations managing multiple instances or requiring automated configuration management.

Proposal

The Advanced Search settings (Elasticsearch index settings) are currently visible and configurable through the GitLab Admin UI but are not exposed through the Application Settings API endpoint. This creates a feature gap that prevents programmatic access and configuration of multiple Elasticsearch indexes.

Current State:

  • Admin UI displays multiple Elasticsearch indexes with their settings at /admin/application_settings/search#js-elasticsearch-settings
  • The API endpoint /api/v4/application/settings only exposes a single elasticsearch_shards attribute
  • The Elasticsearch::IndexSetting model exists and is accessible through ApplicationSetting but isn't mapped to the API response

Proposed Solution: Expose Elasticsearch index settings through the Application Settings API to achieve feature parity with the Admin UI.

Implementation Details:

  1. Update ee/lib/ee/api/entities/application_setting.rb to expose elasticsearch_index_settings

  2. Add a new API response field that returns an array of index settings, including:

    • Index name (e.g., gitlab-production, gitlab-production-work_items)
    • Number of shards (elasticsearch_shards)
    • Number of replicas (elasticsearch_replicas)
    • Any other index-specific configurations available in the model
  3. Include proper EE license checks as this is an Enterprise Edition feature

  4. Maintain backward compatibility with the existing elasticsearch_shards field

Example API Response:

{
  "elasticsearch_shards": 5,  // Keep for backward compatibility
  "elasticsearch_index_settings": [
    {
      "index_name": "gitlab-production",
      "shards": 5,
      "replicas": 1
    },
    {
      "index_name": "gitlab-production-work_items",
      "shards": 3,
      "replicas": 1
    }
  ]
}

Use Cases:

  • Infrastructure-as-code workflows that need to configure Elasticsearch settings
  • Automation scripts for managing GitLab instances
  • Monitoring and observability tools that need to track Elasticsearch configuration

Related Code:

  • Model: ee/app/models/ee/application_setting.rb#L477 (references Elasticsearch::IndexSetting)
  • API Entity to update: ee/lib/ee/api/entities/application_setting.rb
  • Admin UI view that displays the settings correctly
Edited by 🤖 GitLab Bot 🤖